|
23 | 23 | with: |
24 | 24 | persist-credentials: false |
25 | 25 |
|
26 | | - - uses: actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b # v2.1.1 |
27 | | - id: create-token |
28 | | - with: |
29 | | - # analyzing classic branch protections requires a token with admin read permissions |
30 | | - # see https://github.com/ossf/scorecard-action/blob/main/docs/authentication/fine-grained-auth-token.md |
31 | | - # and https://github.com/open-telemetry/community/issues/2769 |
32 | | - app-id: ${{ vars.OSSF_SCORECARD_APP_ID }} |
33 | | - private-key: ${{ secrets.OSSF_SCORECARD_PRIVATE_KEY }} |
34 | | - |
35 | 26 | - uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2 |
36 | 27 | with: |
37 | | - repo_token: ${{ steps.create-token.outputs.token }} |
38 | 28 | results_file: results.sarif |
39 | 29 | results_format: sarif |
40 | 30 | publish_results: true |
|
49 | 39 | path: results.sarif |
50 | 40 | retention-days: 5 |
51 | 41 |
|
| 42 | + - name: "Filter SARIF results" |
| 43 | + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 |
| 44 | + env: |
| 45 | + FILTER_RULES: BranchProtectionID, FuzzingID |
| 46 | + with: |
| 47 | + script: | |
| 48 | + const fs = require('fs'); |
| 49 | +
|
| 50 | + const rulesToFilter = process.env.FILTER_RULES.split(',').map(r => r.trim()); |
| 51 | + const sarif = JSON.parse(fs.readFileSync('results.sarif', 'utf8')); |
| 52 | +
|
| 53 | + sarif.runs.forEach(run => { |
| 54 | + run.tool.driver.rules = run.tool.driver.rules.filter(rule => |
| 55 | + !rulesToFilter.includes(rule.id) |
| 56 | + ); |
| 57 | + run.results = run.results.filter(result => |
| 58 | + !rulesToFilter.includes(result.ruleId) |
| 59 | + ); |
| 60 | + }); |
| 61 | +
|
| 62 | + fs.writeFileSync('filtered-results.sarif', JSON.stringify(sarif, null, 2)); |
| 63 | +
|
| 64 | + - name: "Upload artifact" |
| 65 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 66 | + with: |
| 67 | + name: Filtered SARIF file |
| 68 | + path: filtered-results.sarif |
| 69 | + retention-days: 5 |
| 70 | + |
52 | 71 | # Upload the results to GitHub's code scanning dashboard (optional). |
53 | 72 | # Commenting out will disable upload of results to your repo's Code Scanning dashboard |
54 | 73 | - name: "Upload to code-scanning" |
55 | 74 | uses: github/codeql-action/upload-sarif@192325c86100d080feab897ff886c34abd4c83a3 # v3.30.3 |
56 | 75 | with: |
57 | | - sarif_file: results.sarif |
| 76 | + sarif_file: filtered-results.sarif |
0 commit comments