lockfile-lint does not lint the entire tree for package-lock.json
See original GitHub issueWhen running "test:lockfile": "lockfile-lint -p package-lock.json -t npm -a npm -o https: -c -i",
it does not check past the first resolved URL for a dependency.
Expected Behavior
lockfile-lint
should check the entire tree.
Current Behavior
If we take the below snippet from a package-lock.json
and change the semver
resolved URL to http
or a URL other than registry.npmjs.org
, lockfile-lint
will not catch this.
"@babel/core": {
"version": "7.7.5",
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.7.5.tgz",
"integrity": "sha512-M42+ScN4+1S9iB6f+TL7QBpoQETxbclx+KNoKJABghnKYE+fMzSGqst0BZJc8CpI625bwPwYgUyRvxZ+0mZzpw==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.5.5",
"@babel/generator": "^7.7.4",
"@babel/helpers": "^7.7.4",
"@babel/parser": "^7.7.5",
"@babel/template": "^7.7.4",
"@babel/traverse": "^7.7.4",
"@babel/types": "^7.7.4",
"convert-source-map": "^1.7.0",
"debug": "^4.1.0",
"json5": "^2.1.0",
"lodash": "^4.17.13",
"resolve": "^1.3.2",
"semver": "^5.4.1",
"source-map": "^0.5.0"
},
"dependencies": {
"semver": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
"dev": true
},
"source-map": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=",
"dev": true
}
}
},
Possible Solution
At the moment, my current possible solution is to find and loop over all the resolved
URLs.
Steps to Reproduce (for bugs)
- If you don’t have a project with
lockfile-lint
in it already, create one and installlockfile-lint
- Add a script that uses
lockfile-lint
(e.x."test:lockfile": "lockfile-lint -p package-lock.json -t npm -a npm -o https: -c -i"
) - Go into the
package-lock.json
and change the resolved URL to a dependency that is under"dependencies"
- Run
lockfile-lint
Context
I cannot fully lint my entire package-lock.json
file due to this.
Your Environment
- Library Version used:
^3.0.8
- Node.js version (e.g. Node.js 5.4):
v10.13.0
- Operating System and version (desktop or mobile): macOS Mojave v10.14.5
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
lockfile-lint - npm
Start using lockfile-lint in your project by running `npm i lockfile-lint`. There are 18 other projects in the npm registry using lockfile-lint.
Read more >Add package-lock.json · Issue #3895 · stylelint ... - GitHub
Using npm ci with a lock file will install postcss-value-parser version 3.3.0 , if 3.3.1 is released the stylelint Travis CI jobs will...
Read more >What is package lock json? Lockfiles for yarn & npm ... - Snyk
When a project's package.json is not in-sync with its lock file, package managers like npm and yarn will try to reconcile the difference...
Read more >Angular npm install works but npm ci gives errors
But npm ci exits with an error if dependencies in package-lock.json do not match with those in package.json. So, instead of updating package- ......
Read more >package.json vs package-lock.json: Major Differences
It is possible. Set package-lock=false in /.npmrc to instruct the npm command not to create package-lock.json.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@JamesSingleton if you wanted to take a stab at fixing it and providing a PR I’m happy to guide you through on the change that I had in mind. It’s not a very complicated one but the refactor will touch a few places.
In specific I was thinking of:
ParseLockfile.js
will return a flat array list instead of an objectpackagesList
instead ofpackages
which hints an array list, and opens the possibility in the future to provide a hierarchy structure or otherwise.Alrighty, I’m able to reproduce. Thanks for the heads up on this 👌