-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Null pointer exception while parsing package-lock.json #5318
Comments
Not sure if this is the correct approach, or if it may cause other "issues", but it should avoid the crashing, but may pass handling of empty versions to later code which may not handle the situation properly. I did a quick scan of immediately surrounding code, and it looks like it would be okay, but that doesn't mean it will work properly: diff --git a/core/src/main/java/org/owasp/dependencycheck/analyzer/NodePackageAnalyzer.java b/core/src/main/java/org/owasp/dependencycheck/analyzer/NodePackageAnalyzer.java
index 12875f915..28976bd14 100644
--- a/core/src/main/java/org/owasp/dependencycheck/analyzer/NodePackageAnalyzer.java
+++ b/core/src/main/java/org/owasp/dependencycheck/analyzer/NodePackageAnalyzer.java
@@ -394,7 +394,7 @@ public class NodePackageAnalyzer extends AbstractNpmAnalyzer {
continue;
}
- version = jo.getString("version");
+ version = jo.getString("version", "");
optional = jo.getBoolean("optional", false);
isDev = jo.getBoolean("dev", false);
} else { |
I did some "printf debugging" (or rather "LOGGER.info() debugging" 😉) this afternoon, and I think I found the source of the problem: The Click for a package-lock.json example{
"name": "my-fancy-project",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "my-fancy-project",
"license": "WHATEVER",
"dependencies": {
"some-dependency": "3.0.0",
"another-dep": "5.2.0",
[...truncated for brevity...]
},
"devDependencies": {
"@babel/core": "7.20.5",
"babel-loader": "9.1.0",
[...truncated for brevity...]
},
"engines": {
"node": "18.12.1",
"npm": "8.19.2"
}
},
"node_modules/@babel/core": {
"version": "7.20.5",
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.20.5.tgz",
"integrity": "sha512-UdOWmk4pNWTm/4DlPUl/Pt4Gz4rcEMb7CY0Y3eJl5Yz1vI8ZJGmHWaVE55LoxRjdpx0z259GE9U5STA9atUinQ==",
"dev": true,
"dependencies": {
[...truncated for brevity...]
},
"engines": {
"node": ">=6.9.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/babel"
}
},
[...more actual dependencies follow...]
}
} Edit: This can also be seen in the package-lock.json which @ferben provided along with his comment. According to the NPM docs, this is the intended behavior, starting with NPM v7:
The |
With 8.0.1 the NPE is gone at last. 👍 |
I am still encountering the issue from the |
Suspiciously similar as #1603
Dependency-Check Core version 8.0.0
output:
package-lock.json.zip
The text was updated successfully, but these errors were encountered: