chore(deps): Drop octokit from scanner in favor of plain fetch - #2394
Open
dividedmind wants to merge 1 commit into
Open
chore(deps): Drop octokit from scanner in favor of plain fetch#2394dividedmind wants to merge 1 commit into
dividedmind wants to merge 1 commit into
Conversation
packages/scanner used the full `octokit` metapackage for exactly one REST call: createCommitStatus() in integration/github/commitStatus.ts. That pulled octokit 2.0.19, whose transitive @octokit/webhooks 10.9.1 carries GHSA-pwfr-8pq7-x9qv (high, unauthenticated DoS). The obvious fix -- bump to octokit 4 -- is not available to us. octokit 4 and 5 are "type": "module" with no require condition in their exports map, so they would break scanner's CommonJS build and the @yao-pkg/pkg native snapshot. octokit 3.x is still dual, but it is a dead end to park on. Instead, drop the dependency. The call is now a plain fetch POST to /repos/{owner}/{repo}/statuses/{sha}. Global fetch was already in use in this package (src/rules/lib/openapiProvider.ts). Behaviour is unchanged apart from the failure path, which now throws a plain Error carrying status, statusText and body rather than octokit's RequestError; no caller inspects the error type. This removes 25 packages from the tree. Also re-resolve @octokit/rest in packages/cli from 20.0.1 to 20.1.2. This is within the existing ^20.0.1 range, so no manifest change. 20.1.2 still publishes CJS -- it depends on the -cjs tagged plugin builds -- and pulls @octokit/core 5.2.2, which satisfies the patched floors for @octokit/request (>=8.4.1) and @octokit/request-error (>=5.1.1). Net: 5 octokit advisories down to 3, and the high is cleared. The remainder are moderate ReDoS advisories reaching the tree only through @semantic-release/github 8.1.0, which is the newest 8.x, so there is no in-range fix for them. Add test/integration/github/commitStatus.spec.ts covering the request shape, URL encoding, the non-2xx path, and validate-before-request. Note that nock 13 cannot intercept undici, so these stub globalThis fetch directly rather than using nock. Assisted-by: Claude:claude-opus-5[1m]
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The scanner now relies on global fetch despite supporting Node versions where fetch may not exist at runtime (per engines.node), risking a runtime crash for Node < 18 users.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR removes the octokit metapackage from packages/scanner by replacing the single createCommitStatus() usage with a direct HTTP POST, primarily to eliminate a high-severity transitive advisory while preserving the existing commit-status behavior.
Changes:
- Replaced Octokit-based commit status updates with a direct request to
POST /repos/{owner}/{repo}/statuses/{sha}. - Removed the
octokitdependency from@appland/scannerand updated the lockfile accordingly. - Added an integration test that validates request URL/encoding, request body/headers, config validation, and non-2xx behavior.
File summaries
| File | Description |
|---|---|
| yarn.lock | Removes octokit (scanner) and re-resolves @octokit/rest transitive set per updated dependency graph. |
| packages/scanner/package.json | Drops the octokit dependency from scanner. |
| packages/scanner/src/integration/github/commitStatus.ts | Implements commit status updates via direct HTTP request instead of Octokit. |
| packages/scanner/test/integration/github/commitStatus.spec.ts | Adds test coverage for the new request-based implementation and failure/validation paths. |
Review details
- Files reviewed: 3/4 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+29
to
43
| const response = await fetch(url, { | ||
| method: 'POST', | ||
| headers: { | ||
| accept: 'application/vnd.github+json', | ||
| authorization: `token ${token()!}`, | ||
| 'content-type': 'application/json', | ||
| 'user-agent': 'appland-scanner', | ||
| 'x-github-api-version': '2022-11-28', | ||
| }, | ||
| body: JSON.stringify({ | ||
| state, | ||
| context: 'appland/scanner', | ||
| description, | ||
| }), | ||
| }); |
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.
packages/scanner used the full
octokitmetapackage for exactly one REST call: createCommitStatus() in integration/github/commitStatus.ts. That pulled octokit 2.0.19, whose transitive @octokit/webhooks 10.9.1 carries GHSA-pwfr-8pq7-x9qv (high, unauthenticated DoS).The obvious fix -- bump to octokit 4 -- is not available to us. octokit 4 and 5 are "type": "module" with no require condition in their exports map, so they would break scanner's CommonJS build and the @yao-pkg/pkg native snapshot. octokit 3.x is still dual, but it is a dead end to park on.
Instead, drop the dependency. The call is now a plain fetch POST to /repos/{owner}/{repo}/statuses/{sha}. Global fetch was already in use in this package (src/rules/lib/openapiProvider.ts). Behaviour is unchanged apart from the failure path, which now throws a plain Error carrying status, statusText and body rather than octokit's RequestError; no caller inspects the error type. This removes 25 packages from the tree.
Also re-resolve @octokit/rest in packages/cli from 20.0.1 to 20.1.2. This is within the existing ^20.0.1 range, so no manifest change. 20.1.2 still publishes CJS -- it depends on the -cjs tagged plugin builds -- and pulls @octokit/core 5.2.2, which satisfies the patched floors for @octokit/request (>=8.4.1) and @octokit/request-error (>=5.1.1).
Net: 5 octokit advisories down to 3, and the high is cleared. The remainder are moderate ReDoS advisories reaching the tree only through @semantic-release/github 8.1.0, which is the newest 8.x, so there is no in-range fix for them.
Add test/integration/github/commitStatus.spec.ts covering the request shape, URL encoding, the non-2xx path, and validate-before-request. Note that nock 13 cannot intercept undici, so these stub globalThis fetch directly rather than using nock.
Assisted-by: Claude:claude-opus-5[1m]