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

fix(library): fill libraryFixedIns{}.key in ftypes.Pnpm and ftypes.DotNetCore #1498

Merged
merged 2 commits into from
Jul 26, 2022

Conversation

MaineK00n
Copy link
Collaborator

@MaineK00n MaineK00n commented Jul 25, 2022

What did you implement:

When vulnerability was detected in pnpm-lock.yaml and *.deps.json, the key of libraryFixedIns in the report result was not set.
This PR fixes that.

Also, pnpm-lock.yaml and *.deps.json are added to the target of findLock.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

The key of libraryFixedIns in the report result is filled.

before

"scannedCves": {
  "CVE-2021-23566": {
    "cveID": "CVE-2021-23566",
    "confidences": [
      {
        "score": 100,
        "detectionMethod": "TrivyMatch"
      }
    ],
    "libraryFixedIns": [
      {
        "name": "nanoid",
        "fixedIn": "3.1.31",
        "path": "/home/mainek00n/github/github.com/MaineK00n/vuls/integration/data/lockfile/pnpm-lock.yaml"
      }
    ]
  },
  "GHSA-5crp-9r3c-p9vr": {
    "cveID": "GHSA-5crp-9r3c-p9vr",
    "confidences": [
      {
        "score": 100,
        "detectionMethod": "TrivyMatch"
      }
    ],
    "libraryFixedIns": [
      {
        "name": "Newtonsoft.Json",
        "fixedIn": "13.0.1",
        "path": "/home/mainek00n/github/github.com/MaineK00n/vuls/integration/data/lockfile/datacollector.deps.json"
      }
    ]
  }
}

after

"scannedCves": {
  "CVE-2021-23566": {
    "cveID": "CVE-2021-23566",
    "confidences": [
      {
        "score": 100,
        "detectionMethod": "TrivyMatch"
      }
    ],
    "libraryFixedIns": [
      {
        "key": "node",
        "name": "nanoid",
        "fixedIn": "3.1.31",
        "path": "/home/mainek00n/github/github.com/MaineK00n/vuls/integration/data/lockfile/pnpm-lock.yaml"
      }
    ]
  },
  "GHSA-5crp-9r3c-p9vr": {
    "cveID": "GHSA-5crp-9r3c-p9vr",
    "confidences": [
      {
        "score": 100,
        "detectionMethod": "TrivyMatch"
      }
    ],
    "libraryFixedIns": [
      {
        "key": ".net",
        "name": "Newtonsoft.Json",
        "fixedIn": "13.0.1",
        "path": "/home/mainek00n/github/github.com/MaineK00n/vuls/integration/data/lockfile/datacollector.deps.json"
      }
    ]
  }
}

Checklist:

You don't have to satisfy all of the following.

  • Write tests
  • Write documentation
  • Check that there aren't other open pull requests for the same issue/feature
  • Format your source code by make fmt
  • Pass the test by make test
  • Provide verification config / commands
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: YES

Reference

@MaineK00n MaineK00n self-assigned this Jul 25, 2022
@MaineK00n MaineK00n requested a review from kotakanbe July 25, 2022 09:24
@MaineK00n MaineK00n changed the title fix(library): fill key in ftypes.Pnpm and ftypes.DotNetCore fix(library): fill libraryFixedIns{}.key in ftypes.Pnpm and ftypes.DotNetCore Jul 25, 2022
Comment on lines -175 to -181
filename := filepath.Base(s.LockfilePath)
switch filepath.Ext(filename) {
case ".jar", ".war", ".ear", ".par":
return "java"
default:
return LibraryMap[filename]
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this NewDriver returns an error in cases other than the above, it is appropriate to return an empty string by default.

scanner, err := library.NewDriver(s.Type)

@kotakanbe kotakanbe merged commit ab54266 into master Jul 26, 2022
@kotakanbe kotakanbe deleted the MaineK00n/fix-library-key branch July 26, 2022 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants