Skip to content

Commit a922042

Browse files
authored
fix(policy/engine): upper severity (fanal#197)
1 parent c3d5832 commit a922042

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

policy/engine.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,9 @@ func (e *Engine) queryMetadata(ctx context.Context, namespace string) (types.Pol
593593
return types.PolicyMetadata{}, xerrors.Errorf("decode error: %w", err)
594594
}
595595

596+
// e.g. Low -> LOW
597+
metadata.Severity = strings.ToUpper(metadata.Severity)
598+
596599
return metadata, nil
597600
}
598601

@@ -617,7 +620,6 @@ func (e *Engine) queryInputOption(ctx context.Context, namespace string) (types.
617620
return types.PolicyInputOption{}, xerrors.New("'__rego_input__' must be map")
618621
}
619622

620-
// Set default values
621623
var inputOption types.PolicyInputOption
622624
if err = mapstructure.Decode(result, &inputOption); err != nil {
623625
return types.PolicyInputOption{}, xerrors.Errorf("decode error: %w", err)

policy/testdata/happy/deployment.rego

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ __rego_metadata__ := {
66
"id": "XYZ-100",
77
"title": "Bad Deployment",
88
"version": "v1.0.0",
9-
"severity": "HIGH",
9+
"severity": "High",
1010
"type": "Kubernetes Security Check",
1111
}
1212

0 commit comments

Comments
 (0)