Skip to content

Commit b41017d

Browse files
committed
Merge branch 'main' of github.com:SocketDev/socket-python-cli into lelia/codeql-scm-url-detection
2 parents 55ce6e3 + ef5a7fb commit b41017d

32 files changed

Lines changed: 2240 additions & 366 deletions

‎CHANGELOG.md‎

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,63 @@
11
# Changelog
22

3-
## 2.12.2
3+
## 2.13.1
44

55
### Changed
66

77
- Manifest file links in PR comments and reports pick the source host only from
88
`--scm`. The fallback that guessed GitHub, GitLab, or Bitbucket from the Socket
99
diff URL never produced a link and has been removed.
1010

11+
## 2.13.0
12+
13+
### Upgrade notes
14+
15+
Exit codes change in this release. Check any CI step that matches on a specific
16+
code; see [Exit codes](README.md#exit-codes).
17+
18+
- Invalid flags exit `2` instead of `1`. `--disable-blocking` doesn't apply to
19+
them.
20+
- Ctrl+C exits `130` instead of `2`.
21+
- Missing tokens and other setup failures now honor `--disable-blocking` and
22+
`--exit-code-on-api-error`.
23+
- `--strict-blocking` now fails on existing blocking alerts.
24+
- Config-file booleans, integers and choices are validated before scan setup.
25+
26+
### Added
27+
28+
- Under `--strict-blocking`, PR/MR comments list existing alerts in their own
29+
table.
30+
31+
### Changed
32+
33+
- Incomplete scan comparisons or existing-alert results fail the run with the
34+
infrastructure-error code.
35+
- GitLab security report IDs include the ecosystem, full package coordinate and
36+
advisory ID, so existing findings get new IDs once.
37+
38+
### Fixed
39+
40+
- `--strict-blocking`, the GitLab security report and FOSSA output include
41+
alerts on unchanged packages.
42+
- `--strict-blocking` no longer lists findings on added packages twice.
43+
- Every CVE on a package is reported, not one per severity.
44+
- GitLab reports keep findings from different ecosystems and namespaces separate.
45+
- PR/MR comments group existing license violations and retain warnings about
46+
omitted findings after individual ignores.
47+
- Invalid file lists and unreadable config files exit with the usage-error code.
48+
- Exit-code flags retain their startup values if the config file changes during a run.
49+
- A token without `repo:list` is reported as a missing scope, not a missing
50+
repository. Only a missing repository triggers a create request.
51+
52+
## 2.12.2
53+
54+
### Changed: bump pinned Coana CLI to 15.15.2
55+
56+
- Bumped the pinned reachability engine (the Coana CLI) from `15.15.1` to
57+
`15.15.2`. See the
58+
[reachability analysis changelog](https://docs.socket.dev/docs/reachability-analysis-changelog)
59+
for engine changes.
60+
1161
## 2.12.1
1262

1363
### Changed: bump pinned Coana CLI to 15.15.1

‎README.md‎

Lines changed: 34 additions & 11 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` | Successful report, skipped SCM event, or `--disable-blocking` set; findings gate only evaluated diffs |
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,12 +240,12 @@ 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` forces exit `0` for findings, infrastructure errors and
244+
interrupts.** It takes precedence over `--exit-code-on-api-error` and
245+
`--strict-blocking`. Usage errors still exit `2`.
245246
- **`--exit-code-on-api-error` only applies when `--disable-blocking` is *not*
246-
set.** It changes the infra-error code (and the generic-error code); it never
247-
touches the security-finding code (`1`).
247+
set.** It changes the infrastructure-error code, including unexpected runtime
248+
failures. Findings (`1`), usage errors (`2`) and Ctrl+C (`130`) keep their codes.
248249

249250
So for the common "don't let Socket outages block my pipeline, but still fail on
250251
real findings" goal, use `--exit-code-on-api-error` **without** `--disable-blocking`:
@@ -263,6 +264,28 @@ scan exit `0` on *both* findings and outages — the `soft_fail: 100` rule would
263264
never match, and real findings would stop blocking. That's usually not what you
264265
want.
265266

267+
### Upgrading to 2.13.0
268+
269+
Update pipeline rules and wrapper scripts that match specific exit codes:
270+
271+
| Outcome | Before 2.13.0 | From 2.13.0 |
272+
|---------|---------------|-------------|
273+
| Invalid flags or configuration | CLI validation: `1`; argparse: `2` | `2` for both; never suppressed by `--disable-blocking` |
274+
| Ctrl+C | `2` | `130`, or `0` with `--disable-blocking` |
275+
| Missing token or other setup failure | Fixed `2` or `3`, depending on the failure | Infrastructure-error code (`3` by default); both exit-code flags now apply |
276+
277+
Blocking findings still exit `1`. With `--strict-blocking`, existing blocking
278+
alerts can now fail jobs that previously passed. GitLab report findings also get
279+
new IDs once; see the [release notes](CHANGELOG.md#2130).
280+
281+
Configuration is validated before credentials or network setup. Use native
282+
JSON/TOML booleans such as `false`, a positive integer `timeout`, and an array of
283+
file paths for `files`. Invalid or unreadable configuration exits `2` even when
284+
credentials are missing or blocking is disabled.
285+
286+
For a compact comparison of failure-handling policies, see
287+
[Exit codes in CI](docs/ci-cd.md#exit-codes-in-ci).
288+
266289
## Common gotchas
267290

268291
See [`docs/troubleshooting.md`](https://github.com/SocketDev/socket-python-cli/blob/main/docs/troubleshooting.md#common-gotchas).

‎docs/ci-cd.md‎

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,44 @@ steps:
5252
- "results.sarif"
5353
```
5454
55+
## Exit codes in CI
56+
57+
Choose which outcomes may leave your scan step green. The values below are the
58+
CLI's exit status; CI cancellation and external timeouts can have their own status.
59+
60+
| Outcome | Default | `--exit-code-on-api-error 100` | `--disable-blocking` |
61+
|---------|---------|--------------------------------|----------------------|
62+
| No blocking findings | `0` | `0` | `0` |
63+
| Blocking findings | `1` | `1` | `0` |
64+
| Invalid flags or configuration | `2` | `2` | `2` |
65+
| Setup, API or runtime failure | `3` | `100` | `0` |
66+
| Ctrl+C handled by the CLI | `130` | `130` | `0` |
67+
68+
Use a custom infrastructure code with your CI provider's exit-code allowlist; the
69+
[Buildkite example](../README.md#how-these-options-interact) shows this pattern.
70+
For providers without that feature, remap infrastructure errors to `0`:
71+
72+
```bash
73+
# Keep findings blocking; allow setup/API failures to pass.
74+
socketcli --config .socketcli.toml --exit-code-on-api-error 0
75+
76+
# Report-only mode: findings, infrastructure failures and Ctrl+C exit 0.
77+
# Invalid flags/configuration still exit 2.
78+
socketcli --config .socketcli.toml --disable-blocking
79+
```
80+
81+
Combining the flags gives `--disable-blocking` precedence. Avoid blanket shell
82+
`|| true` or job-wide `continue-on-error` when only API failures should be allowed:
83+
they also hide findings and usage errors. Even with exit `0`, a setup/API failure
84+
does not mean a clean scan; check the logs for a completed report.
85+
86+
Findings block only when a [diff comparison runs](#scan-type-by-pipeline).
87+
SCM event filters can also skip unsupported events with exit `0`; confirm a report
88+
was created when validating a new workflow.
89+
`--strict-blocking` also checks existing blocking alerts; an incomplete comparison
90+
or incomplete existing-alert data is an infrastructure failure. See the
91+
[2.13.0 migration table](../README.md#upgrading-to-2130) when updating existing CI rules.
92+
5593
## Config file usage in CI
5694

5795
Use `--config .socketcli.toml` or `--config .socketcli.json` to keep pipeline commands small.
@@ -465,7 +503,7 @@ With `--scm github` or `--scm gitlab`, the detected event decides the scan type:
465503

466504
| Event | Scan | Blocks the build |
467505
|:------|:-----|:-----------------|
468-
| Pull request / merge request | Diff scan against the repository's baseline | Yes, on newly introduced alerts |
506+
| Pull request / merge request | Diff scan against the repository's baseline | Yes, on new blocking alerts; also existing blockers with `--strict-blocking` |
469507
| Any other pipeline, including default-branch pushes | Full scan | No |
470508

471509
A full scan has no baseline, so it cannot tell a newly introduced alert from one

0 commit comments

Comments
 (0)