Repository navigation
fix(depscore): poll for packages not yet scanned (SURF-2362) - #265
Gerardo Sabetta (gerardosabetta) wants to merge 2 commits into
Conversation
PR SummaryMedium Risk Overview Polling is selective and conservative: unscored rows are identified by missing Unit tests cover mixed batches (one scored, one polled into a score) and poll responses that still lack a score. Reviewed by Cursor Bugbot for commit ed2f5e9. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit ed2f5e9. Configure here.
| typeof inputPurl === 'string' ? unscored.get(inputPurl) : undefined | ||
| if (index !== undefined && hasOverallScore(doc)) { | ||
| lines[index] = fallbackLines[i]!.trim() | ||
| } |
There was a problem hiding this comment.
Poll keeps one artifact per purl
Medium Severity
pollUnscored keeps only the last line index for each inputPurl. Both the lookup and the poll can return several artifacts for one purl. Each scored poll row overwrites that same index, leaving earlier rows unscored. deduplicateArtifacts can then keep an unscored sibling or the wrong build, so platform does not choose among the poll artifacts.
Reviewed by Cursor Bugbot for commit ed2f5e9. Configure here.


Summary
depscorestill does its usualPOST /v0/purllookup withoutpoll, exactly as before. Then, for the packages that came back without a score (notFound/pendingScan), it asks again withpoll=true&timeoutSec=20. A poll answer replaces the first answer only when it carries a score, so depscore never returns less than it did before this PR. Packages that already have a score make no extra request and don't wait.The two answers are matched by the response's
inputPurl, which the API returns with and withoutpoll.Why poll goes second. The first commit sent
poll=trueon the main lookup. Live testing showed thatpoll=trueanswerspendingScanwith no score for many already-scored packages while Socket re-analyzes them. In a 40-package batch of popular versions (express, react, lodash, axios, …), all 40 came backpendingScanwithpoll=true&timeoutSec=5, while the same request without poll returned 40 scores in 1.3s. Single versions did the same (express@4.17.1,express@4.18.2). Polling first, even with a fallback, would add ~20s to ordinary lookups (22.2s for that batch). Polling only the gaps keeps those at their old latency.Why 20s. The spec allows 1–1200. socket-mcp sets no tool timeout of its own; the bound is the shared
httpRequestdefault of 30s (@socketsecurity/libhttp-request). MCP SDK clients default to 60s per request. 20s keeps the poll under the 30s client timeout. A package left unscored now costs up to ~20s more; when the poll still has no score, the first answer is kept.Not in this PR:
purlErrorsandsummary. Both come back as_typecontrol frames, which depscore drops today, so they would need new parsing. Follow-up.Note: the poll URL is derived from the lookup URL, so a
SOCKET_API_BASE_URLoverride polls too.Verification
Live API on 2026-12-04, using gera's local socket-mcp OAuth session (scope
packages:list), never printed. "Through the handler" meanshandleDepscoreRequestfrom this branch, with a preload logging each request's path,pollflag, status and time (no headers). "Fresh" means an npm version published under 10 minutes earlier and never requested before.Before (main, single lookup without poll)
@zukhruf/chaos@0.8.353(fresh)notFound, no scoreanbaric-plugins@1.88.0(fresh)notFound, no scoreexpress@4.18.2Poll-first (first commit, dropped)
@zukhruf/chaos@0.8.353,anbaric-plugins@1.88.0(scan queued ~1 min earlier)@zukhruf/pool@0.8.353,@randock/nameshift-api-client@0.0.589(fresh)pendingScanlodash@4.17.21,react@18.2.0,express@4.21.2express@4.18.2(mid-re-analysis)pendingScan, score lost (twice)timeoutSec=5pendingScanexpress@4.17.1alone, raw,timeoutSec=5pendingScanAfter (this PR: lookup, then poll only the unscored), through the handler
lodash@4.17.21express@4.17.1(raw poll gavependingScanminutes earlier)express@4.18.2@reallexi/rmai-ui-windows-amd64@1.6.659(fresh)@holtjs/stage@0.12.0(fresh)@lintrs/sdk@0.3.0(fresh)Totals include the alert-types metadata call (~0.2–0.4s). Earlier in the session, two other fresh versions scored on poll-only calls in 7.5s and 13.2s.
CI
The first push failed
Test (windows-2025)intest/repo/integration/tool-audit-stdio.test.mts:199("expected 'Error connecting to Socket API' to contain 'synthetic_response_canary'"). This PR didn't cause it:SOCKET_API_BASE_URLto its own URL, so the first commit's change never reached its request.mainin run 46726240978 with a different assertion.What I ran
pnpm run fmt/pnpm run fmt:checkpnpm run lint(clean)pnpm run repo:check(tsc + build, clean)pnpm test: 76 files, 742 tests passedNew tests in
test/repo/unit/tool-depscore.test.mts:poll=true,timeoutSec=20, body with just that PURL), and its score is used.Linear: https://linear.app/socketdev/issue/SURF-2362/socket-mcp-depscore-should-wait-for-packages-socket-hasnt-scanned-yet
Slides
🤖 Generated with Claude Code