-
-
Notifications
You must be signed in to change notification settings - Fork 3
Detect usage of npx in yaml & JS code #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Using yarn dlx | ||
| function goodYarnDlx() { | ||
| // ok: npx-usage-js | ||
| const cmd = `yarn dlx create-react-app my-app`; |
There was a problem hiding this comment.
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
Gudahtt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Summary
In #10 we added detection for
npxusage in shell / JSON scripts. However, there are other cases where we are usingnpxin 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
npxin JS/TS so that even error messages prompting people to run npx scripts are flagged.Note
Introduces detection of unsafe
npxexecution outside lockfiles across JS/TS code and CI YAML.npx-usage-js.yml(JavaScript/TypeScript) andnpx-usage-yml.yml(YAML) rules with WARNING severity,securitytag, rationale/help, and remediation messagenpxin JS/TS string/template literals and in YAMLrun:steps (including scoped packages, flags, env vars, and command chains)jest,eslint,prettier,create-react-app; allowyarn,npm run,yarn dlx)Written by Cursor Bugbot for commit 075f928. This will update automatically on new commits. Configure here.