Skip to content

Commit 5227298

Browse files
committed
Release 2.13.0 with upgrade notes for the exit-code changes
Bumps the minor version because exit codes change: invalid flags exit 2 instead of 1, Ctrl+C exits 130 instead of 2, more failures honor --disable-blocking and --exit-code-on-api-error, and --strict-blocking now fails on existing blocking alerts. The CHANGELOG lists each change a CI step matching on exit codes needs to know about, and the README exit-code table and the --disable-blocking and --strict-blocking docs describe the new behavior.
1 parent 3274b99 commit 5227298

7 files changed

Lines changed: 84 additions & 20 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,74 @@
11
# Changelog
22

3-
## 2.12.2
3+
## 2.13.0
4+
5+
### Upgrade notes
6+
7+
This release changes exit codes. Check any CI step that matches on a specific
8+
code.
9+
10+
- **Invalid flags exit `2`, not `1`.** `1` now always means blocking security
11+
findings. `2` is the code argparse already used for its own usage errors.
12+
`--disable-blocking` does not apply to usage errors.
13+
- **Ctrl+C exits `130`, not `2`.** `130` is the POSIX code for a process stopped
14+
by SIGINT.
15+
- **`--disable-blocking` and `--exit-code-on-api-error` apply to more failures.**
16+
A missing API token, `GITLAB_TOKEN` or `GH_API_TOKEN`, missing reachability
17+
dependencies, a plan without reachability, and a repository that can't be
18+
created used to exit with a hard-coded `2` or `3`. They now exit `3`, or your
19+
`--exit-code-on-api-error` value, and `--disable-blocking` turns them into `0`.
20+
- **`--strict-blocking` now fails on existing blocking alerts.** It didn't
21+
before, because the scan comparison doesn't include alerts on unchanged
22+
packages. Runs that passed with existing blocking alerts will now fail, which
23+
is what the flag documents. To roll it out gradually, see
24+
[Strict Blocking Mode](docs/cli-reference.md#strict-blocking-mode).
25+
- **An incomplete scan comparison fails the run** with the infrastructure-error
26+
code instead of reporting a result that may be missing alerts.
27+
28+
### Changed: exit codes are decided in one place
29+
30+
- Failures that are not security findings raise one error type, and the
31+
top-level handler applies `--disable-blocking` and `--exit-code-on-api-error`
32+
to all of them. See [Exit codes](README.md#exit-codes).
33+
34+
### Fixed: `--strict-blocking` passed with existing blocking alerts
35+
36+
- The CLI reads alerts on unchanged packages from the new full scan, because
37+
the scan comparison returns those packages without their alerts. This costs
38+
one more API request per run, and only runs when an output needs existing
39+
alerts: `--strict-blocking`, `--enable-gitlab-security` or
40+
`--legal-format fossa`. The GitLab security report and FOSSA output, which
41+
list every current finding, were missing the same alerts.
42+
- If that request fails, the run fails with the infrastructure-error code
43+
rather than passing without the existing alerts.
444

545
### Fixed: duplicate findings with `--strict-blocking`
646

7-
- Alerts on added packages are no longer also reported as existing alerts. Under
8-
`--strict-blocking`, each finding on an added package was listed twice in JSON,
9-
SARIF, Slack and GitLab output, and counted again in the summary's
10-
"EXISTING blocking issues" line and the GitLab commit status. The exit code
11-
was not affected.
47+
- Alerts on added packages are no longer also reported as existing alerts. Each
48+
finding on an added package was listed twice in JSON, SARIF, Slack and GitLab
49+
output, and counted again in the summary's "EXISTING blocking issues" line and
50+
the GitLab commit status.
51+
52+
### Fixed: a package's second CVE was dropped
53+
54+
- Alerts were collapsed on package and alert type, and every CVE of one
55+
severity shares an alert type, so only one advisory per package and severity
56+
was reported. A blocking advisory could be dropped behind a warning on the
57+
same package, letting the run pass. Each GHSA or CVE is now reported, and the
58+
PR comment shows its ID next to the title.
59+
60+
### Added: existing alerts in PR/MR comments
61+
62+
- Under `--strict-blocking`, the security comment lists existing alerts in
63+
their own table after the new ones, blocking first. `@SocketSecurity ignore`
64+
applies to them too. The table stops before the comment reaches GitHub's size
65+
limit and links to the full report for the rest.
66+
67+
### Fixed: a token without `repo:list` was reported as a missing repository
68+
69+
- A repository lookup that fails with 401 or 403 now says the token may be
70+
missing the `repo:list` scope. Before, the CLI treated it as a missing
71+
repository, tried to create it, and failed with a `repo:create` error.
1272

1373
## 2.12.1
1474

‎README.md‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,13 @@ Minimal pattern:
217217
218218
## Exit codes
219219
220-
| Code | Meaning |
221-
|------|---------|
222-
| `0` | Clean scan — no blocking issues (or `--disable-blocking` set) |
223-
| `1` | Blocking security finding(s) detected |
224-
| `2` | Scan interrupted (SIGINT / Ctrl+C) |
225-
| `3` | Infrastructure or API error (timeout, network failure, unexpected error) |
220+
| Code | Meaning |
221+
|-------|---------|
222+
| `0` | Clean scan — no blocking issues (or `--disable-blocking` set) |
223+
| `1` | Blocking security finding(s) detected |
224+
| `2` | Invalid flags or configuration (usage error), including argparse's own errors |
225+
| `3` | Infrastructure or API error: missing API or SCM token, permission or plan problem, timeout, network failure, incomplete scan comparison, unexpected error |
226+
| `130` | Scan interrupted (SIGINT / Ctrl+C) |
226227

227228
`--exit-code-on-api-error <N>` remaps the infrastructure-error code (`3`) to any
228229
value — e.g. a Buildkite
@@ -239,9 +240,11 @@ error, so the supervisor's exit status (commonly 124 or 137) takes precedence.
239240
The two flags that affect exit codes can cancel each other out, so the order of
240241
precedence matters:
241242

242-
- **`--disable-blocking` wins over everything.** It forces exit `0` for *all*
243-
outcomes — security findings *and* infrastructure errors. If you set it,
244-
`--exit-code-on-api-error` has no effect (you'll always get `0`).
243+
- **`--disable-blocking` wins for every run that gets past flag parsing.** It
244+
forces exit `0` for security findings, infrastructure errors and interrupts.
245+
If you set it, `--exit-code-on-api-error` has no effect (you'll always get `0`).
246+
It does not apply to usage errors (`2`): a run with invalid flags never scanned
247+
anything, so it always fails.
245248
- **`--exit-code-on-api-error` only applies when `--disable-blocking` is *not*
246249
set.** It changes the infra-error code (and the generic-error code); it never
247250
touches the security-finding code (`1`).

‎docs/cli-reference.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ The CLI runs a pinned version of the Coana CLI, the analysis engine; it does **n
437437
| Parameter | Required | Default | Description |
438438
|:-------------------------|:---------|:--------|:----------------------------------------------------------------------|
439439
| `--ignore-commit-files` | False | False | Compare regardless of which files changed, scanning every manifest |
440-
| `--disable-blocking` | False | False | Non-blocking CI mode: the CLI always exits **0**, even when blocking alerts are present (including with `--strict-blocking`). Also exits 0 on uncaught runtime errors and Socket API failures, so the job is treated as successful while findings and errors are still logged. Takes precedence over `--strict-blocking`. |
440+
| `--disable-blocking` | False | False | Non-blocking CI mode: the CLI exits **0** even when blocking alerts are present (including with `--strict-blocking`). Also exits 0 on infrastructure errors (missing API or SCM token, Socket API failures, uncaught runtime errors) and interrupts, so the job is treated as successful while findings and errors are still logged. Invalid flags still exit **2**. Takes precedence over `--strict-blocking`. |
441441
| `--disable-ignore` | False | False | Disable support for `@SocketSecurity ignore` commands in PR comments. When set, alerts cannot be suppressed via comments and ignore instructions are hidden from comment output. See [Who can ignore an alert](#who-can-ignore-an-alert). |
442442
| `--ignore-authorization` | False | enforce | Who may suppress alerts with `@SocketSecurity ignore`. `enforce` requires write access and honors the command with a warning when the provider cannot report it; `strict` rejects it in that case; `off` honors any commenter. See [Who can ignore an alert](#who-can-ignore-an-alert). |
443443
| `--strict-blocking` | False | False | Fail on ANY security policy violations (blocking severity), not just new ones. Only works in diff mode. See [Strict Blocking Mode](#strict-blocking-mode) for details. |
@@ -643,6 +643,8 @@ Security issues detected by Socket Security:
643643
644644
- **Diff Mode Only**: The flag only works in diff mode (with SCM integration). In API mode, a warning is logged.
645645
- **Error-Level Only**: Only fails on `error=True` alerts (blocking severity), not warnings.
646+
- **Existing alerts come from the full scan**: The scan comparison doesn't carry alerts on unchanged packages, so the CLI reads them from the new full scan, at the cost of one more API request per run. If that request fails, the run fails with the infrastructure-error code rather than passing without them.
647+
- **PR/MR comments**: Existing alerts are listed in their own table after the new ones, blocking first. `@SocketSecurity ignore` applies to them too. Very large sets are cut off before the comment reaches GitHub's size limit, with a link to the full report.
646648
- **Priority**: `--disable-blocking` takes precedence - if both flags are set, the build will always pass.
647649
- **First Scan**: On the very first scan of a repository, there are no "existing" violations, so behavior is identical to standard mode.
648650

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
66

77
[project]
88
name = "socketsecurity"
9-
version = "2.12.2"
9+
version = "2.13.0"
1010
requires-python = ">= 3.11"
1111
license = {"file" = "LICENSE"}
1212
dependencies = [

‎socketsecurity/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
__author__ = 'socket.dev'
2-
__version__ = '2.12.2'
2+
__version__ = '2.13.0'
33
USER_AGENT_NAME = 'socket-python-cli'
44
USER_AGENT = f'{USER_AGENT_NAME}/{__version__}'

‎socketsecurity/core/messages.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,6 @@ def security_alert_row(alert: Issue, diff: Diff, config, show_ignore: bool) -> s
942942
pkg_label = Messages.html_text(f"{alert.pkg_name}@{alert.pkg_version}")
943943
pkg_marker = Messages.comment_marker_text(f"{alert.pkg_name}@{alert.pkg_version}")
944944
alert_title = Messages.alert_title_with_advisory(alert)
945-
# Generate a table row for each alert
946945
ignore_html = (
947946
f"<p><em>Mark as acceptable risk:</em> To ignore this alert only in this pull request, reply with:<br/>"
948947
f"<code>@SocketSecurity ignore {Messages.html_text(alert.pkg_type)}/{pkg_label}</code><br/>"

‎uv.lock‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)