Skip to content

feat: Add configuration option to disable scanning Go version from go.mod#2637

Open
another-rex wants to merge 9 commits intomainfrom
jules-5355023063191685691-972f7842
Open

feat: Add configuration option to disable scanning Go version from go.mod#2637
another-rex wants to merge 9 commits intomainfrom
jules-5355023063191685691-972f7842

Conversation

@another-rex
Copy link
Copy Markdown
Collaborator

This commit addresses the issue where Go version warnings based on go.mod are misleading because the go directive specifies the minimum required language version, not the actual toolchain version. We introduce a new ScanGoModVersion configuration setting, which is disabled by default, ensuring we avoid assumptions regarding the toolchain version from go.mod files.

Snapshots and tests have been updated accordingly to reflect this change in the default behavior.


PR created automatically by Jules for task 5355023063191685691 started by @another-rex

….mod

OSV-Scanner historically used the go version in go.mod to emit Go-version-related warnings.
However, the `go` directive is a minimum language version for the module, not the actual Go toolchain used to build or run the project.

This commit changes the default behavior to not emit warnings or make vulnerability-related decisions based only on the go directive in go.mod. A new configuration setting `ScanGoModVersion` is introduced in `osv-scanner.toml` to opt-in back to this behavior.

Co-authored-by: another-rex <106129829+another-rex@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@G-Rath
Copy link
Copy Markdown
Collaborator

G-Rath commented Mar 11, 2026

Rather than introduce a new config property, what about reusing the existing one with a value of ignore or something?

We can use a custom marshaller to handle the type difference

@another-rex
Copy link
Copy Markdown
Collaborator Author

I think the issue is that I want it to be disabled by default, and opt in, which makes the override field a bit odd to use.

I guess we can have a term like "scan", but it's not really Overriding anything if the default is the version is not extracted.

Add missing blank lines before return statements to comply with nlreturn rules in golangci-lint.

Co-authored-by: another-rex <106129829+another-rex@users.noreply.github.com>
@G-Rath
Copy link
Copy Markdown
Collaborator

G-Rath commented Mar 11, 2026

Ah yeah fair, if it's disabled by default that makes more sense - we could have it kind of like the version properties in things like gh actions e.g.

GoVersion: 'go.mod'
GoVersion: '.go-version'

GoVersion: 1.20

But thats probably not ergonomic enough to be worth it especially since it's off by default now 🤷‍♂️

…tests

Co-authored-by: another-rex <106129829+another-rex@users.noreply.github.com>
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 11, 2026

Codecov Report

❌ Patch coverage is 70.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.03%. Comparing base (fab07dd) to head (a42002f).

Files with missing lines Patch % Lines
pkg/osvscanner/osvscanner.go 70.00% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2637      +/-   ##
==========================================
+ Coverage   68.01%   68.03%   +0.02%     
==========================================
  Files         173      173              
  Lines       13389    13406      +17     
==========================================
+ Hits         9106     9121      +15     
- Misses       3575     3579       +4     
+ Partials      708      706       -2     

☔ 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.

Co-authored-by: another-rex <106129829+another-rex@users.noreply.github.com>
@another-rex another-rex marked this pull request as ready for review March 17, 2026 03:57
@another-rex
Copy link
Copy Markdown
Collaborator Author

@jules Rerun the snapshots building to resolve the conflict (make rebuild-all)

@google-labs-jules
Copy link
Copy Markdown
Contributor

@jules Rerun the snapshots building to resolve the conflict (make rebuild-all)

I have rerun the snapshot building and updated the snapshots.

google-labs-jules bot and others added 5 commits March 17, 2026 04:18
Co-authored-by: another-rex <106129829+another-rex@users.noreply.github.com>
Co-authored-by: another-rex <106129829+another-rex@users.noreply.github.com>
Co-authored-by: another-rex <106129829+another-rex@users.noreply.github.com>
Co-authored-by: another-rex <106129829+another-rex@users.noreply.github.com>
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.

3 participants