Skip to content

Commit e69fb00

Browse files
authored
fix(sca): grype db should be downloaded at least daily (#324)
In case in a repo we are not over the 10GB limit for GitHub actions cache the database never gets updated. This patch makes sure to use a cache key that is day specific to force one fetch per day.
1 parent ba5f614 commit e69fb00

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

security-actions/sca/action.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,21 @@ runs:
162162
env:
163163
grype: ${{ steps.grype.outputs.grype-path }}
164164

165+
- name: Get current date
166+
id: date
167+
shell: bash
168+
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
169+
165170
# Explicitly check for Grype DB in Git Cache
166171
- name: Check Git Cache for Grype DB
167172
id: grype_db_git_cache
168173
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
169174
with:
170175
# Grype cache files are stored in `~/.cache/grype/db` on Linux/macOS
171176
path: ~/.cache/grype/db
177+
# Given the DB should not be less than 5 days old let's refetch it at least once per day
172178
key: |
173-
cache_grype_db_v${{ steps.grype_metadata.outputs.grype_db_schema }}
179+
cache_grype_db_v${{ steps.grype_metadata.outputs.grype_db_schema }}_${{ steps.date.outputs.date }}
174180
175181
# Explicitly check for Grype DB in specified mirror
176182
- name: Parse Grype DB cache input
@@ -334,4 +340,4 @@ runs:
334340
severity-cutoff: ${{ steps.meta.outputs.global_severity_cutoff }}
335341
grype-version: ${{ steps.grype_install.outputs.grype_version }}
336342
env:
337-
GRYPE_DB_AUTO_UPDATE: false # Use grype db cache from grype step above
343+
GRYPE_DB_AUTO_UPDATE: false # Use grype db cache from grype step above

0 commit comments

Comments
 (0)