Build-time security
package-tripwire
Fail CI when dependency changes look suspicious.
npm i -D package-tripwireWhat it checks
install-scriptNewpreinstall/install/postinstallscripts (or implicitnode-gyp), or scripts that changed since the previous versiondisallowed-install-scriptPackage runs install scripts but is not listed inallowScriptswhen enforcement is onintegrity-changeSamename@versionwith a different integrity hash or tarball source, or a lockfile hash that doesn't match the registryregistry-signature-invalidRegistry tarball ECDSA signature does not verify (same rules asnpm audit signatures)unsigned-packageRegistry metadata has no tarball signature while the registry publishes signing keysprovenance-lostnpm provenance attestation was present on the previous version but missing on the new oneprovenance-missingResolved version has no provenance attestation (--require-provenancepromotes to a failure)disallowed-host/disallowed-scheme/name-url-mismatchlockfile-lint style tarball URL policy (opt-in vialockfileLint)
Quick usage
CLI
package-tripwire # compare working-tree lockfile against HEAD
package-tripwire --base origin/main # compare against a branch / tag / commit
package-tripwire --save-baseline .tripwire/baseline.json # snapshot the current lockfile
package-tripwire --baseline .tripwire/baseline.json # compare against the snapshot
package-tripwire --min-age 7d --fail-on warn --sarif tripwire.sarif --json tripwire.json
API
import { run, analyze, parseAny, createRegistry, formatSarif, lintLockfile, findDisallowedInstallScripts } from 'package-tripwire';
// const { run } = require('package-tripwire');
const result = await run({ base: 'origin/main', config: { minAge: '3d', enforceAllowScripts: true, allowScripts: ['esbuild'] } });
console.log(result.findings);
Every option is documented in the package-tripwire docs.
CI / GitHub Action
name: Dependency tripwire
on: pull_request
permissions:
contents: read
security-events: write # only needed for SARIF upload
jobs:
tripwire:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- uses: MrLouisWright/package-tripwire@v1
with:
min-age: 72h
fail-on: error
sarif: tripwire.sarif
- if: always()
uses: github/codeql-action/upload-sarif@v3
with: { sarif_file: tripwire.sarif }