Skip to content

Commit

Permalink
Validation for security policy field existence
Browse files Browse the repository at this point in the history
  • Loading branch information
begelundmuller committed Jul 3, 2024
1 parent fbe47fe commit d0e7eb6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions runtime/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,20 @@ func (r *Runtime) ValidateMetricsView(ctx context.Context, instanceID string, mv
fields[strings.ToLower(f.Name)] = f
}

// Check security policy rules apply to fields that exist
for _, rule := range mv.SecurityRules {
fa := rule.GetFieldAccess()
if fa == nil {
continue
}

for _, f := range fa.Fields {
if _, ok := fields[strings.ToLower(f)]; !ok {
res.OtherErrs = append(res.OtherErrs, fmt.Errorf("field %q referenced in 'security' is not a dimension or measure", f))
}
}
}

// Check time dimension exists
if mv.TimeDimension != "" {
f, ok := fields[strings.ToLower(mv.TimeDimension)]
Expand Down

0 comments on commit d0e7eb6

Please sign in to comment.