-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c864cb9
commit a81d60f
Showing
1 changed file
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: Jenkins Security Scan | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
java-version: | ||
description: Version of Java set up for the build. See actions/setup-java documentation for values. | ||
type: string | ||
required: true | ||
java-cache: | ||
description: What kind of Java dependency cache to set up. See actions/setup-java documentation for values. | ||
type: string | ||
required: false | ||
|
||
permissions: | ||
security-events: write | ||
|
||
# Private repo support | ||
contents: read # For actions/checkout | ||
actions: read # For github/codeql-action/upload-sarif | ||
|
||
jobs: | ||
scan: | ||
runs-on: ubuntu-latest # Provides `jq` | ||
steps: | ||
- name: Check out plugin | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Java | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'temurin' | ||
java-version: ${{ inputs.java-version }} | ||
cache: ${{ inputs.java-cache }} | ||
|
||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v3 | ||
with: | ||
languages: java | ||
config: | | ||
disable-default-queries: true | ||
packs: | ||
- jenkins-infra/[email protected] | ||
- codeql/java-queries:AlertSuppression.ql | ||
- codeql/java-queries:AlertSuppressionAnnotations.ql | ||
- name: Autobuild | ||
uses: github/codeql-action/autobuild@v3 | ||
|
||
- name: Run CodeQL | ||
id: generate-sarif | ||
uses: github/codeql-action/analyze@v3 | ||
with: | ||
category: Jenkins Security Scan | ||
upload: failure-only | ||
|
||
- name: Process SARIF | ||
# Process the generated SARIF file: | ||
# 1. Prevent conflicts with otherwise set up CodeQL scan by renaming the tool driver | ||
# 2. Remove suppressed warnings because GitHub Code Scanning does not support inline suppressions | ||
run: | | ||
jq 'setpath(path(.runs[].tool.driver.name); "Jenkins Security Scan") | setpath(path(.runs[].tool.driver.organization); "Jenkins Project") | del(.runs[].results[] | select( .suppressions | length != 0 ))' ../results/java.sarif > jenkins-security-scan.sarif | ||
mv -v ../results/java.sarif . | ||
- name: Archive SARIF | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
path: '*.sarif' | ||
name: Jenkins Security Scan SARIF | ||
|
||
- name: Upload Scan Result | ||
uses: github/codeql-action/upload-sarif@v3 | ||
with: | ||
sarif_file: jenkins-security-scan.sarif | ||
category: Jenkins Security Scan |