Nobody reads 3,000-line package-lock.json diffs. lockfile-lens reads them for you.
It turns a lockfile change into a short review and points at the few packages that actually deserve a human look: new install scripts, releases from people who never maintained the package, brand-new packages, typosquats, license changes, tarballs from unexpected places.
- Zero dependencies. It's a security tool, so it has nothing of its own to compromise.
- Free, no account, no server. Runs in your CI or terminal.
- Private by default. Packages from private registries are never looked up on the public one.
Needs attention: 🔴 1 high · 🟠 6 medium · 🟡 14 low
package-lock.json— 63 added, 30 updated, 11 removed · 75 → 126 packages (+51)
Package Why it needs a look 🔴 esbuild@0.28.2New package runs a script automatically on npm install(preinstall/install/postinstall). This is the #1 way malicious packages execute code.🟠 @img/sharp-* (26 packages)Published 3 days ago. Many malicious releases are caught within days; consider waiting. 🟠 accepts@2.0.0First release by wesleytodd, a maintainer added after the version you had. Usually a normal handover; worth a glance at the changelog.🟡 @img/sharp-libvips-*@1.3.5 (10 packages)License is LGPL-3.0-or-later, which comes with conditions for your project. ▸ ➕ Added (63) ▸ 🔄 Updated (30) ▸ ➖ Removed (11) (collapsible tables)
The comment is updated in place on every push, so it never spams the PR.
Create .github/workflows/lockfile-lens.yml:
name: lockfile-lens
on:
pull_request:
paths: ['**/package-lock.json', '**/npm-shrinkwrap.json']
permissions:
contents: read
pull-requests: write # to post the comment
jobs:
lens:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: xelerb-debug/lockfile-lens@v0
# with:
# fail-on: high # make the check red on high-risk changes
# online: true # registry checks (release age, publisher, deprecation)
# paths: '' # default: every changed lockfile, monorepos includedThat's it. Works with Dependabot and Renovate PRs too — which is exactly where nobody reads the lockfile.
| Input | Default | Meaning |
|---|---|---|
fail-on |
none |
Fail the check on findings at least high, medium or low |
online |
true |
Look packages up on registry.npmjs.org |
comment |
true |
Post / update a PR comment (the report always goes to the job summary) |
paths |
(auto) | Space-separated lockfiles to check |
max-rows |
50 |
Rows per table |
Pull requests from forks get a read-only token, so they can't be commented on; the report is still in the job summary.
npx lockfile-lens # uncommitted lockfile changes vs HEAD
npx lockfile-lens --base main # what your branch changes compared to main
npx lockfile-lens old.json new.json # any two lockfilespackage-lock.json 63 added, 30 updated, 11 removed · 75 → 126 packages (+51)
HIGH esbuild@0.28.2
New package runs a script automatically on npm install ...
MEDIUM @img/sharp-* (26 packages)
Published 3 days ago. Many malicious releases are caught within days; consider waiting.
...
Summary: 1 high, 31 medium, 14 low
| Option | |
|---|---|
-b, --base <ref> |
git ref to compare against (default HEAD; uses the merge-base, like a PR) |
-p, --path <file> |
lockfile to check, repeatable |
-f, --format |
text · markdown · json |
--offline |
skip registry lookups |
--fail-on <level> |
exit code 1 on findings ≥ high / medium / low |
--verbose |
list everything, ungrouped |
Exit codes: 0 ok · 1 findings at or above --fail-on · 2 error.
Use it as a pre-push hook, or right after npm update to see what you just pulled in.
| Check | Why | |
|---|---|---|
| 🔴 | Install script added | preinstall/postinstall run code on every developer machine and CI runner. Most npm malware lives here. |
| 🔴 | Publisher is not a maintainer | A release by someone who never published or maintained the package: classic account-takeover signal. |
| 🔴 | Brand-new package (< 30 days) | No track record; typical for malware and typosquats. |
| 🔴 | Same version, different tarball | Published npm versions are immutable. A changed hash means another registry or a tampered lockfile. |
| 🔴 | Plain http / new download host | The tarball can be swapped, or comes from somewhere your project never used. |
| 🔴 | Not on the registry | Lockfile points at a package or version that doesn't exist (often: removed for malware). |
| 🔴/🟠 | License changed | e.g. MIT → AGPL in a patch release. |
| 🟠 | Fresh release (< 7 days) | Most malicious releases are detected and pulled within days. |
| 🟠 | New maintainer's first release | Usually fine. Also exactly how event-stream was hijacked. |
| 🟠 | Lookalike name | lodahs, reactdom, @someone/lodash… |
| 🟠 | Git dependency / missing integrity / deprecated | Mutable or unverifiable code. |
| 🟡 | Copyleft or unclear license, downgrades | Not a threat, but you want to know. |
Things it deliberately does not flag: install scripts that the package already had, private registries you already use, normal maintainer rotation inside a team, and major version bumps (those are shown in the Updated table instead).
Identical findings in one scope (@esbuild/*, @img/*…) are grouped into one row, so the real outliers stay visible.
- Offline checks need nothing but the two lockfiles.
- Online checks query only
registry.npmjs.org, and only for packages your lockfile says come from there. Names of packages from private registries never leave your machine. - No telemetry.
import { analyze, renderMarkdown } from 'lockfile-lens';
const result = await analyze(oldLockText, newLockText, { online: true });
console.log(result.findings);
console.log(renderMarkdown([result]));- npm
package-lock.json/npm-shrinkwrap.json, lockfileVersion 1, 2 and 3, workspaces and aliases. - Node.js 20+.
-
pnpm-lock.yamlandyarn.lock - Python (
poetry.lock,uv.lock) and Rust (Cargo.lock) - Inline "what does this install script run" preview
- Ignore list (
.lockfile-lens.json) for accepted findings
Ideas and PRs are very welcome.
lockfile-lens is free and will stay free. If it caught something for you, or just saved your reviewers time, consider sponsoring the project. It directly pays for the time spent maintaining it.