Skip to content

Commit

Permalink
add missing (subject) relation checks
Browse files Browse the repository at this point in the history
  • Loading branch information
gertd committed Jul 30, 2024
1 parent 2654cdd commit 7e8c5ea
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions safe/relation.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ func (i *SafeRelation) Validate(mc *cache.Cache) error {
return nil
}

if !mc.RelationExists(model.ObjectName(i.GetObjectType()), model.RelationName(i.GetRelation())) {
return derr.ErrRelationNotFound.Msg(i.GetObjectType() + ":" + i.GetRelation())
}

if IsSet(i.GetSubjectRelation()) {
if !mc.RelationExists(model.ObjectName(i.GetSubjectType()), model.RelationName(i.GetSubjectRelation())) {
return derr.ErrRelationNotFound.Msg(i.GetSubjectType() + ":" + i.GetSubjectRelation())
}
}

return mc.ValidateRelation(i.Relation)
}

Expand Down

0 comments on commit 7e8c5ea

Please sign in to comment.