Skip to content

test(manifest): run cdxgen help checks offline - #1807

Merged
John-David Dalton (jdalton) merged 2 commits into
v1.xfrom
test/cdxgen-help-forwarding-offline
Dec 2, 2026
Merged

John-David Dalton (jdalton) merged 2 commits into
v1.xfrom
test/cdxgen-help-forwarding-offline

Conversation

@jdalton

Copy link
Copy Markdown
Contributor

The cdxgen help tests can spend their timeout starting a package-manager download just to check argument forwarding. Run the CLI in a temporary npm project with the repository’s installed cdxgen and an empty, offline npm cache. Both command names must now print cdxgen’s help and exit successfully.

Node 22 timeout on SocketDev/socket-cli#1800

@cursor

cursor Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Test-only refactor with no production code paths; behavior change is stricter help assertions in CI.

Overview
Cdxgen help tests no longer rely on loose heuristics or Windows CI fallbacks. A shared spawnCdxgenHelp helper runs the CLI in a throwaway npm project (symlinked node_modules, npm_config_offline, isolated cache) so help checks use the repo’s installed cdxgen without triggering downloads/timeouts.

socket cdxgen and socket manifest cdxgen help specs now call that helper and assert exit code 0, real CycloneDX/cdxgen help text, and the Socket banner command name. hasCdxgenHelpContent / hasSocketBanner were removed; manifest help coverage for -h and --help is consolidated into parameterized cmdit cases.

Reviewed by Cursor Bugbot for commit b152fa4. Configure here.

@jdalton
John-David Dalton (jdalton) merged commit b25c16a into v1.x Dec 2, 2026
11 checks passed
@jdalton
John-David Dalton (jdalton) deleted the test/cdxgen-help-forwarding-offline branch December 2, 2026 16:09

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ 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 b152fa4. Configure here.

Comment thread test/utils.mts
},
})
} finally {
await rm(cwd, { recursive: true, force: true })

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temp cleanup can wipe node_modules

High Severity

spawnCdxgenHelp junctions the repository node_modules into a temp directory and then rms that directory recursively in finally. On Windows a junction is a reparse point; fs.rm({ recursive: true }) has treated EPERM as “not empty” and descended into the target, which would delete the real install rather than only the temp junction. Cleanup errors are also uncaught, so a locked handle after npx can fail an otherwise passing test.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b152fa4. Configure here.

Comment thread test/utils.mts
SOCKET_CLI_CONFIG: '{}',
npm_config_offline: 'true',
npm_config_cache: path.join(cwd, '.npm-cache'),
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Offline npx may skip local cdxgen

Medium Severity

The temp project’s package.json is only {"private":true}, while npx is invoked as @cyclonedx/cdxgen@<pinned version> with npm_config_offline=true and npm_config_cache pointed at a fresh empty directory. If npm exec does not treat the symlinked install as satisfying that spec (common when the package is not a declared dependency, or when a versioned spec still loads a packument), the fetch fails immediately with ENOTCACHED instead of printing help, so the new code === 0 / CycloneDX Generator assertions fail.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b152fa4. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants