Upload JFrog CLI Scan Results to GitHub Unified Security View

Upload JFrog scan results from a GitHub Actions job to code scanning.

Upload JFrog scan results to GitHub code scanning from a GitHub Actions job in JFrog Integration with GitHub. The JFrog CLI writes a combined Static Analysis Results Interchange Format (SARIF) file, final.sarif. jfrog/setup-jfrog-cli sends that file to POST /repos/{owner}/{repo}/code-scanning/sarifs during its post step.

📘

Note

Pipeline code-scanning upload requires a JFrog Artifactory Enterprise subscription or above. The upload through the JFrog GitHub App runs only on JFrog SaaS, with JFrog Advanced Security exposures and GitHub App build scanning enabled. GitHub App build scanning is off by default.

For the App upload, the build's version-control URL must be on github.com, and the JFrog GitHub App must be installed on that repository. Code scanning is available for public repositories on GitHub.com. A private repository needs a GitHub Code Security license. An organization-owned repository on GitHub Team, GitHub Enterprise Cloud, or GitHub Enterprise Server needs GitHub Code Security enabled.

Before You Begin

  • jfrog/setup-jfrog-cli@v5, JFrog CLI 2.67.0 or newer, and a JFrog scan that writes final.sarif under the JFrog CLI security summary directory.
  • JF_GIT_TOKEN set to a GitHub token with security_events: write and contents: read permissions. Don't print the token.
  • JF_URL and JFrog authentication for the scan itself. Use OpenID Connect (OIDC) for the JFrog token. For more information, see OIDC Authentication.
  • Code scanning set up on the repository. Public repositories on GitHub.com can use it. A private repository needs a GitHub Code Security license. An organization-owned repository on GitHub Team, GitHub Enterprise Cloud, or GitHub Enterprise Server needs GitHub Code Security enabled.

Without a SARIF upload, review the findings in the JFrog Platform. The upload step is skipped when final.sarif or JF_GIT_TOKEN is absent.

Upload Scan Results

This task sends final.sarif from the jfrog/setup-jfrog-cli post step to the GitHub code scanning API.

To upload scan results from GitHub Actions:

  1. Add jfrog/setup-jfrog-cli@v5 and set JF_URL, JF_PROJECT, JF_GIT_TOKEN, and the OIDC provider name.

    - uses: jfrog/setup-jfrog-cli@v5
      env:
        JF_URL: ${{ vars.JF_URL }}
        JF_PROJECT: ${{ vars.JF_PROJECT }}
        JF_GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        oidc-provider-name: <OIDC_PROVIDER_NAME>

    Where:

    • <OIDC_PROVIDER_NAME>: The OIDC provider name configured in JFrog
  2. Grant the workflow token permission to write security events.

    permissions:
      id-token: write
      contents: read
      security-events: write
  3. Run the JFrog scan command for the artifact or build.

The post step gzip-compresses final.sarif, Base64-encodes it, and uploads it for the current commit and Git ref.

Expected output:

SARIF file uploaded successfully

Set the GitHub Enterprise Server Base URL

The post step sends the upload to the GitHub REST API base URL. On a runner managed by your GitHub Enterprise Server, the action detects that URL automatically.

To set the GitHub Enterprise Server REST API base URL:

  1. Pass the full REST API base URL, including /api/v3, with ghe-base-url.

    - uses: jfrog/setup-jfrog-cli@v5
      env:
        JF_URL: ${{ vars.JF_URL }}
        JF_GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        oidc-provider-name: <OIDC_PROVIDER_NAME>
        ghe-base-url: https://<GITHUB_ENTERPRISE_SERVER>/api/v3

    Where:

    • <OIDC_PROVIDER_NAME>: The OIDC provider name configured in JFrog
    • <GITHUB_ENTERPRISE_SERVER>: The hostname of your GitHub Enterprise Server
  2. Enable code scanning on the GitHub Enterprise Server and on the repository.

If the server rejects the upload, the post step logs a warning that starts with Failed populating code scanning sarif and doesn't fail the job.

Upload Results with the JFrog GitHub App

On JFrog SaaS, JFrog Xray can upload build scan results through the JFrog GitHub App. JFrog Advanced Security exposures and GitHub App build scanning must be enabled, and the build's version-control URL must be on github.com.

To upload results with the JFrog GitHub App:

  1. Install the JFrog GitHub App on the repository.
  2. Run a JFrog Xray build-info scan.

Verify the Upload

After the GitHub Actions post step uploads final.sarif, confirm the result in the job log and in GitHub.

To verify the GitHub Actions SARIF upload:

  1. In the job log, look for SARIF file uploaded successfully.
  2. In GitHub, go to Security > Code scanning alerts and review the findings for the same commit.

Troubleshoot

Use the following checks when the upload doesn't show a code scanning alert.

SymptomWhat to Check
No token provided for uploading code scanning sarif files.Set JF_GIT_TOKEN and grant security-events: write.
No code scanning sarif file was found.Confirm the scan command generates final.sarif before the post step.
GitHub accepts the upload but no alert is visible.Confirm code scanning is enabled for the repository and that you're viewing the uploaded commit.

Related Topics


Did this page help you?