Skip to content

Commit

Permalink
fixes a core dump when template_args are not set in the rule
Browse files Browse the repository at this point in the history
  • Loading branch information
Willie Sana committed Sep 14, 2020
1 parent d5418b5 commit 3dcd3c7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/policy/opa/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ func (e *Engine) LoadRegoFiles(policyPath string) error {
}

// Check for default template variable values specified
if val, ok := regoMetadata.TemplateArgs["name"]; ok {
zap.S().Warn("reserved template name arg was specified", zap.String("name", regoMetadata.Name), zap.String("file", filePath), zap.String("template arg", val.(string)))
} else {
if _, ok := regoMetadata.TemplateArgs["name"]; !ok {
if regoMetadata.TemplateArgs == nil {
regoMetadata.TemplateArgs = make(map[string]interface{})
}
// Add reserved template variable values
regoMetadata.TemplateArgs["name"] = regoMetadata.Name
}
Expand Down

0 comments on commit 3dcd3c7

Please sign in to comment.