Add Related Locations to Misconfiguration SARIF output #6847
Replies: 2 comments 6 replies
-
hi @cholesterol while I like the idea, I do think it will be hard to maintain this as not all modules are hosted off of GitHub. Do you have an example of a related location URL? |
Beta Was this translation helpful? Give feedback.
-
@simar7 @nikpivkin 👋🏻 , I'm also noticing now as I'm trying to use the --tf-exclude-downloaded-modules flag as a workaround that lots of my historical issues related to upstream providers don't seem to close or open like I would expect. I read through the upload sarif source code and it looks like GitHub uses the primary artifact location as a fallback when computing hashes to generate a fingerprint if the sarif is missing this information, and that it has to be local to the repository. Is this intended behavior? Should the docs be updated to dissuade people not excluding downloaded tf modules when using Trivy in an actions pipeline since it doesn't generate fingerprints? Or perhaps just be updated to let people know of the potential gotchas when implementing Trivy w/ Advanced Security? Should the primary location for any given result generated from an upstream provider be the location in the local source code instead of the upstream artifact so these can reliably be used for fingerprint generation? As it stands if you're calling the same module in multiple locations they will all have the same primary artifact location and share the same fingerprint which will increase the odds of dupes/inconsistent closing/opening of alerts in GitHub Advanced Security. Here is an example of where this would be an issue (using the vscode sarif extension to view the raw sarif) Since these both share the exact same location as the root cause of the misconfiguration (line 440/441 in the community security group provider) I believe they will share a fingerprint. |
Beta Was this translation helpful? Give feedback.
-
Description
👋🏻 Hey there,
I've already written the code necessary to address this and didn't realize I should have created a discussion first so an issue could get spun up. Apologies for doing this out of order. If folks agree this would be useful to have I can immediately open up a PR to close the corresponding feature issue.
Currently when using Trivy with it's corresponding GitHub Action I noticed that although I get related locations for Terraform modules in the standard table output that this is missing from the SARIF output.
As a result if you're working in a monorepo where lots of folks are using the same module as a dependency it can be incredibly difficult (if not impossible) to triage which local file made reference to that module, and where.
It would be helpful to have the same output that is available in the Table format available in GitHub via SARIF. Example of the output I'm referencing below.
The PR I'm working on instead takes any artifact and if it's not local (prepended by github.com) will change the markdown so the user gets a link to the upstream module code (including the line range/etc). They also get a list of artifacts local to that repository in their related locations that can be expanded in-line like any other GitHub Code-scanning alert. The output looks like the following.
I think this would be a huge QoL upgrade for folks that want to see the dependency path for terraform misconfigurations directly in GitHub.
Thank you and apologies again for doing this a bit out of order,
Target
Filesystem
Scanner
Misconfiguration
Beta Was this translation helpful? Give feedback.
All reactions