fix(doctor): skip npm audit and explain when no package-lock.json (#36893)#36901
Closed
alaamohanad169-ship-it wants to merge 1 commit into
Closed
fix(doctor): skip npm audit and explain when no package-lock.json (#36893)#36901alaamohanad169-ship-it wants to merge 1 commit into
alaamohanad169-ship-it wants to merge 1 commit into
Conversation
ff700f2 to
fb6c0b2
Compare
On Windows native installs (and any Hermes-managed install where agent-browser is vendored without a package-lock.json), `hermes doctor` was reporting phantom 'X npm vulnerabilities' and telling users to run `npm audit fix` inside the Hermes-managed directory in %LOCALAPPDATA%. That fix path is un-actionable: - `npm audit fix` requires a lockfile to safely update - The path is Hermes-managed; users should not hand-edit it - Vulnerabilities in vendored deps are addressed by the Hermes release pipeline, not by individual user action Now doctor checks for package-lock.json before running the audit. When it's missing, the audit is skipped and three info lines explain: 1. why the audit was skipped (no package-lock.json) 2. that vulnerabilities are managed by the release pipeline 3. that users should not run `npm audit fix` inside that path Regression tests cover both the no-lockfile (skip) and lockfile-present (run normally) paths. Closes NousResearch#36893.
fb6c0b2 to
97cd86e
Compare
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.
Summary
Fixes
hermes doctorreporting un-actionable npm-vulnerability warnings on Windows native (and any Hermes-managed) installs that shipagent-browservendored undernode_modules/without apackage-lock.json.When the lockfile is missing the doctor now:
npm auditcall (it cannot be safely remediated anyway)npm audit fixinside the Hermes-managed pathWhen the lockfile IS present the existing audit logic is unchanged.
Issue
Fixes #36893
Test plan
tests/hermes_cli/test_doctor.py::test_run_doctor_skips_npm_audit_when_no_lockfile— new regression test: no lockfile → audit not called, clear info messages emittedtests/hermes_cli/test_doctor.py::test_run_doctor_runs_npm_audit_when_lockfile_present— new regression test: lockfile present → audit runs and surfaces vulnerabilities as beforetest_doctor.pytests still passtest_windows_native_support.py+test_windows_compat.pytests still passtest_security_advisories.pytests still passHow it was implemented
Followed TDD:
hermes_cli/doctor.pythat checks forpackage-lock.jsonbefore invokingnpm audit; both new tests passif not ... : ... continueblock) and added a comment explaining the Windows-native motivation; no other refactoring neededCaveats
package-lock.json(the common case for development checkouts).