Repository navigation
Conversation
|
bugbot run |
72c2f29 to
69f8871
Compare
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>
now sends only a "diff" event type to create_new_diff and everything else, default-branch pushes included, to create_full_scan_with_report_url. The permission docs asserted the opposite -- that plain pushes also reach the diff-scans path -- which was true when they were written against 2.8.1 and is not true now. Replace the claim with a table of which runs compare, and keep the old behavior as a note, since the warning still shows up in logs from pre-2.9.0 runs with no pull request in sight. Re-verified the rest against 2.9.7: SDK call surface, the four sys.exit(2) sites, the temporary empty baseline, and the reachability scan ID are all unchanged.
The scope tables were inferred from scope names. The API reference publishes the scope each endpoint checks, so the tables now use those and the open question about unpublished scopes is resolved: GET organizations, GET report/supported and the ignore-comment telemetry post check none. Rechecking the call surface against 2.12.0 also changed the guidance: - repo:update is never exercised. POST full-scans checks only full-scans:create, including when it sets the repository head. - --sbom-file makes no API call; the CycloneDX export it was mapped to has no caller. License-metadata and full-scan metadata reads are likewise unreached outside tests. - diff-scans/from-ids checks full-scans:list as well as diff-scans:create. - --reach's manifest upload and tier-1 finalize check full-scans:create, as do the Coana CLI's reachability calls. - The exit-2 section now quotes the repo:create hint the CLI logs on a 403.
c7b9938 to
a1c1ae4
Compare
|
bugbot run |
PR SummaryLow Risk Overview The main addition is
Reviewed by Cursor Bugbot for commit 5fc3b67. Configure here. |
Only a diff-producing run that takes its baseline from the repository's head scan looks the repository up, and so only that run can create it or exit 2. A full-scan run uploads straight to full-scans, which creates a missing repository for an organization-wide token. A failed streaming fallback also only points at full-scans:list when it fails with Insufficient permissions.
A failed GET report/supported raises from the SDK and stops the run; the bundled pattern list only covers a non-error response with no body. An empty baseline is created when the repository has no head scan, not on every new branch, since a branch compares against the repository's head scan.
|
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 5fc3b67. Configure here.
Why
Before this PR, the repo said one thing about token permissions: a troubleshooting note on the diff-scans comparison. That note described the
APIAccessDeniedfallback as PR/MR-only, when it applies to every run that compares scans. It also told readers to grantfull-scans:list, which the fallback path already proves the token has. It never listed the baseline set of scopes, so a token couldn't be provisioned from the docs.The setup guide's scope list doesn't match this CLI
The CI/CD token setup guide lists nine scopes. It leaves out
diff-scans:createanddiff-scans:list. Every diff-producing run calls the diff-scans endpoints first, so a token set up exactly as the guide says getsAPIAccessDeniedthere and falls back to the streaming comparison. The only sign is a warning in the log. Following the documented setup is enough to cause this, so every CLI user who did that is affected.The converse also holds.
socketclinever uses four of the guide's scopes:repo:update,security-policy:read,triage:alerts-listandtriage:alerts-update. That includesrepo:update:POST full-scanschecks onlyfull-scans:create, even when it sets the repository head.This PR documents the gap for CLI users. SocketDev/docs#195 fixes the guide itself.
What changed
docs/troubleshooting.mdcarries the substance:APIAccessDeniedfallback, which runs compare, and how to tell which scope is missing.2when the token can't create the repository.Supporting changes:
README.md,docs/cli-reference.mdanddocs/ci-cd.md.$SOCKET_API_TOKEN. It now saysSOCKET_SECURITY_API_TOKEN.How the mapping was verified
Each endpoint-to-scope mapping is the scope the API itself checks. For public endpoints that's the
securityblock in the API reference. For the three hidden ones (upload-manifest-files,tier1-reachability-scan/finalize, and the telemetry post), it's each route'srequiredScopes. The draft of this PR inferred mappings from scope names, and checking them against the API changed three of them:repo:update: unused (see above).--sbom-filemakes no API call. The CycloneDX export it was mapped to has no caller, and the license-metadata and full-scan metadata reads are reached only from tests.GET organizations,GET report/supportedand the ignore-comment telemetry post check no scope at all, which resolves the draft's open question.The call surface was re-audited against 2.12.0 after rebasing: SDK calls, the
sys.exit(2)sites, the diff/full-scan flow decision, the empty-baseline path, and the log strings the docs quote.Notes for the reviewer
README.md's exit code table now notes that exit2also covers repository lookup and creation failures, and that neither exit-code flag remaps it. That behavior is a bug, tracked separately. This PR only documents it.check_versionis a required, unfiltered check that wants a version ahead of PyPI. If another PR claims 2.12.1 first, this one rides it.Related PRs
The same scope audit for the other two Python repos, and the docs-site fix. Each links to this PR's troubleshooting section, so merge this one first.
diff-scansscopes to the CI/CD token setup guide.Fixes: CE-461
Refs: CE-384, CE-460, CE-481