Skip to content

Commit feb5e49

Browse files
ergoushaErgin Akin
andauthored
fix: disable osv-scanner Go call analysis to prevent OOM kills (#457)
osv-scanner runs govulncheck based Go call analysis by default. That step type checks the whole build graph and requires more than 8GB of memory on moderately sized modules, which gets the scan OOM killed with exit code 137. Measured with osv-scanner v2.5.1 against a 346 package go.mod: osv-scanner --lockfile go.mod 7.6GB 105s osv-scanner --no-call-analysis=go --lockfile go.mod 73MB 1.9s The reported vulnerabilities are identical with and without call analysis, as it only adds reachability annotations that this action does not act on. Set OSV_SCANNER_CALL_ANALYSIS to true to re-enable it. Closes #456 Co-authored-by: Ergin Akin <eakin@scubergphilis.com>
1 parent 128db79 commit feb5e49

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

build/task.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ vars:
7272
OSV_SCANNER_VERSION_WITHOUT_V_PREFIX: # the version found by the package-version-updater contains a 'v' prefix
7373
sh: echo {{.OSV_SCANNER_VERSION}} | sed -e "s|v||"
7474
OSV_SCANNER_BIN: "{{.GOBIN}}/osv-scanner"
75+
OSV_SCANNER_CALL_ANALYSIS: '{{.OSV_SCANNER_CALL_ANALYSIS | default "false"}}'
76+
# govulncheck based Go call analysis type checks the whole build graph and can
77+
# consume more than 8GB, causing the scan to be OOM killed (exit code 137).
78+
OSV_SCANNER_CALL_ANALYSIS_FLAG: '{{if eq .OSV_SCANNER_CALL_ANALYSIS "true"}}--call-analysis=go{{else}}--no-call-analysis=go{{end}}'
7579
OSV_SCANNER_OUTPUT: /tmp/osv-scanner.txt
7680
GQLGEN_VERSION: v0.17.94
7781
GQLGEN_BIN: "{{.GOBIN}}/gqlgen"
@@ -375,6 +379,7 @@ tasks:
375379
echo "Running osv-scanner scan..."
376380
# Run osv-scanner and capture output, allow it to fail
377381
{{.OSV_SCANNER_BIN}} \
382+
{{.OSV_SCANNER_CALL_ANALYSIS_FLAG}} \
378383
--lockfile go.mod \
379384
> {{.OSV_SCANNER_OUTPUT}} 2>&1 || scan_exit_code=$?
380385
@@ -398,6 +403,7 @@ tasks:
398403
echo "Found osv-scanner.toml configuration file."
399404
echo "Re-running scan with ignore configuration..."
400405
{{.OSV_SCANNER_BIN}} \
406+
{{.OSV_SCANNER_CALL_ANALYSIS_FLAG}} \
401407
--config osv-scanner.toml \
402408
--lockfile go.mod \
403409
> {{.OSV_SCANNER_OUTPUT}} 2>&1 || final_exit_code=$?

docs/osv-scanner.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,29 @@ reason = "False positive - not applicable to our usage"
3939
- Review and update the ignore list regularly
4040
- Ignored vulnerabilities should be temporary - aim to fix or update dependencies
4141

42+
## Call Analysis
43+
44+
By default osv-scanner runs govulncheck based Go call analysis, which type checks
45+
the whole build graph. On larger modules this requires more than 8GB of memory and
46+
the process is OOM killed by the runner (exit code 137, output ends with
47+
`Killed`). As the reported vulnerabilities are identical with and without it,
48+
call analysis is disabled in this action.
49+
50+
Set `OSV_SCANNER_CALL_ANALYSIS` to `true` to re-enable it, and make sure enough
51+
memory is available:
52+
53+
```yaml
54+
jobs:
55+
mcvs-golang-action:
56+
runs-on: ubuntu-24.04
57+
env:
58+
OSV_SCANNER_CALL_ANALYSIS: "true"
59+
steps:
60+
- uses: schubergphilis/mcvs-golang-action@vX.Y.Z
61+
with:
62+
testing-type: security-golang-modules
63+
```
64+
4265
## Additional Resources
4366
4467
- [osv-scanner GitHub Repository](https://github.com/google/osv-scanner)

0 commit comments

Comments
 (0)