-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
x/vuln: convert govulncheck output to sarif format #61347
Comments
CC @golang/vulndb |
This would definitely be a welcome addition, just came to make this proposal request and found this was proposed already - I remember having to create a(n) (experimental) transformation layer to integrate it into Code Scanning for my personal projects but it would be a great if we can get first class support for SARIF through this tool. I believe the recent changes before 1.0 release (creating an output |
This proposal has been added to the active column of the proposals project |
@zpavlinovic to look into this. |
It sounds like we will find some way to produce SARIF for this use case, likely as a separate tool. |
An open question about SARIF support for Github code scanning is how to present witness call stacks. AFAIK, the dependency code cannot be annotated and parts of the call stack will refer to such code by definition. (Even if it could be annotated, it is not clear how users would assemble a call stack from a bunch of annotations spread over different files. IDEs can step through the call stack, but I don't think that is an option here.) One way to go about this is to create an annotation/alert for the |
Based on the discussion above, this proposal seems like a likely accept. |
Is it going to be part of |
It is supposed to be a separate command that govulncheck-action will call. It won't be part of govulncheck command. The question is how to create Sarif output so it makes sense for Github code scanning. In particular, to what code should the alerts be associated? |
Will this tool be under x/vuln/cmd? I originally thought we'd let the community write and maintain the conversion tool. If the Go team is committed to support the SARIF format anyway, why do we want to keep this as a separate command instead of having SARIF format is useful beyond the GitHub code scanning. Many services, apps, and editor extensions ingest the format. For example, it's a possibility to let the SARIF viewer extension in VS Code to handle display of govulncheck findings (instead of depending on gopls or vscode-go).
Annotating go.mod will work for applications like GitHub code scanning. And if most of findings can be fixed by simply upgrading the module, I think that fits nicely. Alternative ways to consider are all the entry points or the first place in the module that leads eventually to the vulnerable symbol. That potentially allows SARIF-based applications' grouping, sorting, and filtering findings to be more powerful, but associating the module upgrade with the result seems tricky. |
Keeping the tool separate allows tools to be pipelined, so for instance I guess the question is, is SARIF ubiquitous enough to be a blessed format, in which case adding it as an output directly to govulncheck makes sense, but if it is just one among many, then I would rather keep it in a separate tool. Also the prototype will probably want to use owenrumney/go-sarif as it seems to be the current library of choice for dealing with sarif, but that might not be a reasonable dependency for govulncheck itself. |
I think the tool doesn't need to support GitHub Code Scanning specifically, as long as it adheres to the SARIF spec, it Regarding how to associate vulnerable parts of the code, the SARIF spec supports something called the CodeFlows property and ThreadFlows. The idea behind CodeFlows is to show the call stack from the (potentially vulnerable) user input right down to the vulnerable symbol (think sources and syncs from taint analysis). The spec allows for us to thoroughly help the user with identifying which parts of the code and their dependencies are vulnerable and the call stack is very useful when auditing. Another thing to note here is that it can have more than one CodeFlows so it could potentially also have the path from the vulnerable usage of a symbol within a dependency to the |
I hope the answer is yes from my quick googling. (gitlab, sonar, datadog, vscode, jetbrains qodana, etc and i see various libraries). I guess it is more likely for enterprises to go with something with published spec for their filtering integration instead of developing a tool that only works with govulncheck's json format. Producer-wise, staticcheck seems to have unofficial(?) support in progress, and golangci-lint has an open issue (not sure if that will ever implemented). Products like snyk, checkmarx supports sarif. Google's osv scanner also reports sarif. Wait, I think google/osv-scanner integrates govulncheck internally. Can users use google/osv-scanner instead? Do they have github action?
In this case, the question is whether it should be part of the official go project. It looks like currently rust is leaning towards depending on community-maintained solutions for the github action or the sarif conversion. (https://github.com/rust-lang/rust-clippy issue 8122) |
I did start work on SARIF support in Staticcheck but eventually got side-tracked. My two cents: it's the only format that's somewhat widely supported, and it allows some nice integrations with GitHub. The spec is big, but you only need a tiny subset of it for something like Staticcheck, and even less for govulncheck. I don't think there's much value in depending on a third party dependency for generating SARIF, as it's primarily structs, constants, and Consumers of SARIF are rather hit and miss in what parts of SARIF they support and how well, which can make it difficult to rely on less common SARIF features to expose your information. This also makes it a "fun" experience to debug your SARIF output, as for example the VSCode extension to look at SARIF can disagree with GitHub's interpretation of it. |
It depends on how Sarif format will be used. If it's decided to associate findings on go.mod file require lines, the second |
These details about exactly how to implement the conversion can be handled outside the proposal process. |
It looks like the scope of the proposal needs to be updated. It is no longer about github-action.
|
No change in consensus, so accepted. 🎉 |
Change https://go.dev/cl/549815 mentions this issue: |
Change https://go.dev/cl/549775 mentions this issue: |
But don't document it. Updates golang/go#61347 Change-Id: Iac4aef93c3e74a235f646b101feea2b1c62769ac Reviewed-on: https://go-review.googlesource.com/c/vuln/+/549376 Reviewed-by: Maceo Thompson <maceothompson@google.com> Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Cottrell <iancottrell@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
The handler keeps track of the most precise findings for a vulnerability. Updates golang/go#61347 Change-Id: I8fe8183826f152d8d51d9e5b3117cd192012fdba Reviewed-on: https://go-review.googlesource.com/c/vuln/+/549775 Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Maceo Thompson <maceothompson@google.com>
Change https://go.dev/cl/550015 mentions this issue: |
Change https://go.dev/cl/549995 mentions this issue: |
Also add a summary to one of the vulndb entries. This actually improves testing coverage for both govulncheck text and sarif. Updates golang/go#61347 Change-Id: Id851d6015daf350908b433c56853daf75f1240fb Reviewed-on: https://go-review.googlesource.com/c/vuln/+/549815 Reviewed-by: Maceo Thompson <maceothompson@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Change https://go.dev/cl/567455 mentions this issue: |
This makes config more self-contained and will help make sarif support cleaner. Also update help with default values for scan mode and level to be consistent while at it. Updates golang/go#61347 Change-Id: I6fc8d3dcd82f7843b54b704a9bdcc02352eeeeaa Reviewed-on: https://go-review.googlesource.com/c/vuln/+/567455 Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Maceo Thompson <maceothompson@google.com>
Other information (message, location, and stacks) will be added in future CLs. Updates golang/go#61347 Change-Id: I3bb78594372038817e379c16d452ff5159b26efc Reviewed-on: https://go-review.googlesource.com/c/vuln/+/549995 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Cottrell <iancottrell@google.com> Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Updates golang/go#61347 Change-Id: Iffc71db2b1256db2a7294619be29a4a6e4ddfc5c Reviewed-on: https://go-review.googlesource.com/c/vuln/+/550015 Reviewed-by: Maceo Thompson <maceothompson@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Change https://go.dev/cl/550736 mentions this issue: |
Change https://go.dev/cl/550735 mentions this issue: |
Location information will be added later. Updates golang/go#61347 Change-Id: Ibd6a2f7f6dfd4ac6e333c5de070b76a68e8e462c Reviewed-on: https://go-review.googlesource.com/c/vuln/+/550735 TryBot-Result: Gopher Robot <gobot@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Maceo Thompson <maceothompson@google.com> Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
Updates golang/go#61347 Change-Id: Iae039bb8dbe77cb984e425179bc39eaa2ddc3b8e Reviewed-on: https://go-review.googlesource.com/c/vuln/+/550736 Reviewed-by: Maceo Thompson <maceothompson@google.com> Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Change https://go.dev/cl/551375 mentions this issue: |
A code flow is a compact representation of a trace used for the textual output of govulncheck. For that purpose, the logic for trace compaction is extracted into a separate internal package traces. We also add the message portion of Location object for code flows to reduce the number of CLs; the actual physical region part will come in following CLs. To make things consistent, we also add the Message part of the location for stacks. Updates golang/go#61347 Change-Id: I99065a7aab7aa794e7a08687cb4055bc21a610f8 Reviewed-on: https://go-review.googlesource.com/c/vuln/+/551375 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com> Reviewed-by: Maceo Thompson <maceothompson@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Change https://go.dev/cl/552955 mentions this issue: |
Updates golang/go#61347 Change-Id: I725012e4b028b879a0d1720fc47632e76e699c04 Reviewed-on: https://go-review.googlesource.com/c/vuln/+/552955 Reviewed-by: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Change https://go.dev/cl/558016 mentions this issue: |
And also make sure the paths are not added in binary mode. Updates golang/go#61347 Change-Id: If48fe57215cdecb01b8b687fbe042aae584f1d6d Reviewed-on: https://go-review.googlesource.com/c/vuln/+/558016 Reviewed-by: Maceo Thompson <maceothompson@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
Change https://go.dev/cl/558017 mentions this issue: |
Otherwise, sarif validator complains. Also add default position values in case the position is not available. Updates golang/go#61347 Change-Id: Id30aa3cf352c35df841075e28ca9ffa1c17576ff Reviewed-on: https://go-review.googlesource.com/c/vuln/+/558017 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com> Reviewed-by: Ian Cottrell <iancottrell@google.com>
Change https://go.dev/cl/580955 mentions this issue: |
Change https://go.dev/cl/581076 mentions this issue: |
We don't need it and it is not actually needed. Sarif validator is fine without it and so is Github Code scanning. Updates golang/go#61347 Change-Id: I1d368422935fddd6b9960917010287ae7bca2683 Reviewed-on: https://go-review.googlesource.com/c/vuln/+/581076 Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com> Auto-Submit: Zvonimir Pavlinovic <zpavlinovic@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
With the introduction of the new govulncheck-action, teams that are making use of GitHub Advanced Security are able to integrate vulnerabilities identified by other tools. GitHub supports the SARIF format (latest schema version is 2.1.0).
I propose the addition of a
sarif-file
input to instruct the action to produce a SARIF report that may be uploaded to GitHub for integration with code scanning.https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/sarif-support-for-code-scanning
The text was updated successfully, but these errors were encountered: