Skip to content

Commit 423672c

Browse files
committed
Correct how missing scopes behave, and how the baseline is chosen
A missing scope was described as mostly degrading with a warning. Only the two diff-scans scopes do that. The others fail the run: - full-scans:list is needed before any comparison. scan_type is always set, so the baseline is the newest matching scan listed from the default branch, not the repository's head-scan pointer, and a denied listing exits with the API-error code. The same listing explains when an empty baseline is created. - The scope table now says what happens without each scope. Calls the tables missed: POST python-cli-runs (and its logs and finalize calls) on every run, and POST coana-cli/artifacts under --reach, which accepts full-scans:create or fixes:list. GET report/supported needs no token, and the streaming fallback endpoint is deprecated in the API. Also covered: scope groups, tokens restricted to specific repositories, comment events, and the flags that force a comparison. The README exit-code table is left alone. The repository-failure section keeps the exit-2 details under "2.12.x and earlier", so it stays true when the exit-code contract changes. The setup-guide paragraphs describe tokens made from its nine-scope list instead of the guide's current contents, which are about to change.
1 parent 70d1e35 commit 423672c

5 files changed

Lines changed: 121 additions & 85 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
### Documentation
66

77
- New [API token permissions](docs/troubleshooting.md#api-token-permissions) guide:
8-
the scopes `socketcli` needs and the API calls each one covers.
8+
the scopes `socketcli` needs, what happens without each one, and the API calls
9+
behind them.
910
- Add `diff-scans:create` and `diff-scans:list` to CI tokens. Without them, scan
1011
comparisons fall back to a less resilient path with only a warning.
11-
- Documented why exit code `2` can mean the token can't create the repository.
12+
- Documented what happens when the token can't look up or create the repository,
13+
and how the baseline scan for a comparison is chosen.
1214
- Listed all four accepted token environment variables in priority order.
1315

1416
## 2.12.1

‎README.md‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ pip install socketsecurity
1818
export SOCKET_SECURITY_API_TOKEN="<token>"
1919
```
2020

21-
The token needs more than scan-creation access, and some paths fall back with only a
22-
warning when a permission is missing. See
21+
The token needs more than scan-creation access. Most missing scopes fail the run, and
22+
a token without the `diff-scans` scopes falls back with only a warning. See
2323
[`docs/troubleshooting.md#api-token-permissions`](https://github.com/SocketDev/socket-python-cli/blob/main/docs/troubleshooting.md#api-token-permissions).
2424

2525
### 3) Run a basic scan
@@ -225,7 +225,7 @@ Minimal pattern:
225225
|------|---------|
226226
| `0` | Clean scan — no blocking issues (or `--disable-blocking` set) |
227227
| `1` | Blocking security finding(s) detected |
228-
| `2` | Scan interrupted (SIGINT / Ctrl+C), or a repository lookup/creation failure |
228+
| `2` | Scan interrupted (SIGINT / Ctrl+C) |
229229
| `3` | Infrastructure or API error (timeout, network failure, unexpected error) |
230230

231231
`--exit-code-on-api-error <N>` remaps the infrastructure-error code (`3`) to any
@@ -250,10 +250,6 @@ precedence matters:
250250
set.** It changes the infra-error code (and the generic-error code); it never
251251
touches the security-finding code (`1`).
252252

253-
- **Neither flag covers exit `2`.** A repository lookup/creation failure (typically a
254-
token permission gap) exits `2` directly and is not remapped by either flag. See
255-
[`docs/troubleshooting.md#a-missing-repository-permission-can-exit-2`](https://github.com/SocketDev/socket-python-cli/blob/main/docs/troubleshooting.md#a-missing-repository-permission-can-exit-2).
256-
257253
So for the common "don't let Socket outages block my pipeline, but still fail on
258254
real findings" goal, use `--exit-code-on-api-error` **without** `--disable-blocking`:
259255

‎docs/ci-cd.md‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -623,11 +623,12 @@ Prebuilt examples in this repo:
623623
the console table, including native Buildkite job logs, and in GitHub/GitLab
624624
security comments when that SCM adapter is configured. Findings without a known
625625
patched release leave the console cell blank and omit the comment field.
626-
- A token missing the `diff-scans:*` scopes does not fail the build. It logs
626+
- A token missing the `diff-scans:create` and `diff-scans:list` scopes does not fail
627+
the build. It logs
627628
`Diff scan comparison failed with APIAccessDenied(Insufficient permissions)` and falls
628629
back to a less resilient comparison path. This affects every run that compares
629630
scans: PR/MR events, and runs without an SCM integration. An SCM-integrated branch
630-
push creates a full scan and never compares. The
631-
[CI/CD token setup guide](https://docs.socket.dev/docs/create-socket-api-key-for-cicd)
632-
leaves both scopes out; see
633-
[`troubleshooting.md#api-token-permissions`](troubleshooting.md#api-token-permissions).
631+
push creates a full scan and never compares. Tokens created from the nine-scope
632+
list in the CI/CD token setup guide lack both scopes; see
633+
[`troubleshooting.md#api-token-permissions`](troubleshooting.md#api-token-permissions)
634+
for the full scope list and what each missing scope does.

‎docs/cli-reference.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,10 @@ This repository's examples use `SOCKET_SECURITY_API_TOKEN`, and the CI/CD guides
243243
docs.socket.dev use `SOCKET_SECURITY_API_KEY`. Either works. If both are set,
244244
`SOCKET_SECURITY_API_KEY` wins.
245245

246-
> **Token permissions:** the CLI needs more than scan-creation access, and several
247-
> paths degrade with only a warning when a permission is missing rather than failing.
248-
> See [`troubleshooting.md#api-token-permissions`](troubleshooting.md#api-token-permissions)
249-
> for the full list of API calls a run makes and which flags add to it.
246+
> **Token permissions:** the CLI needs more than scan-creation access. Most missing
247+
> scopes fail the run, and a token without the `diff-scans` scopes falls back with only
248+
> a warning. See [`troubleshooting.md#api-token-permissions`](troubleshooting.md#api-token-permissions)
249+
> for the scopes to grant, the API calls a run makes, and which flags add to them.
250250

251251
#### Repository
252252
| Parameter | Required | Default | Description |

0 commit comments

Comments
 (0)