Repository navigation
Scan reopened pull requests instead of passing them unscanned - #460
Draft
David Larsen (dc-larsen) wants to merge 7 commits into
Draft
David Larsen (dc-larsen) wants to merge 7 commits into
David Larsen (dc-larsen) wants to merge 7 commits into
Conversation
With --scm github, a pull_request run whose action was not opened or synchronize logged "Pull Request Action reopened is not a supported type" and exited 0 without scanning. The example workflow subscribes to reopened, and a required check takes the latest run on the head commit, so reopening a pull request could replace a failed Socket check with a pass on the same commit. reopened and ready_for_review now run the same comparison as opened and synchronize. Other actions and unhandled events are still skipped with exit 0, as the exit-code contract documents, but log a warning that no scan ran. pull_request_target gets its own message because it runs against the base branch, so it is not treated as pull_request. GitLab's unhandled pipeline sources log the same warning.
David Larsen (dc-larsen)
temporarily deployed
to
socket-firewall
November 20, 2026 20:11 — with
GitHub Actions
Inactive
…'t scan A missing pull_request action or GITHUB_EVENT_NAME (or CI_PIPELINE_SOURCE on GitLab) now gets its own warning instead of "action 'None' is not scanned", whose advice to drop the action from the workflow didn't apply. The skip warnings list issue_comment as handling ignore commands, not as a scanned event. Tests pin push, workflow_dispatch and issue_comment routing.
Move the Skipped events section below the scan-type paragraphs it had split. State the required-check risk without claiming which run GitHub picks. Explain that push on every branch also runs the job on a pull request's head commit as a full scan that exits 0, and give two ways to keep that run from satisfying a required check.
This was referenced Nov 20, 2026
David Larsen (dc-larsen)
deployed
to
socket-firewall
November 20, 2026 22:16 — with
GitHub Actions
Active
…l-requests # Conflicts: # CHANGELOG.md
This was referenced Nov 20, 2026
…l-requests # 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, apull_requestrun with actionreopenedexits0without scanning:The example workflow (
workflows/github-actions.yml) subscribes toopened, synchronize, reopened, and GitHub's defaultpull_requesttypes are the same three. GitHub doesn't document which run a required check uses when the same job runs more than once on a commit. So after a close and reopen, the passing run that never scanned can satisfy the required check on a commit an earlier run failed. Reported by a customer who blocks merges on--strict-blocking.Root Cause
Github.check_event_typeonly acceptedopenedandsynchronizeforpull_request. Every other action, and every event name it didn't recognize (pull_request_target,merge_group,schedule, ...), hitsys.exit(0). The action case logged at INFO and the unknown-event case at ERROR, but both exited0, so the job passed.Fix
reopenedandready_for_reviewnow return"diff"and run the same comparison asopened/synchronize(PULL_REQUEST_SCAN_ACTIONSinsocketsecurity/core/scm/github.py). Both can leave a head commit without a current result:reopenedbrings back a PR whose last run may have failed, andready_for_reviewis the first real run in workflows that skip drafts withif: !github.event.pull_request.draft. Matching is now case-insensitive on the action.closed,labeled,edited, ...) and unhandled events still exit0. The README exit-code table documents0as "skipped SCM event", and turning those into failures would turn every existingclosed/labeledrun red across current pipelines. Instead each skip now logs a WARNING that says no scan ran, the run exits0, and on a required check that pass does not reflect a scan. That keeps the behavior change limited to the two actions above.pull_request_targetis not treated aspull_request. On that eventGITHUB_SHA/GITHUB_REFpoint at the base branch and the default checkout is the base branch, so a "PR scan" would compare the base against itself and pass. Changed-file detection ingit_interface.pyalso keys onpull_request. It gets its own warning telling users to trigger onpull_request.merge_request_eventpipeline already diffs, so there's no reopened equivalent). Unhandled pipeline sources get the same explicit warning instead oflog.error+ exit0. Bitbucket and Azure have no SCM adapter, so they have no event filter to fix. They run through--scm api.EVENT_ACTIONand noactioninGITHUB_EVENT_PATH, the run says it could not determine thepull_requestaction, instead of "action 'None' is not scanned ... remove this action from the workflow". The same applies to an unsetGITHUB_EVENT_NAMEand, on GitLab, an unsetCI_PIPELINE_SOURCE. This only happens with--scm github/gitlaboutside their CI. Still exit0.issue_commentas handling ignore commands, not as a scanned event (it runs the comment flow, never a scan).docs/ci-cd.md: a "Skipped events" section (below the scan-type paragraphs) lists what scans and what is skipped, with notes onmerge_group(thepull_requestrun is the gate) and on fork pull requests (pull_request_targetis not a substitute;pull_requestfrom a fork gets no secrets and exits3).socket-securityjob onpush: branches: ['**']. A new commit on a PR branch triggers bothpushandpull_requeston the same head commit. Thepull_requestrun diffs and can fail; thepushrun is a full scan and always exits0(confirmed below). With one job name, a required check can resolve against the passingpushrun. A new "Push and pull request runs on the same commit" section indocs/ci-cd.md, and a comment on the example'spushtrigger, give two fixes: restrictpushto the default branch, or run the pull request scan in its own job and require that job's check.Not changed, for a maintainer call:
merge_group(merge queues) is still skipped with exit0. A required check that runs onmerge_grouppasses without scanning. Scanning it properly needs a base/head pair from the merge-group payload, which is more than this fix.editedcan retarget a PR's base branch, but it also fires on every title/description edit, so it stays skipped. The CLI's baseline is the repository head scan, so a retarget doesn't change the comparison anyway.push: branches: ['**']. All three example workflows (GitHub, GitLab, Bitbucket) deliberately scan every commit on every branch, and restrictingpushwould stop scanning branches without a pull request. Branch protection behavior for duplicate job names also couldn't be tested here. The docs and the workflow comment explain the overlap instead.Testing
tests/unit/test_github_event_filter.py(new, 25 cases): scanned actions return"diff";push/workflow_dispatch(with and without a PR number) andissue_commentrouting is pinned;closed/labeled/edited,pull_request_target/merge_group/scheduleand GitLabscheduleexit0with a "No scan ran" warning; a missing action,GITHUB_EVENT_NAMEorCI_PIPELINE_SOURCEgets the "could not determine" warning; a fullcli()run with an existing blocker under--strict-blockingexits1and posts the comment forreopened,ready_for_reviewandsynchronize, and exits0without scanning forclosed. 15 of the 25 fail onmain(the 10 that pass are behaviormainalready has).tests/core/test_cli_exit_contract.py: the skipped-event contract test now also coverspull_request_targetand asserts the warning (all 4 cases fail onmain).uv run pytest: 1027 passed (1001 onmain).ruff check socketsecurity tests,uv lock --locked --offline,git diff --check, anduv build+twine checkpass.workflows/github-actions.yml(--scm github --strict-blocking, samePR_NUMBERlogic; the action comes from a realGITHUB_EVENT_PATHpayload; real comments posted to a throwaway private PR). Two projects: npm (lodash 4.17.11 + handlebars 4.0.11 baseline, the PR adds vm2 3.9.11) and PyPI (pyyaml 5.3 + django 2.2, the PR adds requests 2.19.1), each with a default-branch baseline. Before = 2.13.0 from PyPI, after = this branch, run twice; both after runs were identical on both projects:pull_request/opened,synchronizepull_request/reopenedpull_request/ready_for_reviewpull_request/closed,edited,labeledpull_request, no action in payloadGITHUB_EVENT_NAMEemptypull_request_target/openedmerge_group,scheduleissue_comment (ignore commands)pushon the PR head commit (PR_NUMBER=0),workflow_dispatchissue_comment/createdissue_commentpath)Other 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.Public Changelog
With
--scm github, reopened pull requests and pull requests marked ready for review are scanned. They used to exit 0 without scanning, which could pass a required check on a commit an earlier run failed. Skipped GitHub events and GitLab pipeline sources now log a warning that no scan ran.