From 6872a4115439ba5ecec8148f8baccef23d2aa3ed Mon Sep 17 00:00:00 2001 From: David Larsen Date: Fri, 20 Nov 2026 14:59:05 -0500 Subject: [PATCH 1/4] List every existing advisory under --strict-blocking Existing alerts for --strict-blocking are read from the new full scan through socketdev's fullscans.stream(). socketdev 3.6.2 merged alerts that share a type and severity on a package, so only the first CVE of each severity reached the CLI. The Existing alerts table and the EXISTING blocking issues count undercounted (3 instead of 8 in the repro), and when the first CVE of a group was resolved or triaged to monitor or ignore, the Block CVEs behind it were dropped and the run passed. socketdev 3.6.3 keys merged alerts on the advisory ID and keeps the most severe action. Pin it. The CLI's own consolidation already keeps the advisory ID (Issue.consolidation_key) and filters on error/warn before it dedupes, so no CLI logic changes. The new tests run the real FullScans.stream() over a canned response, so they fail if the pinned SDK collapses advisories again. Bumps the version to 2.13.1. uv.lock needs `uv lock` once socketdev 3.6.3 is published. --- CHANGELOG.md | 12 +++++ pyproject.toml | 4 +- socketsecurity/__init__.py | 2 +- tests/core/test_existing_alerts.py | 81 ++++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff28e72..8630717 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## 2.13.1 + +### Fixed + +- `--strict-blocking` lists and counts every advisory on an unchanged package. + Existing alerts are read through the SDK, which kept one alert per alert type + and severity, so a package with six Critical CVEs showed one, and the + "EXISTING blocking issues" count was too low. Requires `socketdev` 3.6.3. +- A Block-action CVE on an unchanged package now fails the run even when + another CVE of the same severity on that package is triaged to monitor or + ignore. Before, the triaged CVE could stand in for both and the run passed. + ## 2.13.0 ### Upgrade notes diff --git a/pyproject.toml b/pyproject.toml index 0924672..c21b4ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" [project] name = "socketsecurity" -version = "2.13.0" +version = "2.13.1" requires-python = ">= 3.11" license = {"file" = "LICENSE"} dependencies = [ @@ -16,7 +16,7 @@ dependencies = [ "gitpython==3.2.1", "packaging==26.3", "python-dotenv==1.2.4", - "socketdev==3.6.2", + "socketdev==3.6.3", "beautifulsoup4==4.15.0", "markdown==3.11.3", "brotli==1.2.1; platform_python_implementation == 'CPython'", diff --git a/socketsecurity/__init__.py b/socketsecurity/__init__.py index 08835ec..a3c8f69 100644 --- a/socketsecurity/__init__.py +++ b/socketsecurity/__init__.py @@ -1,4 +1,4 @@ __author__ = 'socket.dev' -__version__ = '2.13.0' +__version__ = '2.13.1' USER_AGENT_NAME = 'socket-python-cli' USER_AGENT = f'{USER_AGENT_NAME}/{__version__}' diff --git a/tests/core/test_existing_alerts.py b/tests/core/test_existing_alerts.py index 139577d..b404e14 100644 --- a/tests/core/test_existing_alerts.py +++ b/tests/core/test_existing_alerts.py @@ -16,6 +16,7 @@ from socketdev.exceptions import APIFailure from socketdev.fullscans import ( FullScanParams, + FullScans, FullScanStreamResponse, StreamDiffResponse, ) @@ -245,6 +246,86 @@ def test_matched_package_without_alerts_is_a_clean_result(core): core.sdk.fullscans.stream.assert_called_once() +# --- Existing advisories read through the SDK's full-scan stream ------------------------ +# +# The tests above stub ``fullscans.stream``. These run the real SDK method over a canned +# HTTP response, so they also cover the SDK's merging of duplicate alerts: socketdev +# 3.6.2 kept one alert per type and severity, which dropped every other CVE of that +# severity on a package, along with any Block action it carried. + +HANDLEBARS_CRITICAL_ADVISORIES = [ + ("GHSA-8r5x-fm3f-whwj", ""), + ("GHSA-p8wg-vrv2-v86f", ""), + ("GHSA-2w6w-674q-4c4q", ""), + ("GHSA-w457-6q6x-cgp9", "CVE-2019-19919"), + ("GHSA-765h-qjxv-5f44", "CVE-2021-23383"), + ("GHSA-f2jv-r9rf-7988", "CVE-2021-23369"), +] + + +def _cve_alert(ghsa_id, cve_id, action="error"): + return { + "key": f"key-{ghsa_id}", + "type": "criticalCVE", + "severity": "critical", + "category": "vulnerability", + "props": {"ghsaId": ghsa_id, "cveId": cve_id, "title": f"Advisory {ghsa_id}"}, + "action": action, + } + + +def _stream_through_sdk(core, *artifacts): + """Serve ``artifacts`` as the full-scan NDJSON body and parse it with the real SDK.""" + response = Mock(status_code=200, text="\n".join(json.dumps(a) for a in artifacts)) + api = Mock(request_timeout=30) + api.do_request.return_value = response + core.sdk.fullscans.stream.side_effect = FullScans(api).stream + + +def _existing_only_diff(core, *scan_artifacts): + core.cli_config = CliConfig.from_args(["--api-token", "test", "--strict-blocking"]) + core.sdk.fullscans.stream_diff.return_value = _diff_response(unchanged=[ + _diff_artifact("unchanged", artifact["id"], artifact["name"]) for artifact in scan_artifacts + ]) + _stream_through_sdk(core, *scan_artifacts) + params = FullScanParams(repo="repo", branch="feature") + params.include_license_details = True + return core.create_new_diff(["/repo"], params, explicit_files=["/repo/package.json"]) + + +def test_every_same_severity_advisory_on_an_unchanged_package_is_kept(core, caplog): + alerts = [_cve_alert(ghsa, cve) for ghsa, cve in HANDLEBARS_CRITICAL_ADVISORIES] + + with caplog.at_level("INFO"): + diff = _existing_only_diff(core, _scan_artifact("u1", "handlebars", alerts)) + + assert sorted(a.advisory_id() for a in diff.unchanged_alerts) == sorted( + ghsa.upper() for ghsa, _ in HANDLEBARS_CRITICAL_ADVISORIES + ) + assert all(a.error for a in diff.unchanged_alerts) + assert "Loaded 6 alerts for 1 of 1 unchanged packages" in caplog.text + assert not _handler(strict_blocking=True).report_pass(diff) + + comment = Messages.security_comment_template(diff, _config()) + assert "Existing alerts (6)" in comment + for ghsa, _ in HANDLEBARS_CRITICAL_ADVISORIES: + assert ghsa.upper() in comment + + +@pytest.mark.parametrize("triaged_action", ["ignore", "monitor"]) +def test_a_triaged_advisory_does_not_hide_a_blocking_one_on_the_same_package(core, triaged_action): + """The triaged advisory comes first in the stream; the Block one must still fail the run.""" + alerts = [ + _cve_alert("GHSA-w457-6q6x-cgp9", "CVE-2019-19919", action=triaged_action), + _cve_alert("GHSA-765h-qjxv-5f44", "CVE-2021-23383", action="error"), + ] + + diff = _existing_only_diff(core, _scan_artifact("u1", "handlebars", alerts)) + + assert [(a.advisory_id(), a.error) for a in diff.unchanged_alerts] == [("GHSA-765H-QJXV-5F44", True)] + assert not _handler(strict_blocking=True).report_pass(diff) + + # --- PR comment ------------------------------------------------------------------------ From 4a4354f75980f88b772d17aa3028a8f753985ee2 Mon Sep 17 00:00:00 2001 From: David Larsen Date: Fri, 20 Nov 2026 17:06:22 -0500 Subject: [PATCH 2/4] Note the report output change in the changelog Full-scan mode with --enable-json, --enable-sarif or --enable-gitlab-security reads alerts through the same SDK stream, so those reports now list every advisory on a package too. Diff mode's existing alerts in the GitLab and FOSSA-format output change the same way. --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8630717..da62167 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,12 @@ - A Block-action CVE on an unchanged package now fails the run even when another CVE of the same severity on that package is triaged to monitor or ignore. Before, the triaged CVE could stand in for both and the run passed. +- In full-scan mode, the `--enable-json`, `--enable-sarif` and + `--enable-gitlab-security` reports now list every advisory on a package. + Before, they listed one per alert type and severity, so expect more alerts, + and more with a Block action, in these reports. In diff mode the same + applies to existing alerts in the `--enable-gitlab-security` and + `--legal-format fossa` output. ## 2.13.0 From 803024ac11aac34166aea05d3c0a00cbccde1b12 Mon Sep 17 00:00:00 2001 From: David Larsen Date: Fri, 20 Nov 2026 17:21:42 -0500 Subject: [PATCH 3/4] Pin socketdev 3.6.4 socketdev 3.6.3 was released without the advisory dedupe fix, which now ships as 3.6.4. uv.lock still needs `uv lock` once 3.6.4 is published. --- CHANGELOG.md | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da62167..9cf5978 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ - `--strict-blocking` lists and counts every advisory on an unchanged package. Existing alerts are read through the SDK, which kept one alert per alert type and severity, so a package with six Critical CVEs showed one, and the - "EXISTING blocking issues" count was too low. Requires `socketdev` 3.6.3. + "EXISTING blocking issues" count was too low. Requires `socketdev` 3.6.4. - A Block-action CVE on an unchanged package now fails the run even when another CVE of the same severity on that package is triaged to monitor or ignore. Before, the triaged CVE could stand in for both and the run passed. diff --git a/pyproject.toml b/pyproject.toml index c21b4ec..e8d335b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ dependencies = [ "gitpython==3.2.1", "packaging==26.3", "python-dotenv==1.2.4", - "socketdev==3.6.3", + "socketdev==3.6.4", "beautifulsoup4==4.15.0", "markdown==3.11.3", "brotli==1.2.1; platform_python_implementation == 'CPython'", From 79177a5bfa3eac2b810da42d1f3cb29574f797ed Mon Sep 17 00:00:00 2001 From: David Larsen Date: Fri, 20 Nov 2026 18:08:17 -0500 Subject: [PATCH 4/4] Bump version to 2.13.3 2.13.2 was released from main, so this change needs the next patch version. --- pyproject.toml | 2 +- socketsecurity/__init__.py | 2 +- uv.lock | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4846aca..b7578c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" [project] name = "socketsecurity" -version = "2.13.2" +version = "2.13.3" requires-python = ">= 3.11" license = {"file" = "LICENSE"} dependencies = [ diff --git a/socketsecurity/__init__.py b/socketsecurity/__init__.py index 7ba49e1..0871ade 100644 --- a/socketsecurity/__init__.py +++ b/socketsecurity/__init__.py @@ -1,4 +1,4 @@ __author__ = 'socket.dev' -__version__ = '2.13.2' +__version__ = '2.13.3' USER_AGENT_NAME = 'socket-python-cli' USER_AGENT = f'{USER_AGENT_NAME}/{__version__}' diff --git a/uv.lock b/uv.lock index 196ae3c..b3681e4 100644 --- a/uv.lock +++ b/uv.lock @@ -1334,7 +1334,7 @@ wheels = [ [[package]] name = "socketsecurity" -version = "2.13.2" +version = "2.13.3" source = { editable = "." } dependencies = [ { name = "beautifulsoup4" },