def test_vulnerability_match_trigger_cvssv3_base_score_comparison(
     self,
     image_obj,
     mock_vuln_report,
     score_comparison,
     base_score,
     expected_trigger_fired,
     setup_mocks_vulnerabilities_gate,
 ):
     setup_mocks_vulnerabilities_gate(mock_vuln_report)
     vulns_gate = VulnerabilitiesGate()
     trigger = VulnerabilityMatchTrigger(
         parent_gate_cls=VulnerabilitiesGate,
         cvss_v3_base_score_comparison=score_comparison,
         cvss_v3_base_score=base_score,
         package_type="all",
     )
     exec_context = ExecutionContext(db_session=None, configuration={})
     vulns_gate.prepare_context(image_obj, exec_context)
     trigger.evaluate(image_obj, exec_context)
     assert trigger.did_fire == expected_trigger_fired
     if expected_trigger_fired:
         assert len(trigger.fired) == 1
     else:
         assert len(trigger.fired) == 0
 def test_vulnerability_match_trigger_package_type(
     self,
     image_obj,
     mock_vuln_report,
     package_type,
     expected_trigger_fired,
     setup_mocks_vulnerabilities_gate,
 ):
     setup_mocks_vulnerabilities_gate(mock_vuln_report)
     vulns_gate = VulnerabilitiesGate()
     trigger = VulnerabilityMatchTrigger(
         parent_gate_cls=VulnerabilitiesGate, package_type=package_type)
     exec_context = ExecutionContext(db_session=None, configuration={})
     vulns_gate.prepare_context(image_obj, exec_context)
     trigger.evaluate(image_obj, exec_context)
     assert trigger.did_fire == expected_trigger_fired
 def test_vulnerability_match_trigger_max_days_since_creation(
     self,
     image_obj,
     mock_vuln_report,
     max_days_since_creation,
     expected_trigger_fired,
     expected_number_triggers,
     setup_mocks_vulnerabilities_gate,
 ):
     setup_mocks_vulnerabilities_gate(mock_vuln_report)
     vulns_gate = VulnerabilitiesGate()
     trigger = VulnerabilityMatchTrigger(
         parent_gate_cls=VulnerabilitiesGate,
         max_days_since_creation=max_days_since_creation,
         package_type="all",
     )
     exec_context = ExecutionContext(db_session=None, configuration={})
     vulns_gate.prepare_context(image_obj, exec_context)
     trigger.evaluate(image_obj, exec_context)
     assert trigger.did_fire == expected_trigger_fired
     assert len(trigger.fired) == expected_number_triggers
 def test_vulnerability_match_trigger_package_path_exclude(
     self,
     image_obj,
     mock_vuln_report,
     package_path_exclude,
     expected_trigger_fired,
     expected_number_triggers,
     setup_mocks_vulnerabilities_gate,
 ):
     setup_mocks_vulnerabilities_gate(mock_vuln_report)
     vulns_gate = VulnerabilitiesGate()
     trigger = VulnerabilityMatchTrigger(
         parent_gate_cls=VulnerabilitiesGate,
         package_path_exclude=package_path_exclude,
         package_type="non-os",
         vendor_only=False,
     )
     exec_context = ExecutionContext(db_session=None, configuration={})
     vulns_gate.prepare_context(image_obj, exec_context)
     trigger.evaluate(image_obj, exec_context)
     assert trigger.did_fire == expected_trigger_fired
     assert len(trigger.fired) == expected_number_triggers