mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-29 06:17:25 +00:00
Merge pull request #2904 from infinito-nexus/fix/ci/vulnerability-db-download-retry
fix(ci): retry a failed vulnerability database restore once
This commit is contained in:
3 files changed
+43
-6
No files matched your search
@@ -326,7 +326,7 @@ without opening the job.
|
||||
|
||||
The vulnerability engine is the odometer digit above distro and filesystem, and its glyph follows the architecture glyph in the label (`🐳🧅🌀🦓🦾🔺`).
|
||||
The deploy-time scan of `sys-ctl-hlth-runtime` then runs Syft and that engine only, plus Grype over the source-built runtimes Syft finds.
|
||||
The `vulnerability-db` job of [call-test-deploy.yml](call-test-deploy.yml) downloads the Trivy, Grype and OSV databases once per day into the Actions cache; each deploy job restores the Grype database and the drawn engine's into `build/vulnerability-db`, which the stack and every swarm node mount read-only, and fails when one is missing, so no deploy job downloads a database itself.
|
||||
The `vulnerability-db` job of [call-test-deploy.yml](call-test-deploy.yml) downloads the Trivy, Grype and OSV databases once per day into the Actions cache; each deploy job restores the Grype database and the drawn engine's into `build/vulnerability-db`, which the stack and every swarm node mount read-only. A failed restore gets one more attempt with a fresh download URL, and the job fails when a database is still missing, so no deploy job downloads a database itself.
|
||||
Under act these steps are skipped: the deploy draws its engine and refreshes the shared host directory `INFINITO_VULNERABILITY_DB_HOST_PATH`, which [workflow.sh](../../scripts/tests/deploy/act/workflow.sh) binds into the job container at the same path.
|
||||
`cron-images-mirror-all.yml` writes the findings of its `scan` job per image and per CVE into the job summary and the `vulnerability-findings` artifact; dispatched with `issues: false` it is a dry run that leaves the issues untouched.
|
||||
|
||||
|
||||
@@ -418,14 +418,32 @@ jobs:
|
||||
run: nohup ./scripts/tests/deploy/ci/host-metrics-sampler.sh "${INFINITO_RESCUE_DIAGNOSTICS_BASE}/host-metrics.log" >/dev/null 2>&1 &
|
||||
|
||||
- name: "🍇 Restore the Grype database"
|
||||
id: grype_db
|
||||
if: ${{ !env.ACT && matrix.engine != '' }}
|
||||
continue-on-error: true
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: vulnerability-db-${{ inputs.index }}-grype
|
||||
path: build/vulnerability-db/grype
|
||||
|
||||
- name: "🍇 Retry the Grype database restore"
|
||||
if: ${{ steps.grype_db.outcome == 'failure' }}
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: vulnerability-db-${{ inputs.index }}-grype
|
||||
path: build/vulnerability-db/grype
|
||||
|
||||
- name: "🔬 Restore the ${{ matrix.engine }} database"
|
||||
id: engine_db
|
||||
if: ${{ !env.ACT && matrix.engine != '' && matrix.engine != 'grype' }}
|
||||
continue-on-error: true
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: vulnerability-db-${{ inputs.index }}-${{ matrix.engine }}
|
||||
path: build/vulnerability-db/${{ matrix.engine }}
|
||||
|
||||
- name: "🔬 Retry the ${{ matrix.engine }} database restore"
|
||||
if: ${{ steps.engine_db.outcome == 'failure' }}
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: vulnerability-db-${{ inputs.index }}-${{ matrix.engine }}
|
||||
|
||||
@@ -109,16 +109,35 @@ class TestDatabaseHandover(unittest.TestCase):
|
||||
sorted(f"{HANDOVER}{engine}" for engine in SCANNERS),
|
||||
)
|
||||
|
||||
def _attempts(self) -> dict[str, list[dict]]:
|
||||
attempts: dict[str, list[dict]] = {}
|
||||
for step in self.jobs["deploy"]["steps"]:
|
||||
name = step.get("with", {}).get("name", "")
|
||||
if step.get("uses", "").startswith("actions/download") and name.startswith(
|
||||
HANDOVER
|
||||
):
|
||||
attempts.setdefault(name, []).append(step)
|
||||
return attempts
|
||||
|
||||
def test_a_deploy_downloads_what_the_run_handed_over(self) -> None:
|
||||
self.assertEqual(
|
||||
sorted(
|
||||
args["name"]
|
||||
for args in self._with("deploy", "download")
|
||||
if args.get("name", "").startswith(HANDOVER)
|
||||
),
|
||||
sorted(self._attempts()),
|
||||
[f"{HANDOVER}${{{{ matrix.engine }}}}", f"{HANDOVER}grype"],
|
||||
)
|
||||
|
||||
def test_a_failed_download_gets_exactly_one_more_attempt(self) -> None:
|
||||
for name, attempts in self._attempts().items():
|
||||
with self.subTest(name=name):
|
||||
self.assertEqual(len(attempts), 2)
|
||||
first, last = attempts
|
||||
self.assertIs(first.get("continue-on-error"), True)
|
||||
self.assertEqual(
|
||||
last.get("if"),
|
||||
f"${{{{ steps.{first.get('id')}.outcome == 'failure' }}}}",
|
||||
)
|
||||
self.assertNotIn("continue-on-error", last)
|
||||
self.assertEqual(last["with"], first["with"])
|
||||
|
||||
def test_the_osv_cache_key_follows_the_ecosystem_list(self) -> None:
|
||||
osv = next(
|
||||
step
|
||||
|
||||
Reference in new issue
Block a user