diff --git a/tools/devsecops_engine_tools/engine_risk/test/domain/usecases/test_handle_filters.py b/tools/devsecops_engine_tools/engine_risk/test/domain/usecases/test_handle_filters.py index 5a54ef06..f0e77625 100644 --- a/tools/devsecops_engine_tools/engine_risk/test/domain/usecases/test_handle_filters.py +++ b/tools/devsecops_engine_tools/engine_risk/test/domain/usecases/test_handle_filters.py @@ -58,6 +58,84 @@ def test_filter(self, mock_get_priority_vulnerability, mock_get_active_findings) assert len(result) == 2 + def test_filter_duplicated(self): + findings = [ + Report( + id=["CVE-2021-1234"], + date="21022024", + status="stat2", + where="path2", + tags=["tag1"], + severity="low", + active=True, + ), + Report( + id=["CVE-2021-1234"], + date="21022024", + status="stat2", + where="path2", + tags=["tag2"], + severity="low", + active=None, + ), + Report( + id=["vuln_id"], + date="21022024", + status="stat3", + where="path3", + tags=["tag3"], + severity="info", + active=True, + ), + ] + + result = self.handle_filters.filter_duplicated(findings) + + assert len(result) == 2 + + @patch( + "devsecops_engine_tools.engine_risk.src.domain.usecases.handle_filters.Console" + ) + def test_filter_tags_days(self, mock_console): + remote_config = {"TAG_EXCLUSION_DAYS": {"tag1": 5, "tag2": 10}} + findings = [ + Report( + id=["CVE-2021-1234"], + date="21022024", + status="stat2", + where="path2", + tags=["tag1"], + severity="low", + active=True, + age=4, + ), + Report( + id=["CVE-2021-1234"], + date="21022024", + status="stat2", + where="path2", + tags=["tag2"], + severity="low", + active=None, + age=11, + ), + Report( + id=["vuln_id"], + date="21022024", + status="stat3", + where="path3", + tags=["tag3"], + severity="info", + active=True, + age=5, + ), + ] + + result = self.handle_filters.filter_tags_days(remote_config, findings) + + mock_console().print.assert_called_once() + assert len(result) == 2 + def test__get_active_findings(self): result = self.handle_filters._get_active_findings(self.findings)