@@ -19,8 +19,8 @@ def test_parse_no_findings(self):
1919 self .assertEqual (0 , len (findings ))
2020
2121 def test_parse_only_quality (self ):
22- """This report only have quality findings"""
23- with (get_unit_tests_scans_path ("coverity_api" ) / "only_quality .json" ).open (encoding = "utf-8" ) as testfile :
22+ """Non-RESOURCE_LEAK quality findings are excluded """
23+ with (get_unit_tests_scans_path ("coverity_api" ) / "only_non_resource_leak_quality .json" ).open (encoding = "utf-8" ) as testfile :
2424 parser = CoverityApiParser ()
2525 findings = parser .get_findings (testfile , Test ())
2626 self .assertEqual (0 , len (findings ))
@@ -30,11 +30,21 @@ def test_parse_some_findings(self):
3030 parser = CoverityApiParser ()
3131 findings = parser .get_findings (testfile , Test ())
3232 self .assertIsInstance (findings , list )
33- self .assertEqual (1 , len (findings ))
33+ self .assertEqual (6 , len (findings ))
3434 with self .subTest (i = 0 ):
35- finding = findings [0 ]
35+ finding = findings [0 ] # first RESOURCE_LEAK finding
3636 self .assertTrue (finding .active )
37- self .assertFalse (finding .verified ) # this one is marked as new ("status": "New")
37+ self .assertFalse (finding .verified )
38+ self .assertEqual ("Resource leak" , finding .title )
39+ self .assertEqual ("High" , finding .severity )
40+ self .assertEqual (404 , finding .cwe )
41+ self .assertEqual ("Wdkrtgthhl/Llwfzgphzw/Fashvkaxzx/Okkfacqsxw.rs" , finding .file_path )
42+ self .assertEqual (datetime .date (2021 , 3 , 23 ), finding .date )
43+ self .assertEqual (22480 , finding .unique_id_from_tool )
44+ with self .subTest (i = 4 ):
45+ finding = findings [4 ] # security finding
46+ self .assertTrue (finding .active )
47+ self .assertFalse (finding .verified )
3848 self .assertEqual ("Risky cryptographic hashing function" , finding .title )
3949 self .assertEqual ("Medium" , finding .severity )
4050 self .assertEqual (328 , finding .cwe )
@@ -47,9 +57,9 @@ def test_parse_few_findings_triaged_as_bug(self):
4757 parser = CoverityApiParser ()
4858 findings = parser .get_findings (testfile , Test ())
4959 self .assertIsInstance (findings , list )
50- self .assertEqual (1 , len (findings ))
51- with self .subTest (i = 0 ):
52- finding = findings [0 ]
60+ self .assertEqual (13 , len (findings ))
61+ with self .subTest (i = 1 ):
62+ finding = findings [1 ] # security finding (triaged as bug)
5363 self .assertTrue (finding .active )
5464 self .assertTrue (finding .verified )
5565 self .assertEqual ("HTTP header injection" , finding .title )
@@ -64,9 +74,19 @@ def test_parse_some_findings_mitigated(self):
6474 parser = CoverityApiParser ()
6575 findings = parser .get_findings (testfile , Test ())
6676 self .assertIsInstance (findings , list )
67- self .assertEqual (20 , len (findings ))
77+ self .assertEqual (25 , len (findings ))
6878 with self .subTest (i = 0 ):
69- finding = findings [0 ] # this one is dismissed as a false positive
79+ finding = findings [0 ] # RESOURCE_LEAK finding (active, status New)
80+ self .assertTrue (finding .active )
81+ self .assertFalse (finding .verified )
82+ self .assertEqual ("Resource leak" , finding .title )
83+ self .assertEqual ("High" , finding .severity )
84+ self .assertEqual (404 , finding .cwe )
85+ self .assertEqual ("Vzfkposilb/Ejgmugyeam/Ekcbsjzuiq/Isjhjabnfe.rs" , finding .file_path )
86+ self .assertEqual (datetime .date (2021 , 3 , 31 ), finding .date )
87+ self .assertEqual (22496 , finding .unique_id_from_tool )
88+ with self .subTest (i = 2 ):
89+ finding = findings [2 ] # this one is dismissed as a false positive
7090 self .assertFalse (finding .active )
7191 self .assertTrue (finding .verified )
7292 self .assertTrue (finding .false_p )
@@ -76,8 +96,8 @@ def test_parse_some_findings_mitigated(self):
7696 self .assertEqual ("Pfozpmtueo/Vtoqmbvmzf/Noxacjclcz/Aymctwefbi.rs" , finding .file_path )
7797 self .assertEqual (datetime .date (2021 , 3 , 26 ), finding .date )
7898 self .assertEqual (22486 , finding .unique_id_from_tool )
79- with self .subTest (i = 10 ):
80- finding = findings [10 ]
99+ with self .subTest (i = 12 ):
100+ finding = findings [12 ]
81101 self .assertFalse (finding .active )
82102 self .assertTrue (finding .verified )
83103 self .assertEqual ("Use of hard-coded password" , finding .title )
@@ -86,8 +106,8 @@ def test_parse_some_findings_mitigated(self):
86106 self .assertEqual ("Hvsilgzkwz/Lhmxrchybr/Edcoanzncg/Oowieyoxvn.rs" , finding .file_path )
87107 self .assertEqual (datetime .date (2021 , 3 , 15 ), finding .date )
88108 self .assertEqual (22421 , finding .unique_id_from_tool )
89- with self .subTest (i = 19 ):
90- finding = findings [19 ]
109+ with self .subTest (i = 23 ):
110+ finding = findings [23 ]
91111 self .assertFalse (finding .active )
92112 self .assertTrue (finding .verified )
93113 self .assertEqual ("Cross-site scripting" , finding .title )
0 commit comments