Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@kuscar
Copy link
Contributor

@kuscar kuscar commented Aug 12, 2025

Added support for recognizing osv-scanner-custom.json with the -r option. I wasn’t sure if "osv-scanner-custom.json": {osvscannerjson.Name},
also needs to be added to lockfile.go, since it seems to work without it. Please review and advise on any improvements. I will update the snapshots after.
Do I also need to update the webpage that lists supported files?

Copy link
Collaborator

@another-rex another-rex left a comment

Choose a reason for hiding this comment

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

Looks great!

Can you please also copy cmd/osv-scanner/scan/source/fixtures/locks-insecure/osv-scanner.json to cmd/osv-scanner/scan/source/fixtures/locks-insecure/osv-scanner-custom.json, and then update all snapshots?

This way we have a test for the filename scan working.


As for the docs, just rename the osv-scanner.json file section

Once you extracted your own dependency information, place it in a `osv-scanner.json` file, with the same format as the JSON output of osv-scanner, e.g.:
to osv-scanner-custom.json, and mention that it will automatically be picked up. I can edit this later to put in more detail.

"github.com/google/osv-scanner/v2/internal/scalibrextract/language/javascript/nodemodules"
"github.com/google/osv-scanner/v2/internal/scalibrextract/language/python/requirementsenhancable"
"github.com/google/osv-scanner/v2/internal/scalibrextract/vcs/gitrepo"
"github.com/google/osv-scanner/v2/internal/scalibrextract/language/osv/osvscannerjson"
Copy link
Collaborator

Choose a reason for hiding this comment

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

The imports doesn't seem formatted/ordered correctly here.

@kuscar
Copy link
Contributor Author

kuscar commented Aug 13, 2025

I also updated the orders, but there are still some issues with the lint script. Since this custom file is not part of the Scalibr package, I wasn’t able to resolve them. Could you please take a look?

Also, please check if the documentation is sufficient.

return vendored.New(), nil
case gitrepo.Name:
return gitrepo.New(), nil
case "osv/osvscannerjson":
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
case "osv/osvscannerjson":
case osvscannerjson.Name:

osv-scanner --lockfile osv-scanner:/path/to/osv-scanner.json
```

For automatic scan detection, you can create an osv-scanner-custom.json file using the same procedure described above for osv-scanner.json.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
For automatic scan detection, you can create an osv-scanner-custom.json file using the same procedure described above for osv-scanner.json.
For automatic scan detection, you can create an `osv-scanner-custom.json` file using the same procedure described above for `osv-scanner.json`.

@G-Rath
Copy link
Collaborator

G-Rath commented Aug 13, 2025

@kuscar it looks like the remaining linting issues are with gofmt - running gofmt -w internal/scalibrplugin/* should resolve them.

You'll also need to run npx prettier --write . to format the docs

@kuscar
Copy link
Contributor Author

kuscar commented Aug 13, 2025

Thank you, that was insanely fast. Please let me know if there’s anything else I can improve.

@codecov-commenter
Copy link

codecov-commenter commented Aug 18, 2025

Codecov Report

❌ Patch coverage is 62.50000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.37%. Comparing base (e06e67d) to head (e6f8ef0).

Files with missing lines Patch % Lines
...brextract/language/osv/osvscannerjson/extractor.go 66.66% 1 Missing and 1 partial ⚠️
internal/scalibrplugin/resolve.go 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2177      +/-   ##
==========================================
- Coverage   67.49%   67.37%   -0.12%     
==========================================
  Files         170      170              
  Lines       16328    16357      +29     
==========================================
  Hits        11020    11020              
- Misses       4623     4634      +11     
- Partials      685      703      +18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@another-rex
Copy link
Collaborator

Known limitation with this current fix, it will fail for the --format=spdx output, but that will require much more work to fix, so leaving it as is for now. @michaelkedar Can you take a look?

Copy link
Member

@michaelkedar michaelkedar left a comment

Choose a reason for hiding this comment

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

LGTM

@michaelkedar
Copy link
Member

Known limitation with this current fix, it will fail for the --format=spdx output, but that will require much more work to fix, so leaving it as is for now. @michaelkedar Can you take a look?

We might want to document this limitation somewhere in the docs

@another-rex another-rex merged commit 141de13 into google:main Aug 19, 2025
16 checks passed
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.

5 participants