Repository navigation
Stop failing issue_comment runs that have no ignore command - #464
Draft
David Larsen (dc-larsen) wants to merge 5 commits into
Draft
David Larsen (dc-larsen) wants to merge 5 commits into
David Larsen (dc-larsen) wants to merge 5 commits into
Conversation
An issue_comment run on a pull request that already has a Socket security comment crashed with KeyError: 'ignore' and exited 3 unless the pull request also had an honored @SocketSecurity ignore command. check_for_socket_comments only adds the "ignore" key when such a command exists, but remove_comment_alerts called process_security_comment whenever the security comment existed, and get_ignore_options indexed comments["ignore"] directly. Any ordinary comment, or an ignore command from someone without write access, failed the job. remove_comment_alerts (GitHub and GitLab) now returns early and leaves the security comment untouched when there are no ignore commands, and get_ignore_options treats a missing key as no commands. Ignore, ignore-all and --disable-ignore behave as before.
David Larsen (dc-larsen)
deployed
to
socket-firewall
November 20, 2026 22:15 — with
GitHub Actions
Active
…error # Conflicts: # CHANGELOG.md
This was referenced Nov 20, 2026
…error # Conflicts: # CHANGELOG.md
2.13.2 was released from main, so this change needs the next patch version.
David Larsen (dc-larsen)
deployed
to
socket-firewall
November 20, 2026 23:11 — with
GitHub Actions
Active
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
--scm github, anissue_commentrun on a pull request that already has a Socket security comment exits3for any ordinary comment:Only a comment that starts with
@SocketSecurity ignorefrom someone with write access avoids it. The example workflow (workflows/github-actions.yml) subscribes toissue_comment, so every "LGTM" or review reply on a pull request with Socket alerts produces a failed Socket job. Found while verifying 2.13.0 against real pull request scans. The unguarded lookup dates back to the first releases; 2.13.0 reports it as exit3.Root Cause
Comments.check_for_socket_commentsonly adds an"ignore"key when the pull request has at least one honored ignore command.Github.remove_comment_alerts(and the GitLab equivalent) calledComments.process_security_commentwhenever a security comment existed, andComments.get_ignore_optionsreadcomments["ignore"]directly. With no ignore command, that lookup raisedKeyError, which the CLI reports as an unexpected error (exit3). An ignore command rejected by the write-access gate (#302) leaves the same shape, so it crashed too.Fix
remove_comment_alerts(GitHub and GitLab) returns early when there are no ignore commands: it logsNo @SocketSecurity ignore commands on this pull request; security comment left unchangedand makes no API call. Rewriting the security comment with no commands would only re-normalize it, so leaving it alone is the safer no-op.get_ignore_optionstreats a missing"ignore"key as no commands, so any other caller gets(False, [])instead of a crash.0for these runs follows the README contract: no findings were evaluated and nothing failed.@SocketSecurity ignore <pkg>,ignore-all, malformed commands and--disable-ignoretake the same path as before. GitLab never reports anissue_commentpipeline source, so its comment flow is reachable only by configuration; it gets the same guard for consistency.Not changed (separate issues, noticed while testing):
Github.comment_reaction_existscomparescontentto":thumbsup:", but the API returns"+1", so the check never matches. GitHub de-duplicates a user's identical reaction, so the visible effect is one extra API call per ignore comment per run.get_comments_for_prreads only the first page of comments (30), so an ignore command past the 30th comment is not seen.Tests
tests/unit/test_comment_event_flow.py(new, 20 cases). Fullcli()runs for anissue_commentevent: ordinary comments (plain, empty, mentions@SocketSecuritywithoutignore) exit0with no comment update, reaction or telemetry; no security comment exits0;ignore npm/lodash@...removes only that row, adds the reaction and sends one telemetry event;ignore-allreplaces the table with the no-alerts body;--disable-ignorenever reads comments; an ignore command from a commenter without write access is dropped without crashing; four malformed commands keep every row. Unit cases coverget_ignore_options({})andremove_comment_alertson both adapters with and without ignore commands. 8 of the 20 fail onmainwithKeyError: 'ignore'.uv run pytest -q tests/unit/ tests/core/: 1021 passed (1001 onmain).uv run ruff check,uv lock --locked --offline,git diff --checkanduv buildpass.--scm github --strict-blocking. Before = 2.13.0 from PyPI; after = this branch's wheel. For the ignore cases, both versions ran from the same starting security comment (38 alert rows), restored between runs:LGTM, thanksKeyError: 'ignore'updated_atunchanged), run twiceLGTM, thanks+--disable-ignore@SocketSecurity ignore vm2(no version)@SocketSecurity ignore(no package)@SocketSecurity ignore npm/vm2@3.9.11@SocketSecurity ignore-allOther open 2.13.x fixes
2.13.1 and 2.13.2 were released from
mainon 2026-11-20, so this branch mergesmainatv2.13.2and bumps to2.13.3inpyproject.toml,socketsecurity/__init__.pyanduv.lock, with its CHANGELOG entries under a new## 2.13.3heading. #459, #460, #461, #462, #463, #464 and #465 all make the same bump, so the version files merge cleanly between them, and once one merges the rest ride main's unreleased2.13.3(Version Check accepts a version equal to main's while it is above the latest PyPI release). Merging a second one conflicts only inCHANGELOG.md: keep one## 2.13.3heading and combine the bullets under its subsections (Upgrade notes, Changed, Fixed, Documentation, in that order). There are no code conflicts between them. Ifmainreleases 2.13.3 before this merges, bump to the next patch again. This branch and #460 both editscm/github.pyandscm/gitlab.py; those merge cleanly.Public Changelog
With
--scm github, an ordinary comment on a pull request that has a Socket security comment no longer fails the Socket job with exit 3. The comment run now exits 0 and leaves the security comment unchanged.