@@ -138,6 +138,30 @@ def should_write_comment(disabled: bool, has_findings: bool, update_existing: bo
138138 return update_existing
139139 return True
140140
141+
142+ def _match_ignored_alerts_for_telemetry (
143+ ignored_alerts : list ,
144+ ignore_all : bool ,
145+ ignore_commands : list [tuple [str , str ]],
146+ ) -> list :
147+ """Return alerts attributable to one ignore comment."""
148+ if ignore_all :
149+ return list (ignored_alerts )
150+ return [
151+ alert
152+ for alert in ignored_alerts
153+ if any (
154+ Comments .is_ignore (
155+ alert .pkg_name ,
156+ alert .pkg_version ,
157+ name ,
158+ version ,
159+ alert .pkg_type ,
160+ )
161+ for name , version in ignore_commands
162+ )
163+ ]
164+
141165def _select_pull_request_provider (integration_type : str , scm_type : str ) -> str :
142166 """Prefer an active comment adapter when resolving pull request context."""
143167 return scm_type if scm_type in ("github" , "gitlab" ) else integration_type
@@ -837,16 +861,11 @@ def _is_unprocessed(c):
837861 sender_id = str (user .get ("id" , "" ))
838862
839863 # Match this comment's targets to the actual ignored alerts
840- matched_alerts = []
841- if c_ignore_all :
842- matched_alerts = ignored_alerts
843- else :
844- for alert in ignored_alerts :
845- full_name = f"{ alert .pkg_type } /{ alert .pkg_name } "
846- purl = (full_name , alert .pkg_version )
847- purl_star = (full_name , "*" )
848- if purl in c_ignore_commands or purl_star in c_ignore_commands :
849- matched_alerts .append (alert )
864+ matched_alerts = _match_ignored_alerts_for_telemetry (
865+ ignored_alerts ,
866+ c_ignore_all ,
867+ c_ignore_commands ,
868+ )
850869
851870 shared_fields = {
852871 "event_kind" : "user-action" ,
0 commit comments