Repository navigation
Check existing alerts under --strict-blocking when no manifest changed - #462
Draft
David Larsen (dc-larsen) wants to merge 6 commits into
Draft
David Larsen (dc-larsen) wants to merge 6 commits into
David Larsen (dc-larsen) wants to merge 6 commits into
Conversation
Without --ignore-commit-files, the CLI reads the changed files to decide whether to compare. When none is a supported manifest it sets force_api_mode, creates a full scan of the target path, and turns blocking off because a full scan has no baseline. That fallback exists so a change that cannot alter dependencies doesn't post a comment or block on alerts it didn't introduce. Under --strict-blocking it also skipped the check the flag exists for: a code-only pull request passed with a warning that --strict-blocking needs diff mode, even when the repository had existing blocking alerts. With --strict-blocking, a change that touches no manifest now runs the comparison over every manifest in the target path, the same way --ignore-commit-files does. Existing alerts are loaded from the new full scan and fail the run, and PR/MR comments list them. Failures reading them keep the infrastructure-error code. Runs without --strict-blocking keep the full-scan fallback, and SCM branch pipelines still create a full scan.
David Larsen (dc-larsen)
temporarily deployed
to
socket-firewall
November 20, 2026 20:29 — with
GitHub Actions
Inactive
--strict-blocking when no manifest changed
The no-manifest message was logged when the mode was chosen, before the SCM event type was known. Skipped pull request events (closed, for example) printed that every manifest would be compared and then exited without a scan, and SCM branch pipelines printed it before creating a full scan. Log it after the event check, only when the run goes on to compare. Document the wider reach of the change: without --scm, default-branch pushes and non-git target paths now compare under --strict-blocking and can fail on existing blocking alerts. Note that --reach pull request scans need a default-branch scan made with --reach, and reword the API Mode line. Add tests for GitLab merge request and branch pipelines, an API-mode default-branch push, and the log message. The branch pipeline tests now return a blocking alert from the full scan, so they fail if blocking were left on.
David Larsen (dc-larsen)
deployed
to
socket-firewall
November 20, 2026 22:08 — with
GitHub Actions
Active
This was referenced Nov 20, 2026
…o-manifest-change # Conflicts: # CHANGELOG.md
This was referenced Nov 20, 2026
…o-manifest-change
…o-manifest-change # 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
--strict-blockingand without--ignore-commit-files, a pull request whose changes touch no supported manifest passes even when the repository has existing blocking alerts. The CLI falls back to a full scan, logs "--strict-blocking is only supported in diff mode", and exits0. Most pull requests change code only, so on a default setup--strict-blockingdid nothing for most of them. #453 listed this as a known gap. Found while verifying 2.13.0 against a customer report.Root Cause
Without
--ignore-commit-files,main_codereads the changed files to decide whether to compare. When none is a supported manifest it setsforce_api_mode, creates a full scan of the target path, and switches blocking off because a full scan has no baseline (#101 added this; before it, such commits skipped the scan entirely). For a normal run that is reasonable: a change that can't alter dependencies has no new alerts to block on or comment about.--strict-blockingexists to fail on alerts the change didn't introduce, so the fallback skipped exactly what the flag is for. The same fallback also skipped the PR/MR comment flow under--scm github/gitlab.Fix
Under
--strict-blocking, a change with no supported manifest now setsforce_diff_mode, the same path--ignore-commit-filestakes. The run compares every manifest in the target path against the baseline, loads existing alerts from the new full scan throughCore.add_existing_alerts_from_full_scan, fails on existing Block alerts, and lists them in the console and the PR/MR comment exactly as on any other comparison. If existing alerts can't be read, the existing infrastructure-error handling applies (3,--exit-code-on-api-error,0under--disable-blocking).The "compares every manifest" log line is printed after the SCM event check, and only when the run goes on to compare. Skipped pull request events (
closed,labeled, ...) and SCM branch pipelines don't print it.I chose this over reading existing alerts from the fallback full scan. That full scan has no baseline, so "existing" would mean "every alert in the scan", the comment flow would still be skipped, and it would need a second blocking path. Reusing the comparison keeps one code path and produces the same output a user already gets with
--ignore-commit-files.Unchanged:
--strict-blockingkeep the full-scan fallback.Upgrade note: without
--scmthere is no event type, so this applies to every--strict-blockingrun with no manifest change, not only pull requests. Default-branch pushes in Bitbucket, Azure Pipelines, Jenkins and other pipelines that don't set--scm, and target paths that aren't git repositories, now compare against the head scan and fail on existing Block alerts where they used to pass.--ignore-commit-filesalready behaved this way. The CHANGELOG has an "Upgrade notes" entry and the CLI reference says so.--reach: the baseline is the head scan of the same type, so a--reachPR scan needs a default-branch scan made with--reach. Otherwise the baseline is empty and every alert is labeled new. The exit code is the same under--strict-blocking, but the comment says the change introduced them. This predates this PR (--ignore-commit-filesalready hit it), but code-only strict PRs now reach it on default flags, so the CLI reference notes it.Cost: for
--strict-blockingruns on code-only changes, the CLI now does what it already did with--ignore-commit-filesor a manifest change. It resolves the baseline, waits for the diff-scan comparison, and streams the new full scan once for existing alerts. Manifest upload is the same as before, since the fallback also scanned the whole target path. Measured end to end, those runs went from about 1 s to 13-14 s (about 5.5 s comparison wait plus about 6 s existing-alert stream), matching the--ignore-commit-filesruns on the same commits.Docs: the
--strict-blockinghelp text, the CLI reference (flag table, Strict Blocking notes, File Selection Behavior, Scanning Modes) andci-cd.mdno longer say the flag is diff-only on no-manifest changes.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.Testing
tests/core/test_strict_blocking_no_manifest_change.py(26 tests) drivessocketcli.cli()with a README-only change across--enable-diff, default API mode,--fileswithout a manifest, and a non-git target: existing Block alert exits1, no Block alert exits0,--disable-blockingexits0, unreadable existing alerts use the infrastructure code (default, remapped, nonblocking), no fallback warning under the flag, manifest changes still compare, non-strict runs keep the full-scan fallback, a code-only GitHub pull request posts the comment with the existing alerts, a GitLab merge request does the same, GitHub and GitLab push pipelines still create a full scan and don't block even when that scan carries a Block alert, an API-mode default-branch push compares (withmake_default_branch) and fails, and the comparison log line appears only when a comparison runs (not on a skippedclosedevent or a branch pipeline). 16 of the 26 fail onmain.pull_requestclosed/labeledrun with--strict-blockingon a code-only change: before this fix the log said every manifest would be compared and then "No scan ran; exiting 0"; now it prints only the "No scan ran" warning. Exit0both ways, and the combined suite passes (1036).uv run pytest -q -o addopts=: 1027 passed (1001 onmain).ruff check .,ruff format --checkon the new test file,uv lock --locked --offline,hatch buildandtwine checkpass.socketdev3.6.2), on four projects: a small npm project with a multi-CVE Block package, a second npm project, a PyPIrequirements.txtproject and a shallow clone of a public React app (1,199 packages).--enable-diff --strict-blockingon a README-only commit: 2.13.0 exits0with the fallback warning on all four. This branch exits1on all four (run twice each), with the same existing-alert counts and the same rendered comment (scan IDs aside) as--ignore-commit-fileson the same commit. Manifest-changing commits, non-strict runs,--ignore-commit-filesruns, and--disable-blockingbehaved the same before and after.--strict-blocking(default API mode and--enable-diff) exit1with 3 / 1 / 9 existing Block alerts, the same counts as--ignore-commit-files --strict-blocking; non-strict exit0;--strict-blocking --disable-blockingexit0. Stock 2.13.0 exits0with the fallback warning. API-mode default-branch push with--default-branch --strict-blockingon a README-only commit: 2.13.0 exit0, this branch exit1(twice).Public Changelog
--strict-blockingnow fails on existing blocking alerts when a change touches no dependency manifest. Previously such changes got a full scan with blocking turned off and passed. Without--scm, this includes default-branch pushes and non-git target paths, which can now fail on existing blocking alerts after upgrading.