Skip to content

Commit 152fe3e

Browse files
QualitySecurityPaperclip-Paperclip
andcommitted
ci(security): skip osv-scanner when there are no manifests
osv-scanner exits non-zero with "No package sources found, --help for usage information" when run against a tree with no dependency manifests. That's what happened on common's main: no go.mod, so the scan failed even though there was nothing to find. Gate the osv-scanner steps behind a go.mod detection, mirroring the govulncheck and license-policy jobs. If the org ever adopts non-Go projects, broaden the detector to match package.json / Cargo.toml / requirements.txt. Refs QUA-7. Co-Authored-By: Paperclip <[email protected]>
1 parent 94d71e1 commit 152fe3e

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

.github/workflows/security.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,33 @@ jobs:
5858
- name: Checkout
5959
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
6060

61+
- name: Detect Go module
62+
id: detect
63+
run: |
64+
# osv-scanner exits non-zero with "No package sources found" if there is
65+
# nothing to scan. The quantcli org is Go-only today, so gate on go.mod.
66+
# If a non-Go manifest (package.json, requirements.txt, Cargo.toml, …) is
67+
# ever introduced, broaden this check.
68+
if [ -f go.mod ]; then
69+
echo "has_manifests=true" >> "$GITHUB_OUTPUT"
70+
else
71+
echo "has_manifests=false" >> "$GITHUB_OUTPUT"
72+
echo "::notice::No go.mod found; skipping osv-scanner."
73+
fi
74+
6175
- name: Set up Go
76+
if: steps.detect.outputs.has_manifests == 'true'
6277
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
6378
with:
6479
go-version: stable
6580
cache: false
6681

6782
- name: Install osv-scanner
83+
if: steps.detect.outputs.has_manifests == 'true'
6884
run: go install github.com/google/osv-scanner/v2/cmd/osv-scanner@latest
6985

7086
- name: Run osv-scanner
87+
if: steps.detect.outputs.has_manifests == 'true'
7188
run: osv-scanner scan source --recursive .
7289

7390
license-policy:

0 commit comments

Comments
 (0)