Skip to content

Commit

Permalink
Fix inherited cti.reference check
Browse files Browse the repository at this point in the history
  • Loading branch information
yury-palyanitsa authored and IKukhta committed Feb 25, 2025
1 parent 59c2397 commit 33fa16d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions metadata/validator/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
Expand Down

0 comments on commit 33fa16d

Please sign in to comment.