From 33fa16d0201991e764b5053f4082e021913fe623 Mon Sep 17 00:00:00 2001 From: Yury Palyanitsa Date: Tue, 25 Feb 2025 19:09:43 +0200 Subject: [PATCH] Fix inherited cti.reference check --- metadata/validator/validator.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/metadata/validator/validator.go b/metadata/validator/validator.go index af00e8a..8caa01c 100644 --- a/metadata/validator/validator.go +++ b/metadata/validator/validator.go @@ -173,17 +173,15 @@ func (v *MetadataValidator) Validate(current *metadata.Entity) error { if parentRef != TrueStr && currentRef == TrueStr { return fmt.Errorf("%s@%s: parent cti.reference defines a specific CTI, but child specifies true", current.Cti, key) } - if currentRef == TrueStr { + // If either the parent or the current reference is true, then we don't need to validate the reference + if currentRef == TrueStr || parentRef == TrueStr { continue } - expr, err := v.ctiParser.Parse(currentRef) + expr, err := v.ctiParser.Parse(parentRef) if err != nil { return fmt.Errorf("%s@%s: %s", current.Cti, key, err.Error()) } - if parentRef == TrueStr { - continue - } - if err := v.matchCti(&expr, parentRef); err != nil { + if err := v.matchCti(&expr, currentRef); err != nil { return fmt.Errorf("%s@%s: %s", current.Cti, key, err.Error()) } }