Skip to content

Commit ec8fb0f

Browse files
committed
fix(release): accept current Grype database schema
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
1 parent 38c7291 commit ec8fb0f

4 files changed

Lines changed: 49 additions & 7 deletions

File tree

‎.github/workflows/release-candidate.yml‎

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -734,8 +734,18 @@ jobs:
734734
if ! jq -e '
735735
type == "object" and
736736
(.matches | type == "array") and
737-
(.descriptor.db.built | type == "string") and
738-
(.descriptor.db.checksum | type == "string")
737+
(
738+
(.descriptor.db.built // .descriptor.db.status.built)
739+
| type == "string"
740+
) and
741+
(
742+
(.descriptor.db.checksum | type == "string") or
743+
(
744+
.descriptor.db.status.from
745+
| type == "string" and
746+
test("checksum=sha256%3A[0-9a-fA-F]{64}")
747+
)
748+
)
739749
' "${report}" >/dev/null; then
740750
echo "Grype did not emit a complete scan report (exit ${status})" >&2
741751
exit 1
@@ -744,6 +754,22 @@ jobs:
744754
echo "::warning::Grype exited ${status}; enforcing its complete report through the reviewed advisory policy"
745755
fi
746756
}
757+
read_db_metadata() {
758+
local report="$1"
759+
jq -er '
760+
[
761+
(.descriptor.db.built // .descriptor.db.status.built),
762+
(
763+
.descriptor.db.checksum //
764+
(
765+
.descriptor.db.status.from
766+
| capture("checksum=sha256%3A(?<digest>[0-9a-fA-F]{64})").digest
767+
| ascii_downcase
768+
)
769+
)
770+
] | @tsv
771+
' "${report}"
772+
}
747773
for name in registry-notary registry-relay; do
748774
digest_ref="$(cat "inputs/build-a/dist/images/${name}.digest")"
749775
expected_label_args=()
@@ -779,8 +805,9 @@ jobs:
779805
echo "Exported rootfs ${name} contains a forbidden special file" >&2
780806
exit 1
781807
fi
782-
db_built="$(jq -er '.descriptor.db.built' "dist/candidate/dist/grype/${name}.grype.json")"
783-
db_checksum="$(jq -er '.descriptor.db.checksum' "dist/candidate/dist/grype/${name}.grype.json")"
808+
IFS=$'\t' read -r db_built db_checksum < <(
809+
read_db_metadata "dist/candidate/dist/grype/${name}.grype.json"
810+
)
784811
db_built_epoch="$(date -u -d "${db_built}" +%s)"
785812
now_epoch="$(date -u +%s)"
786813
if (( db_built_epoch > now_epoch || now_epoch - db_built_epoch > 259200 )); then
@@ -810,8 +837,9 @@ jobs:
810837
echo "Exported rootfs postgresql contains a forbidden special file" >&2
811838
exit 1
812839
fi
813-
db_built="$(jq -er '.descriptor.db.built' dist/candidate/dist/grype/postgresql.grype.json)"
814-
db_checksum="$(jq -er '.descriptor.db.checksum' dist/candidate/dist/grype/postgresql.grype.json)"
840+
IFS=$'\t' read -r db_built db_checksum < <(
841+
read_db_metadata dist/candidate/dist/grype/postgresql.grype.json
842+
)
815843
db_built_epoch="$(date -u -d "${db_built}" +%s)"
816844
now_epoch="$(date -u +%s)"
817845
if (( db_built_epoch > now_epoch || now_epoch - db_built_epoch > 259200 )); then

‎release/OPERATIONS.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ the separate repeatability workflow, not a second build in the blocking
3030
candidate path.
3131
Grype process status is not itself the advisory decision. The candidate first
3232
requires a complete scan report, then the reviewed advisory policy decides
33-
whether that report is acceptable.
33+
whether that report is acceptable. Database identity accepts both the legacy
34+
flat Grype descriptor and the nested descriptor emitted by the pinned Grype
35+
release.
3436

3537
The selector writes `registry-stack.release-proof-selection.v1` JSON into the
3638
candidate evidence.

‎release/scripts/check-gates-inventory.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,9 @@
649649
'digest_ref="$(cat "inputs/build-a/dist/images/${name}.digest")"',
650650
"scan_sbom() {",
651651
'(.matches | type == "array")',
652+
".descriptor.db.built // .descriptor.db.status.built",
653+
'test("checksum=sha256%3A[0-9a-fA-F]{64}")',
654+
"read_db_metadata() {",
652655
"Grype did not emit a complete scan report",
653656
"enforcing its complete report through the reviewed advisory policy",
654657
"name: Enforce advisory policy",

‎release/scripts/test_registry_release.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,15 @@ def test_release_image_scans_are_policy_enforced_and_preserved(self) -> None:
701701
self.assertIn("set +e", scan_body)
702702
self.assertIn('status=$?', scan_body)
703703
self.assertIn('(.matches | type == "array")', scan_body)
704+
self.assertIn(
705+
".descriptor.db.built // .descriptor.db.status.built",
706+
scan_body,
707+
)
708+
self.assertIn(
709+
'test("checksum=sha256%3A[0-9a-fA-F]{64}")',
710+
scan_body,
711+
)
712+
self.assertIn("read_db_metadata() {", scan_body)
704713
self.assertIn(
705714
"Grype did not emit a complete scan report",
706715
scan_body,

0 commit comments

Comments
 (0)