@@ -723,6 +723,27 @@ jobs:
723723 fi
724724 printf '%s\n' "${postgresql_ref}" \
725725 > dist/candidate/dist/images/postgresql.digest
726+ scan_sbom() {
727+ local sbom="$1"
728+ local report="$2"
729+ local status
730+ set +e
731+ grype "sbom:${sbom}" -o json > "${report}"
732+ status=$?
733+ set -e
734+ if ! jq -e '
735+ type == "object" and
736+ (.matches | type == "array") and
737+ (.descriptor.db.built | type == "string") and
738+ (.descriptor.db.checksum | type == "string")
739+ ' "${report}" >/dev/null; then
740+ echo "Grype did not emit a complete scan report (exit ${status})" >&2
741+ exit 1
742+ fi
743+ if (( status != 0 )); then
744+ echo "::warning::Grype exited ${status}; enforcing its complete report through the reviewed advisory policy"
745+ fi
746+ }
726747 for name in registry-notary registry-relay; do
727748 digest_ref="$(cat "inputs/build-a/dist/images/${name}.digest")"
728749 expected_label_args=()
@@ -745,8 +766,9 @@ jobs:
745766 "dist/candidate/dist/sbom/${name}.spdx.json" \
746767 --image-name "${name}" \
747768 --digest-ref "${digest_ref}"
748- grype "sbom:dist/candidate/dist/sbom/${name}.syft.json" -o json \
749- > "dist/candidate/dist/grype/${name}.grype.json"
769+ scan_sbom \
770+ "dist/candidate/dist/sbom/${name}.syft.json" \
771+ "dist/candidate/dist/grype/${name}.grype.json"
750772 mkdir -p "dist/candidate/dist/rootfs/${name}"
751773 crane export "${digest_ref}" - \
752774 | tar --extract --file=- --directory="dist/candidate/dist/rootfs/${name}" \
@@ -775,8 +797,9 @@ jobs:
775797 dist/candidate/dist/sbom/postgresql.spdx.json \
776798 --image-name postgresql \
777799 --digest-ref "${postgresql_ref}"
778- grype "sbom:dist/candidate/dist/sbom/postgresql.syft.json" -o json \
779- > dist/candidate/dist/grype/postgresql.grype.json
800+ scan_sbom \
801+ dist/candidate/dist/sbom/postgresql.syft.json \
802+ dist/candidate/dist/grype/postgresql.grype.json
780803 mkdir -p dist/candidate/dist/rootfs/postgresql
781804 crane export "${postgresql_ref}" - \
782805 | tar --extract --file=- --directory=dist/candidate/dist/rootfs/postgresql \
0 commit comments