Skip to content

Commit 33cfa96

Browse files
authored
Don't mark manual rules without Rego as missing (#77)
* Don't mark manual rules without Rego as missing Signed-off-by: wwwil <[email protected]> * Add manual rule to TestNewReport Signed-off-by: wwwil <[email protected]>
1 parent 0098447 commit 33cfa96

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

pkg/reports/reports.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,10 @@ func NewReport(pm *packaging.PolicyManifest, rc *results.ResultCollection) (api.
126126

127127
switch {
128128
case result == nil:
129-
missing = true
130-
missingRules = append(missingRules, rule.ID)
129+
if !rule.Manual {
130+
missing = true
131+
missingRules = append(missingRules, rule.ID)
132+
}
131133
case result.IsFailureState():
132134
success = false
133135
violations = result.Violations

pkg/reports/reports_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,11 @@ func TestNewReport(t *testing.T) {
245245
ID: "b_rule",
246246
Name: "My Rule B",
247247
},
248+
{
249+
ID: "c_rule",
250+
Name: "My Rule C",
251+
Manual: true,
252+
},
248253
},
249254
},
250255
},
@@ -295,6 +300,15 @@ func TestNewReport(t *testing.T) {
295300
Links: []string{},
296301
Violations: []string{"violation"},
297302
},
303+
api.ReportRule{
304+
ID: "c_rule",
305+
Name: "My Rule C",
306+
Manual: true,
307+
Success: false,
308+
Missing: false,
309+
Links: []string{},
310+
Violations: []string{},
311+
},
298312
},
299313
},
300314
},
@@ -349,6 +363,15 @@ func TestNewReport(t *testing.T) {
349363
Links: []string{},
350364
Violations: []string{},
351365
},
366+
api.ReportRule{
367+
ID: "c_rule",
368+
Name: "My Rule C",
369+
Manual: true,
370+
Success: false,
371+
Missing: false,
372+
Links: []string{},
373+
Violations: []string{},
374+
},
352375
},
353376
},
354377
},

0 commit comments

Comments
 (0)