aquasecurity / trivy-action

Runs Trivy as GitHub action to scan your Docker container image for vulnerabilities
Apache License 2.0
806 stars 233 forks source link

Issue with uploading the SARIF report to GitHub #408

Open uRhos opened 2 weeks ago

uRhos commented 2 weeks ago

Hello,

We're facing issues with the Using Trivy to scan your Git repo setup, the action is working fine and creates a SARIF report, however that report is not accepted by GithHub in the Upload Trivy scan results to GitHub Security tab step. Here's our workflow.yaml config:

  - name: Run Trivy vulnerability scanner in repo mode
    uses: aquasecurity/trivy-action@master
    env:
      TRIVY_USERNAME: ${{ secrets.TRIVY_USERNAME }}
      TRIVY_PASSWORD: ${{ secrets.TRIVY_PASSWORD }}
      TRIVY_DB_REPOSITORY: ${{ secrets.TRIVY_REPOSITORY }}
    with:
      scan-type: 'fs'
      ignore-unfixed: true
      format: 'sarif'
      output: 'trivy-results.sarif'
      timeout: '10m'
      severity: 'CRITICAL,HIGH'
      scanners: "vuln,misconfig"
      limit-severities-for-sarif: true

  - name: Upload Trivy scan results to GitHub Security tab
    uses: github/codeql-action/upload-sarif@v3
    with:
      sarif_file: 'trivy-results.sarif'

The error from the Upload Trivy scan results to GitHub Security tab is: Error: Code Scanning could not process the submitted SARIF file: locationFromSarifResult: expected artifact location, locationFromSarifResult: expected artifact location We're using the latest version supported in the trivy-action.

simar7 commented 2 weeks ago

@uRhos that's interesting. I tested this earlier as you can see here and it was fine.

Is it possible for you run the same scan locally with the Trivy CLI to see what output you get? It might be a bug with the SARIF output being generated incorrectly.

Were the reports correctly being generated and uploaded in prior versions of Trivy action?

richardrobarth commented 2 weeks ago

I had similar issue since yesterday, had to revert to 0.25.0. Our problem was that result was generated in table format (not sarif). From the looks of it the action isnt picking up the correct config (from trivy.yaml).

uRhos commented 2 weeks ago

@uRhos that's interesting. I tested this earlier as you can see here and it was fine.

Is it possible for you run the same scan locally with the Trivy CLI to see what output you get? It might be a bug with the SARIF output being generated incorrectly.

Were the reports correctly being generated and uploaded in prior versions of Trivy action?

Yes, after setting version: 'v0.55.0' the workflow is completed correctly, but I agree with @richardrobarth the trivy.yaml config is not being picked up, so we had to change from using it to using the inputs and env vars

JackDallas commented 2 weeks ago

Also hitting this in multiple repos, pinning to 0.24.0 fixes it for us

simar7 commented 1 week ago

@uRhos could you try with the latest release https://github.com/aquasecurity/trivy-action/releases/tag/0.27.0 we had an issue where env var were not getting set and it should be addressed hopefully in this release. Let us know how it goes.

mat-sylvia-mark43 commented 1 week ago

Also having issues with SARIF upload. Confirmed the SARIF is there after the trivy scan, but didn't confirm its contents. Errors from the upload-sarif action attached. I changed no working directory settings or anything like that.

git call failed. Continuing with commit SHA from user input or environment. Error: The checkout path provided to the action does not appear to be a git repository. git call failed. Will calculate the base branch SHA on the server. Error: The checkout path provided to the action does not appear to be a git repository.

image

nikpivkin commented 1 week ago

Hi @mat-sylvia-mark43 ! Can you give me an example of your workflow?

uRhos commented 1 week ago

Hi @uRhos ! Can you give me an example of your workflow?

The workflow we use is pretty much in the description, we just have one more step to checkout the code first

nikpivkin commented 1 week ago

@uRhos Ah, I accidentally mentioned you

uRhos commented 1 week ago

@uRhos could you try with the latest release https://github.com/aquasecurity/trivy-action/releases/tag/0.27.0 we had an issue where env var were not getting set and it should be addressed hopefully in this release. Let us know how it goes.

so we tried it with the 0.27.0 version of trivy-action and 0.56.2 version of trivy and got the same error, after setting the trivy version to 0.55.2 it works, so it's probably a bug in the latest trivy release

mat-sylvia-mark43 commented 1 week ago

@nikpivkin Here you go!

image

mat-sylvia-mark43 commented 3 days ago

@nikpivkin any thoughts? The action appears to be completely broken by this.