Skip to content
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

unexpected error with SWIFT Package Manager Analyzer #3813

Closed
piggy34 opened this issue Nov 22, 2021 · 2 comments
Closed

unexpected error with SWIFT Package Manager Analyzer #3813

piggy34 opened this issue Nov 22, 2021 · 2 comments
Labels
Milestone

Comments

@piggy34
Copy link

piggy34 commented Nov 22, 2021

Describe the bug
Receiving the following error

`
[INFO] Finished SWIFT Package Manager Analyzer (0 seconds)
[WARN] An unexpected error occurred during analysis of '.../Package.resolved' (SWIFT Package Resolved Analyzer): class javax.json.JsonValueImpl cannot be cast to class javax.json.JsonString (javax.json.JsonValueImpl and javax.json.JsonString are in unnamed module of loader 'app')

[ERROR]
java.lang.ClassCastException: class javax.json.JsonValueImpl cannot be cast to class javax.json.JsonString (javax.json.JsonValueImpl and javax.json.JsonString are in unnamed module of loader 'app')
at org.glassfish.json.JsonObjectBuilderImpl$JsonObjectImpl.getJsonString(JsonObjectBuilderImpl.java:252)
at org.glassfish.json.JsonObjectBuilderImpl$JsonObjectImpl.getString(JsonObjectBuilderImpl.java:257)
at org.owasp.dependencycheck.analyzer.SwiftPackageResolvedAnalyzer.lambda$analyzeSpmResolvedDependencies$0(SwiftPackageResolvedAnalyzer.java:175)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at org.owasp.dependencycheck.analyzer.SwiftPackageResolvedAnalyzer.analyzeSpmResolvedDependencies(SwiftPackageResolvedAnalyzer.java:168)
at org.owasp.dependencycheck.analyzer.SwiftPackageResolvedAnalyzer.analyzeDependency(SwiftPackageResolvedAnalyzer.java:139)
at org.owasp.dependencycheck.analyzer.AbstractAnalyzer.analyze(AbstractAnalyzer.java:131)
at org.owasp.dependencycheck.AnalysisTask.call(AnalysisTask.java:88)
at org.owasp.dependencycheck.AnalysisTask.call(AnalysisTask.java:37)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)

`

Version of dependency-check used
The problem occurs using version 6.5.0 of the cli

To Reproduce
Steps to reproduce the behavior:

  1. brew install dependency-check
  2. dependency-check --suppression dependency-check-suppression.xml --enableExperimental --project XXX --out . --scan .

Expected behavior
dependency check to run without complaints

@piggy34 piggy34 added the bug label Nov 22, 2021
@squarefrog
Copy link
Contributor

I'm getting this too with 6.5.0, with a Package.resolved containing null values. For example, try this Package.resolved file:

{
  "object": {
    "pins": [
      {
        "package": "Commandant",
        "repositoryURL": "https://github.com/Carthage/Commandant.git",
        "state": {
          "branch": null,
          "revision": "ab68611013dec67413628ac87c1f29e8427bc8e4",
          "version": "0.17.0"
        }
      },
      {
        "package": "swift-doc",
        "repositoryURL": "https://github.com/SwiftDocOrg/swift-doc",
        "state": {
          "branch": "1.0.0-beta.4",
          "revision": "581af2fe50667ed2f49c53d26b91a8feb4531302",
          "version": null
        }
      }
    ]
  },
  "version": 1
}

Replacing the null value from version causes the error to not be thrown. With SPM, if version is null, then they are using the head of a specific branch.

Looking at this line, should there be a check to see if the value exists before trying to extract it?

@jeremylong
Copy link
Owner

Thanks for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants