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.
- Upload Scan Results
- Set the GitHub Enterprise Server Base URL
- Upload Results with the JFrog GitHub App
- Verify the Upload
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 CLI2.67.0or newer, and a JFrog scan that writesfinal.sarifunder the JFrog CLI security summary directory.JF_GIT_TOKENset to a GitHub token withsecurity_events: writeandcontents: readpermissions. Don't print the token.JF_URLand 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:
-
Add
jfrog/setup-jfrog-cli@v5and setJF_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
-
Grant the workflow token permission to write security events.
permissions: id-token: write contents: read security-events: write -
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 successfullySet 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:
-
Pass the full REST API base URL, including
/api/v3, withghe-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/v3Where:
<OIDC_PROVIDER_NAME>: The OIDC provider name configured in JFrog<GITHUB_ENTERPRISE_SERVER>: The hostname of your GitHub Enterprise Server
-
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:
- Install the JFrog GitHub App on the repository.
- 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:
- In the job log, look for
SARIF file uploaded successfully. - 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.
| Symptom | What 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
Updated 12 days ago
