This repository was archived by the owner on Oct 14, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +76
-45
lines changed
hooks/declarative-subsequent-scans Expand file tree Collapse file tree 5 files changed +76
-45
lines changed Original file line number Diff line number Diff line change @@ -22,10 +22,14 @@ interface CascadingRules {
2222}
2323
2424interface CascadingRuleSpec {
25- matches : Array < Finding > ;
25+ matches : Matches ;
2626 scanSpec : ScanSpec ;
2727}
2828
29+ interface Matches {
30+ anyOf : Array < Finding > ;
31+ }
32+
2933interface Scan {
3034 metadata : k8s . V1ObjectMeta ;
3135 spec : ScanSpec ;
@@ -74,7 +78,7 @@ export function getCascadingScans(
7478 for ( const cascadingRule of cascadingRules ) {
7579 for ( const finding of findings ) {
7680 // Check if one (ore more) of the CascadingRule matchers apply to the finding
77- const matches = cascadingRule . spec . matches . some ( ( matchesRule ) =>
81+ const matches = cascadingRule . spec . matches . anyOf . some ( ( matchesRule ) =>
7882 isMatch ( finding , matchesRule )
7983 ) ;
8084
Original file line number Diff line number Diff line change @@ -4,13 +4,14 @@ metadata:
44 name : " tls-scans"
55spec :
66 matches :
7- - category : " Open Port"
8- attributes :
9- port : 443
10- service : " https"
11- - category : " Open Port"
12- attributes :
13- service : " https"
7+ anyOf :
8+ - category : " Open Port"
9+ attributes :
10+ port : 443
11+ service : " https"
12+ - category : " Open Port"
13+ attributes :
14+ service : " https"
1415 scanSpec :
1516 name : " sslyze"
1617 parameters : ["--regular", "{{attributes.hostname}}"]
Original file line number Diff line number Diff line change @@ -30,11 +30,17 @@ type CascadingRuleSpec struct {
3030 // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
3131 // Important: Run "make" to regenerate code after modifying this file
3232
33- // Foo is an example field of CascadingRule. Edit CascadingRule_types.go to remove/update
34- Matches []MatchesRule `json:"matches"`
33+ // Matches defines to which findings the CascadingRule should apply
34+ Matches Matches `json:"matches"`
35+ // ScanSpec defines how the cascaded scan should look like
3536 ScanSpec executionv1.ScanSpec `json:"scanSpec"`
3637}
3738
39+ // Matches defines how matching rules should be combined. Do all have to match? Or just One?
40+ type Matches struct {
41+ AnyOf []MatchesRule `json:"anyOf,omitempty"`
42+ }
43+
3844// MatchesRule is a generic map which is used to model the structure of a finding for which the CascadingRule should take effect
3945type MatchesRule struct {
4046 Name string `json:"name,omitempty"`
Original file line number Diff line number Diff line change @@ -35,35 +35,39 @@ spec:
3535 description : CascadingRuleSpec defines the desired state of CascadingRule
3636 properties :
3737 matches :
38- description : Foo is an example field of CascadingRule. Edit CascadingRule_types.go
39- to remove/update
40- items :
41- description : MatchesRule is a generic map which is used to model the
42- structure of a finding for which the CascadingRule should take effect
43- properties :
44- attributes :
45- additionalProperties :
46- anyOf :
47- - type : integer
48- - type : string
49- x-kubernetes-int-or-string : true
38+ description : Matches defines to which findings the CascadingRule should
39+ apply
40+ properties :
41+ anyOf :
42+ items :
43+ description : MatchesRule is a generic map which is used to model
44+ the structure of a finding for which the CascadingRule should
45+ take effect
46+ properties :
47+ attributes :
48+ additionalProperties :
49+ anyOf :
50+ - type : integer
51+ - type : string
52+ x-kubernetes-int-or-string : true
53+ type : object
54+ category :
55+ type : string
56+ description :
57+ type : string
58+ location :
59+ type : string
60+ name :
61+ type : string
62+ osi_layer :
63+ type : string
64+ severity :
65+ type : string
5066 type : object
51- category :
52- type : string
53- description :
54- type : string
55- location :
56- type : string
57- name :
58- type : string
59- osi_layer :
60- type : string
61- severity :
62- type : string
63- type : object
64- type : array
67+ type : array
68+ type : object
6569 scanSpec :
66- description : ScanSpec defines the desired state of Scan
70+ description : ScanSpec defines how the cascaded scan should look like
6771 properties :
6872 parameters :
6973 items :
You can’t perform that action at this time.
0 commit comments