Repository navigation
security: OSV-Scanner on pull requests and weekly, a GitHub button, Fyne 2.8.2 #181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d67de64
1464ee7
735ca61
ee01872
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| # Blocks a pull request that brings in a vulnerability the main branch does not | ||
| # already have, by any package manifest in the tree - go.mod and the pinned | ||
| # Python packages the semgrep job installs. | ||
| # | ||
| # The owner's decision of 2026-10-14: a pull request is stopped only for what it | ||
| # adds. What main already carries is reported once a week to the Security tab by | ||
| # osv-weekly.yml, and does not hold up a change that did not cause it. | ||
| # | ||
| # How it tells the two apart. The tree is scanned twice, first as the branch it | ||
| # merges into and then as the merge itself, and the reporter compares the two | ||
| # results - the method of the action's own pull request workflow. That workflow | ||
| # is not called as it is, because it keeps the job token in the checkout to | ||
| # switch branches and asks for security-events: write to upload. Neither is | ||
| # needed: the base is the first parent of the merge commit, which a fetch depth | ||
| # of two already holds, and a pull request has nothing to upload. | ||
| # | ||
| # Next to the two gates that already read the same go.mod. "review new | ||
| # dependencies" looks only at what the diff adds and only through GitHub's | ||
| # advisories. "known vulnerabilities" is govulncheck, which counts only what our | ||
| # code can reach. This one reads OSV, which also covers the Python packages, and | ||
| # counts a vulnerable package whether or not anything calls it - see | ||
| # --no-call-analysis below. | ||
| name: OSV pull request | ||
|
|
||
| on: | ||
| pull_request: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| # A push to the pull request makes the run before it pointless, and each run | ||
| # scans the tree twice. The same grouping as dev-build.yml. | ||
| concurrency: | ||
| group: osv-pull-request-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| scan: | ||
| name: new vulnerabilities (OSV) | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
| steps: | ||
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| # The merge commit and its two parents, the first of which is the | ||
| # branch this pull request merges into. | ||
| fetch-depth: 2 | ||
| persist-credentials: false | ||
|
|
||
| # Asserted rather than assumed, from the review of #181: with a commit | ||
| # of one parent here, HEAD^1 would be the pull request's own previous | ||
| # commit, and the comparison would find nothing new for the wrong reason. | ||
| - name: the branch this merges into | ||
| run: | | ||
| parents=$(git rev-list --parents -n 1 HEAD | wc -w) | ||
| if [ "$parents" -ne 3 ]; then | ||
| echo "::error::The checkout is not the merge commit of this pull request ($((parents - 1)) parent(s)), so there is no base to compare against." | ||
| exit 1 | ||
| fi | ||
| git checkout --quiet --detach HEAD^1 | ||
|
|
||
| # The scanner exits 1 when it finds something and with another code when | ||
| # it cannot scan at all, and the step cannot tell the two apart. The | ||
| # results file can, and the check further down reads it. | ||
| # | ||
| # --no-call-analysis=go because it cannot work here and fails loudly | ||
| # when tried. It compiles the tree, and this tree refuses to compile | ||
| # without the tags in .github/build-tags and a C compiler with the | ||
| # headers of the window's toolkit, neither of which the scanner's image | ||
| # carries. Measured 2026-10-14: hundreds of compile errors in the log, and | ||
| # every Go advisory reported as if called anyway. Whether a vulnerable | ||
| # function is reachable is what the govulncheck job answers. | ||
| - name: scan the branch this merges into | ||
| id: old | ||
| uses: google/osv-scanner-action/osv-scanner-action@a345acffa64b0eaede81a3d9aae6141214d9c8fc # v2.6.0 | ||
| continue-on-error: true | ||
| with: | ||
| scan-args: |- | ||
| --format=json | ||
| --output=osv-old.json | ||
| --no-call-analysis=go | ||
| --recursive | ||
| ./ | ||
|
|
||
| - name: the merge of this pull request | ||
| env: | ||
| MERGE: ${{ github.sha }} | ||
| run: git checkout --quiet --force --detach "$MERGE" | ||
|
|
||
| - name: scan the merge of this pull request | ||
| id: new | ||
| uses: google/osv-scanner-action/osv-scanner-action@a345acffa64b0eaede81a3d9aae6141214d9c8fc # v2.6.0 | ||
| continue-on-error: true | ||
| with: | ||
| scan-args: |- | ||
| --format=json | ||
| --output=osv-new.json | ||
| --no-call-analysis=go | ||
| --recursive | ||
| ./ | ||
|
|
||
| # Both files, whatever the scan steps returned. The reporter reads a file | ||
| # it cannot parse as one with no findings - measured 2026-10-14 on | ||
| # v2.6.0, from the review of #181: thirty findings cut short came out | ||
| # "No issues found", exit 0, and so did a missing file. Only a whole | ||
| # result goes on to be compared. | ||
| - name: both scans wrote a whole result | ||
| run: | | ||
| status=0 | ||
| for f in osv-old.json osv-new.json; do | ||
| if ! jq -e '.results | type == "array"' "$f" > /dev/null 2>&1; then | ||
| echo "::error::$f is missing or is not a whole scan result, so the scan did not complete. Read the scan steps above for the cause." | ||
| status=1 | ||
| fi | ||
| done | ||
| exit "$status" | ||
|
|
||
| # Fails the job on anything in the second scan that is not in the first. | ||
| # The log of this step is the list: every finding with its package, the | ||
| # advisory and the version that fixes it. The annotations on the pull | ||
| # request are not - measured 2026-10-14 with findings in two files, one | ||
| # annotation came out, for one of them. | ||
| - name: what this pull request adds | ||
| uses: google/osv-scanner-action/osv-reporter-action@a345acffa64b0eaede81a3d9aae6141214d9c8fc # v2.6.0 | ||
| with: | ||
| scan-args: |- | ||
| --old=osv-old.json | ||
| --new=osv-new.json | ||
| --output=osv-new.sarif | ||
| --gh-annotations=true | ||
| --fail-on-vuln=true | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,99 @@ | ||||||||||||||||||||||||||
| # Once a week, every known vulnerability in what the main branch depends on, | ||||||||||||||||||||||||||
| # into the Security tab of the repository. | ||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||
| # The other half of osv-pull-request.yml. A pull request is stopped only for | ||||||||||||||||||||||||||
| # what it adds, by the owner's decision of 2026-10-14, so a vulnerability that | ||||||||||||||||||||||||||
| # was published against something main already uses has to show up somewhere | ||||||||||||||||||||||||||
| # else - and that place is here. Weekly because an advisory is published on | ||||||||||||||||||||||||||
| # its own schedule, not on ours: a tree nobody touches for a month still gets | ||||||||||||||||||||||||||
| # new findings. | ||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||
| # The run is red while anything is found, and the results go up either way. A | ||||||||||||||||||||||||||
| # clean upload is what closes the alerts of the week before, so an upload that | ||||||||||||||||||||||||||
| # happened only on findings would leave fixed alerts open for ever. Red so that | ||||||||||||||||||||||||||
| # a finding is also a failed run with a notice, rather than a line in a tab | ||||||||||||||||||||||||||
| # somebody has to remember to open. | ||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||
| # The same scanner and the same arguments as the pull request workflow, so the | ||||||||||||||||||||||||||
| # two cannot come to disagree about what counts. The reasons for each argument | ||||||||||||||||||||||||||
| # are written there. | ||||||||||||||||||||||||||
| name: OSV weekly | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||
| schedule: | ||||||||||||||||||||||||||
| # Monday 05:17 UTC, an hour after the weekly fuzzing in ci.yml. | ||||||||||||||||||||||||||
| - cron: "17 5 * * 1" | ||||||||||||||||||||||||||
| # By hand, from the Actions tab, after a fix is merged and before the next | ||||||||||||||||||||||||||
| # Monday - the alerts it closes close on the next upload. | ||||||||||||||||||||||||||
| workflow_dispatch: | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # A run by hand while the Monday one is going waits for it rather than | ||||||||||||||||||||||||||
| # uploading beside it. Not cancelled: each run is a whole scan worth keeping. | ||||||||||||||||||||||||||
| concurrency: | ||||||||||||||||||||||||||
| group: osv-weekly | ||||||||||||||||||||||||||
| cancel-in-progress: false | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||
| contents: read | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||
| scan: | ||||||||||||||||||||||||||
| name: vulnerabilities in main (OSV) | ||||||||||||||||||||||||||
| # By hand from another branch it would scan and upload that branch, and | ||||||||||||||||||||||||||
| # this workflow is about main. From the review of #181. | ||||||||||||||||||||||||||
| if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) | ||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||
| timeout-minutes: 15 | ||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||
| contents: read | ||||||||||||||||||||||||||
| # The upload to the Security tab. Granted to this job only and to nothing | ||||||||||||||||||||||||||
| # a pull request runs. | ||||||||||||||||||||||||||
| security-events: write | ||||||||||||||||||||||||||
| # Read by the upload to name the run it belongs to - the action's own | ||||||||||||||||||||||||||
| # workflow grants it for the same step (github/codeql-action issue 2117). | ||||||||||||||||||||||||||
| actions: read | ||||||||||||||||||||||||||
|
Comment on lines
+47
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value 🔎 Supported by static analysis🏁 Script executed: set -eu
printf '%s\n' '--- workflow ---'
nl -ba .github/workflows/osv-weekly.yml
printf '%s\n' '--- zizmor references/config ---'
rg -n -i --hidden --glob '!vendor/**' --glob '!node_modules/**' 'zizmor|undocumented-permissions|permissions:' .github . 2>/dev/null || true
printf '%s\n' '--- diff against stated base ---'
git diff --no-ext-diff --unified=80 a3e0893d393da7dbcd002d266f39edb93dbb9749 d67de644326fc116be792c67aa5a34966297c321 -- .github/workflows/osv-weekly.ymlRepository: donislawdev/TestingFilesGenerator Length of output: 9675 🌐 Web query:
💡 Result: Document non- The The workflow-level Suggested fix--- "a/.github/workflows/osv-weekly.yml"
+++ "b/.github/workflows/osv-weekly.yml"
@@ -35,14 +35,10 @@
name: vulnerabilities in main (OSV)
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
- # The upload to the Security tab. Granted to this job only and to nothing
- # a pull request runs.
- security-events: write
- # Read by the upload to name the run it belongs to - the action's own
- # workflow grants it for the same step (github/codeql-action issue 2117).
- actions: read
+ security-events: write # Upload to the Security tab.
+ actions: read # Allow the upload action to name the workflow run.
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:📝 Committable suggestion
Suggested change
🧰 Tools🪛 zizmor (1.30.1)[warning] 42-42: permissions without explanatory comments (undocumented-permissions): needs an explanatory comment (undocumented-permissions) 🤖 Prompt for AI AgentsSource: Linters/SAST tools
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not changed. This repository explains a permission in a comment above the line, as release.yml does for id-token and attestations, and zizmor does not run in its CI. 🤖 Addressed by Claude Code |
||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||
| persist-credentials: false | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| - name: scan | ||||||||||||||||||||||||||
| id: scan | ||||||||||||||||||||||||||
| uses: google/osv-scanner-action/osv-scanner-action@a345acffa64b0eaede81a3d9aae6141214d9c8fc # v2.6.0 | ||||||||||||||||||||||||||
| continue-on-error: true | ||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||
| scan-args: |- | ||||||||||||||||||||||||||
| --format=json | ||||||||||||||||||||||||||
| --output=osv-results.json | ||||||||||||||||||||||||||
| --no-call-analysis=go | ||||||||||||||||||||||||||
| --recursive | ||||||||||||||||||||||||||
| ./ | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Whatever the scan step returned. The reporter reads a file it cannot | ||||||||||||||||||||||||||
| # parse as one with no findings and writes a clean SARIF from it - | ||||||||||||||||||||||||||
| # measured 2026-10-14 on v2.6.0 - and a clean upload closes every alert. | ||||||||||||||||||||||||||
| - name: the scan wrote a whole result | ||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||
| if ! jq -e '.results | type == "array"' osv-results.json > /dev/null 2>&1; then | ||||||||||||||||||||||||||
| echo "::error::osv-results.json is missing or is not a whole scan result, so the scan did not complete and nothing is uploaded. Read the scan step above for the cause." | ||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Writes the results for the Security tab and fails the job when there | ||||||||||||||||||||||||||
| # is any, which is after the file is written - the upload below runs | ||||||||||||||||||||||||||
| # either way. | ||||||||||||||||||||||||||
| - name: results for the Security tab | ||||||||||||||||||||||||||
| uses: google/osv-scanner-action/osv-reporter-action@a345acffa64b0eaede81a3d9aae6141214d9c8fc # v2.6.0 | ||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||
| scan-args: |- | ||||||||||||||||||||||||||
| --new=osv-results.json | ||||||||||||||||||||||||||
| --output=osv-results.sarif | ||||||||||||||||||||||||||
| --gh-annotations=false | ||||||||||||||||||||||||||
| --fail-on-vuln=true | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| - name: upload to the Security tab | ||||||||||||||||||||||||||
| if: ${{ !cancelled() && hashFiles('osv-results.sarif') != '' }} | ||||||||||||||||||||||||||
| uses: github/codeql-action/upload-sarif@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2 | ||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||
| sarif_file: osv-results.sarif | ||||||||||||||||||||||||||
| category: osv-scanner | ||||||||||||||||||||||||||
|
donislawdev marked this conversation as resolved.
|
||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.