Skip to content

Conversation

@NicholasEllul
Copy link
Contributor

@NicholasEllul NicholasEllul commented Jan 6, 2026

Summary

In #10 we added detection for npx usage in shell / JSON scripts. However, there are other cases where we are using npx in javascript files, as well as in GitHub workflows. This PR adds support for detection in those languages to ensure that potential supply chain issues are detected.

Note that we intentionally match all strings using npx in JS/TS so that even error messages prompting people to run npx scripts are flagged.


Note

Introduces detection of unsafe npx execution outside lockfiles across JS/TS code and CI YAML.

  • Adds npx-usage-js.yml (JavaScript/TypeScript) and npx-usage-yml.yml (YAML) rules with WARNING severity, security tag, rationale/help, and remediation message
  • Matches shell commands starting with npx in JS/TS string/template literals and in YAML run: steps (including scoped packages, flags, env vars, and command chains)
  • Test suites cover positive/negative cases (e.g., jest, eslint, prettier, create-react-app; allow yarn, npm run, yarn dlx)

Written by Cursor Bugbot for commit 075f928. This will update automatically on new commits. Configure here.

@NicholasEllul NicholasEllul requested a review from a team as a code owner January 6, 2026 20:35
Copy link
Member

Choose a reason for hiding this comment

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

Is there an easy way to ignore this warning for vendored code? We have some third-party minified code in mobile and extension that would contain the string npx (e.g. a fixture of a snap bundle used by e2e tests)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Gudahtt yes this would be configured in the security-code-scanner.yml in the paths-ignored section (Example)

// Using yarn dlx
function goodYarnDlx() {
// ok: npx-usage-js
const cmd = `yarn dlx create-react-app my-app`;
Copy link
Member

Choose a reason for hiding this comment

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

Maybe worth considering adding a warning about yarn dlx as well (it also doesn't update the lockfile, though at least it wouldn't bypass a pre-existing one).

But we can consider that in a separate PR

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants