Skip to content

Commit a8471de

Browse files
mbolognaclaude
andcommitted
fix: replace anchore/scan-action with manual grype install to fix stale DB
Root cause: anchore/scan-action@v4 internally uses actions/cache to restore the Grype vulnerability DB. This cache restore happens *inside* the action, after our "Clear stale Grype DB cache" step had already run. As a result, the stale DB (built >5 days ago) was always restored before grype executed, causing: db could not be loaded: the vulnerability database was built 1 week ago (max allowed age is 5 days) With no DB available, grype produced no SARIF output, which then caused a second failure at the upload step: Invalid SARIF. JSON syntax error: Unexpected end of JSON input Fix: drop anchore/scan-action@v4 entirely and replace with three explicit steps: 1. Install grype via the official install script 2. Run `grype db update` to force a fresh DB download (no cache involved) 3. Run grype manually, writing SARIF directly to grype-results.sarif This also eliminates the now-unnecessary "Move Grype results" step, which only existed to rename the action's hardcoded output filename. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 5d04bd7 commit a8471de

1 file changed

Lines changed: 7 additions & 17 deletions

File tree

.github/workflows/build-scan-push.yml

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -178,30 +178,20 @@ jobs:
178178
severity: CRITICAL,HIGH,MEDIUM
179179
timeout: 10m
180180

181-
- name: Clear stale Grype DB cache
181+
- name: Install Grype
182182
if: matrix.scanner == 'grype'
183-
run: rm -rf ~/.cache/grype/db
183+
run: curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /usr/local/bin
184184

185-
- name: Run Grype vulnerability scanner
185+
- name: Update Grype DB
186186
if: matrix.scanner == 'grype'
187-
uses: anchore/scan-action@v4
188-
continue-on-error: true
189-
with:
190-
image: ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:latest
191-
fail-build: false
192-
severity-cutoff: high
193-
output-format: sarif
187+
run: grype db update
194188

195-
- name: Move Grype results
189+
- name: Run Grype vulnerability scanner
196190
if: matrix.scanner == 'grype'
197191
continue-on-error: true
198192
run: |
199-
if [ -f results.sarif ]; then
200-
mv results.sarif grype-results.sarif
201-
else
202-
echo "Grype results file not found"
203-
exit 1
204-
fi
193+
grype "${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:latest" \
194+
-o sarif > grype-results.sarif
205195
206196
- name: Upload SARIF to GitHub Security
207197
if: always() && hashFiles(format('{0}-results.sarif', matrix.scanner)) != ''

0 commit comments

Comments
 (0)