Improve documentation for requisite API token permissions - #353
Draft
lelia wants to merge 2 commits into
Draft
Conversation
The only scope guidance in the repo covered the diff-scans comparison path, described it as PR/MR-only, and listed `full-scans:list` alongside the two `diff-scans:*` scopes. The comparison also runs on plain pushes, and the streaming fallback is itself a full-scans read, so a reader hitting the `APIAccessDenied` warning was pointed at the wrong permission and told the condition did not apply to them. Replace it with the full picture: what every run calls, what diff-producing runs add, and what each flag adds. Scope names are only published for the diff-scans path, so the rest are described by endpoint rather than guessed at. Also document three outcomes that look like failures and are not: the temporary empty baseline on a first scan, the reachability scan ID being a `tier1ReachabilityScanId` rather than a full scan ID, and a repository permission gap exiting 2 — a code the exit table documents as a keyboard interrupt, and which bypasses `--disable-blocking` and `--exit-code-on-api-error`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The permission tables described endpoints but deferred on scope names, since nothing in this repo or the SDK publishes them. The public CI/CD token setup guide does: nine scopes, which the docs now name and map to the calls they cover. That guide omits `diff-scans:create` and `diff-scans:list`. Every diff-producing run tries the diff-scans endpoints first, so a token provisioned exactly as documented always fails that call and falls back to the legacy streaming comparison, with a warning as the only signal. Anyone following the documented setup hits this. The converse is also worth stating: `socketcli` makes no triage or security-policy calls, so three of the nine scopes the guide lists are not exercised by this CLI. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
Author
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 72c2f29. Configure here.
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.
Why
The repo documented exactly one thing about token permissions: a troubleshooting note about the diff-scans comparison path. It had three problems.
It described the
APIAccessDeniedfallback as a PR/MR-only condition. The comparison also runs on plain pushes —socketcli.py:846callscreate_new_diffin the non-PR/MR branch — so a pipeline that only scans pushes hits it and reads the note as not applying.It listed
full-scans:listalongside the twodiff-scans:*scopes. The streaming fallback isGET orgs/{org}/full-scans/diff, itself a full-scans read, so if the fallback returns results the token already has that permission. Readers were pointed at a permission they demonstrably had.And it never documented the baseline set, conceding as much with "in addition to whatever the scan itself needs". A token could not be provisioned from the docs.
The setup guide omits two scopes this CLI requires
The published CI/CD token setup guide tells readers to select nine scopes:
repo:list,repo:create,repo:update,security-policy:read,triage:alerts-list,triage:alerts-update,full-scans:list,full-scans:create,packages:listIt does not list
diff-scans:createordiff-scans:list.Every diff-producing run tries the diff-scans endpoints first, so a token provisioned exactly as that guide describes fails that call with
APIAccessDeniedand silently falls back to the legacy streaming comparison. The only signal is a warning in the log. This is not a misconfiguration a user can be blamed for — following the documented setup produces it, and it affects every CLI user who provisioned that way.The converse also holds.
socketclimakes no triage or security-policy API calls at all, verified against the full SDK call surface, sosecurity-policy:read,triage:alerts-listandtriage:alerts-updateare not exercised by this CLI. They are on the guide's list for other Socket tooling.The guide itself is separate tooling and out of scope here; this PR documents the gap so CLI users can work around it.
What changed
docs/troubleshooting.mdcarries the substance: three tables covering what every run calls, what diff-producing runs add, and what each flag adds; the nine documented scope names plus the two missing ones, mapped to the calls they cover; and sections on theAPIAccessDeniedfallback, temporary baseline scans, reachability vs. full-scan IDs, and the exit-2 caveat.Supporting changes: permissions pointers in
README.md,docs/cli-reference.md, anddocs/ci-cd.md; all four accepted token environment variables documented in priority order; and a$SOCKET_API_TOKENreference in the GitLab requirements section corrected toSOCKET_SECURITY_API_TOKEN.TODO
Two calls every run makes —
GET organizationsandGET report/supported— map to no scope on the guide's list. They appear to be available to any valid org token, but that is inference, and the docs currently say so. Also unmapped:license-metadata,export/cdx, the reachability manifest upload, andfinalize_tier1.The scope-to-call mapping in the tables is likewise inferred from the names, since the guide publishes no per-endpoint mapping. It is labelled as inferred in the docs. Someone who owns the scope definitions should confirm both before this leaves draft.
Notes for the reviewer
Every claim was verified against 2.8.1, not the 2.7.2 tree the audit started on.
README.md's exit code table now notes that exit2also covers repository lookup/creation failure, and that neither exit-code flag remaps it. That behavior is a bug, tracked separately — this PR only documents it.The changelog entry is under
## Unreleasedrather than a version number. A branch section header matching a version that ships first gets silently deleted on rebase with no conflict marker, and coana bump PRs land unpredictably. Whoever cuts the next patch needs to rename that header, or it ends up orphaned under a newer section.No version bump:
version-check.ymlonly triggers onsocketsecurity/**,pyproject.toml,uv.lock, and its own path, so a.md-only PR never runs the gate.Fixes: CE-461
Refs: CE-384, CE-460
Note
Low Risk
Markdown-only documentation changes with no runtime or dependency changes.
Overview
Documentation-only PR that expands how to provision Socket API tokens for
socketcliand fixes several misleading permission/exit-code notes.The main change is a rewritten
docs/troubleshooting.md#api-token-permissionssection: tables for API calls on every run, on diff-producing runs, and per flag; scope-to-call mapping; callout that the published CI/CD setup guide omitsdiff-scans:createanddiff-scans:list(so tokens following that guide silently fall back to legacy comparison); and note that triage/security-policy scopes are unused by this CLI.Scan-comparison guidance is corrected so
APIAccessDeniedfallback applies to any diff-producing run (including default-branch pushes), not only PR/MR, and clarifies that missing grants are the twodiff-scans:*scopes—notfull-scans:listwhen the streaming fallback already works.New troubleshooting sections document expected “failure-like” behavior: temporary empty baselines on first scan, reachability IDs vs full-scan IDs, and exit
2for repository lookup/creation permission gaps (including that--disable-blockingand--exit-code-on-api-errordo not remap it).README.mdexit-code table and precedence notes are updated to match.docs/cli-reference.mddocuments all four accepted token env vars in priority order and fixes the GitLab requirements reference from$SOCKET_API_TOKENtoSOCKET_SECURITY_API_TOKEN. Pointers to the permissions guide are added inREADME.md,docs/cli-reference.md, anddocs/ci-cd.md.CHANGELOG.mdrecords the work under Unreleased.Reviewed by Cursor Bugbot for commit 72c2f29. Configure here.