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

Recreated Github Action PR #432

Merged
merged 91 commits into from
Jul 31, 2023
Merged

Conversation

another-rex
Copy link
Collaborator

@another-rex another-rex commented Jul 5, 2023

This PR features:

  • Refactors the format flag's internal logic so that we can don't need to repeat the format types so much, and we can test when we add a new format entry if we forgot anything.
  • Adds a new format "sarif", which returns a SARIF report (closes Add support for SARIF output #216 )
  • Adds a Github Action action.yaml and it's specialized dockerfile action.dockerfile. This docker image runs a bash script wrapping osv-scanner, first by preprocessing the input so the last argument will be split by new line, allowing the workflow user to pass in multiple directories/files they wish to scan. The script also changes exit codes 127 and 128 to 0 as they contain errors that the user can't really do anything about.
  • Adds two reusable workflows using this new github action for this repo
    • Reusable PR workflow, for using to check if PRs introduce new vulnerabilities.
    • Reusable Scheduled workflow, for use to regularly check for new vulns applying to your existing vulns.
  • Adds an experimental flag: --experimental-diff, which will only output the difference between a previous run and this run of the osv-scanner. This is for use in the PR workflow.
  • Sorts the grouped ID output.

Closes #57

Currently the reusable workflow has to point to a specific action which cannot be relative (otherwise it would point to the wrong action when reused in another repo). This means right now it's pointed to this fork/branch instead of the master branch, this will need to be updated once this PR is merged.

Example of what workflow sarif output looks like:
image

Here is an example of the PR reusable workflow working:

another-rex/scorecard-check-osv-e2e#1

That PR adds an additional vulnerability, which causes it to fail. You can see that only the new vuln is showing up in the code scanning report: https://github.com/another-rex/scorecard-check-osv-e2e/security/code-scanning/1

TODO after this PR is merged:

  • Change links that point to this PR branch to point to main (and/or a tagged commit of main)
  • Add support for annotations
  • Add documentation (this is for later, as we want to dogfood it in our own repos first before broadcasting this widely)

@another-rex
Copy link
Collaborator Author

Here is an example of the PR reusable workflow working:

another-rex/scorecard-check-osv-e2e#1

That PR adds an additional vulnerability, which causes it to fail. You can see that only the new vuln is showing up in the code scanning report: https://github.com/another-rex/scorecard-check-osv-e2e/security/code-scanning/1

Copy link
Collaborator

@oliverchang oliverchang left a comment

Choose a reason for hiding this comment

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

nice! some minor comments/questions.

.github/workflows/osv-scanner-reusable-pr.yml Outdated Show resolved Hide resolved
- name: "Checkout target branch"
run: git checkout $GITHUB_BASE_REF
- name: "Run scanner"
uses: another-rex/osv-scanner@markdown-output
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to update all of these references to google/osv-scanner@main ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes we do, but only after this is already merged, otherwise I think it will prevent merging as the action will fail. Maybe a better way is to merge only the code part and have a separate PR for the workflows part.

action.yml Outdated Show resolved Hide resolved
action.yml Outdated
default: 'sarif'
recursive-search:
description: 'Recursively scan though subdirectories'
required: false
Copy link
Collaborator

Choose a reason for hiding this comment

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

is required: false required if there is a default ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think it's required, but I think it's clearer to explicitly state it for all for all inputs.

Copy link
Collaborator

@G-Rath G-Rath Jul 13, 2023

Choose a reason for hiding this comment

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

Random note because frankly its weird imo and super easy to miss: required isn't actually enforced "yet"

cmd/osv-scanner/main.go Outdated Show resolved Hide resolved
pkg/models/results.go Outdated Show resolved Hide resolved
pkg/models/results.go Outdated Show resolved Hide resolved
pkg/reporter/format.go Outdated Show resolved Hide resolved
pkg/osvscanner/vulnerability_result.go Outdated Show resolved Hide resolved
pkg/osvscanner/vulnerability_result.go Outdated Show resolved Hide resolved
picatz added a commit to picatz/jose that referenced this pull request Jul 19, 2023
Until google/osv-scanner#432 is merged, this method seems to be required.
Copy link
Collaborator

@oliverchang oliverchang left a comment

Choose a reason for hiding this comment

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

Is there anything in particular blocking this PR from merging at this point?

@another-rex another-rex merged commit ec18942 into google:main Jul 31, 2023
7 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.

Add support for SARIF output Build GitHub actions for running osv-scanner
3 participants