@@ -90,6 +90,33 @@ def test_consolidation_key_includes_ecosystem_and_ignores_advisory_case():
9090 assert npm .consolidation_key ()[3 ] == pypi .consolidation_key ()[3 ]
9191
9292
93+ def test_adding_a_cve_to_a_ghsa_record_keeps_the_same_finding_identity ():
94+ ghsa_only = _cve ("GHSA-aaaa-aaaa-aaaa" , error = True )
95+ both = _cve ("GHSA-aaaa-aaaa-aaaa" , error = True )
96+ both .props ["cveId" ] = "CVE-2026-0001"
97+
98+ assert ghsa_only .consolidation_key () == both .consolidation_key ()
99+ assert Messages .generate_uuid_from_alert_gitlab (ghsa_only ) == Messages .generate_uuid_from_alert_gitlab (both )
100+ assert len (Core .get_new_alerts ({ghsa_only .key : [ghsa_only , both ]}, {})) == 1
101+
102+
103+ @pytest .mark .parametrize ("ghsa_field" , ["ghsaId" , "ghsa_id" ])
104+ @pytest .mark .parametrize ("cve_field" , ["cveId" , "cve_id" , "cve" ])
105+ def test_disjoint_advisory_ids_are_not_assumed_to_be_aliases (ghsa_field , cve_field ):
106+ # Neither input establishes whether these identifiers name the same advisory.
107+ # Retaining both protects a blocker from being hidden behind another finding.
108+ ghsa_only = _cve ("GHSA-aaaa-aaaa-aaaa" , warn = True , props_field = ghsa_field )
109+ cve_only = _cve ("CVE-2026-0001" , error = True , props_field = cve_field )
110+
111+ alerts = Core .get_new_alerts ({ghsa_only .key : [ghsa_only ], cve_only .key : [cve_only ]}, {})
112+
113+ assert alerts == [ghsa_only , cve_only ]
114+ report = Messages .create_security_comment_gitlab (Diff (new_alerts = alerts ))
115+ assert len ({finding ["id" ] for finding in report ["vulnerabilities" ]}) == 2
116+ config = Mock (spec = CliConfig , disable_blocking = False , strict_blocking = False )
117+ assert OutputHandler (config , Mock ()).return_exit_code (Diff (new_alerts = alerts )) == 1
118+
119+
93120def test_non_advisory_alerts_still_collapse_per_package_and_type ():
94121 """Alerts with no advisory ID keep the per-package, per-type collapse."""
95122 first = Issue (pkg_type = "npm" , purl = "a@1.0.0" , type = "envVars" , props = {}, warn = True , key = "k1" )
0 commit comments