@@ -192,3 +192,22 @@ func TestControl_GetControlTypeTags(t *testing.T) {
192
192
assert .NoError (t , err , err )
193
193
assert .Equal (t , []string {}, missingAttributeControl .GetControlTypeTags ())
194
194
}
195
+
196
+ func TestControl_IsFixedByNetworkPolicy (t * testing.T ) {
197
+ validControlJsonNoAttributes := `{"name":"TEST","description":"","remediation":"","rulesNames":["CVE-2022-0185"],"id":"C-0079","long_description":"","test":"","controlID":"C-0079","baseScore":4,"example":""}`
198
+ var validControl Control
199
+ err := json .Unmarshal ([]byte (validControlJsonNoAttributes ), & validControl )
200
+ assert .NoError (t , err , err )
201
+ assert .False (t , validControl .IsFixedByNetworkPolicy ())
202
+
203
+ validControlJson := `{"name":"TEST","attributes":{"controlTypeTags":["security","compliance"],"isFixedByNetworkPolicy":true, "attackTracks":[{"attackTrack": "network","categories": ["Eavesdropping","Spoofing"]}]},"description":"","remediation":"","rulesNames":["CVE-2022-0185"],"id":"C-0079","long_description":"","test":"","controlID":"C-0079","baseScore":4,"example":""}`
204
+ err = json .Unmarshal ([]byte (validControlJson ), & validControl )
205
+ assert .NoError (t , err , err )
206
+ assert .True (t , validControl .IsFixedByNetworkPolicy ())
207
+
208
+ missingAttributeControlJson := `{"name":"TEST","attributes":{"controlTypeTags":["security","compliance"]},"description":"","remediation":"","rulesNames":["CVE-2022-0185"],"id":"C-0079","long_description":"","test":"","controlID":"C-0079","baseScore":4,"example":""}`
209
+ var missingAttributeControl Control
210
+ err = json .Unmarshal ([]byte (missingAttributeControlJson ), & missingAttributeControl )
211
+ assert .NoError (t , err , err )
212
+ assert .False (t , missingAttributeControl .IsFixedByNetworkPolicy ())
213
+ }
0 commit comments