# Transcript for 07-delivery/03-cicd-pipeline.md, hands-on steps 1 to 11. # Tier A: scanner images pinned by digest in ci/scan.sh, a kind cluster with a # Kubernetes v1.37.0 node, kubectl client v1.35.5 (the host's own). One Linux # machine. # Recorded by running the chapter's commands in order from full-guide/. The # cluster and node names are shown as `bookstore`, terminal colour codes are # removed and tabs are expanded to spaces. Nothing else is edited. ## step 1 $ pip install -q pre-commit==4.7.0 $ rm -rf /tmp/bookstore $ cp -R examples/bookstore /tmp/bookstore && rm -rf /tmp/bookstore/ci/fixtures # stands in for your repo $ (cd /tmp/bookstore && git init -q && git add -A && pre-commit run --all-files) gitleaks.................................................................Passed hadolint.................................................................Passed gosec....................................................................Passed $ (cd /tmp/bookstore && printf 'GITHUB_TOKEN=ghp_%s\n' "$(printf 'NOTAREALTOKEN%.0s' 1 2 3)" > .env && git add .env && pre-commit run gitleaks) $ rm -rf /tmp/bookstore gitleaks.................................................................Failed - hook id: gitleaks - exit code: 1 Finding: GITHUB_TOKEN=REDACTEDKEN Secret: REDACTED RuleID: github-pat Entropy: 3.290468 File: .env Line: 1 Fingerprint: .env:github-pat:1 9:00PM INF 0 commits scanned. 9:00PM INF scanned ~758617 bytes (758.62 KB) in 565ms 9:00PM WRN leaks found: 1 ## step 2 $ $scan gitleaks examples/bookstore/app $ $scan trufflehog examples/bookstore/app scan.sh: gitleaks clean on examples/bookstore/app scan.sh: trufflehog clean on examples/bookstore/app $ $scan gitleaks examples/bookstore/ci/fixtures/vulnerable; echo "exit $?" $ jq -r '.[] | "\(.RuleID) \(.File)"' scan-reports/gitleaks.json $ $scan trufflehog examples/bookstore/ci/fixtures/vulnerable scan.sh: gitleaks flagged examples/bookstore/ci/fixtures/vulnerable (exit 1, report scan-reports/gitleaks.json) exit 1 github-pat examples/bookstore/ci/fixtures/vulnerable/config.env scan.sh: trufflehog clean on examples/bookstore/ci/fixtures/vulnerable $ $scan --expect github-pat gitleaks examples/bookstore/ci/fixtures/vulnerable $ $scan --expect Github trufflehog examples/bookstore/ci/fixtures/vulnerable scan.sh: control ok, gitleaks reported github-pat on examples/bookstore/ci/fixtures/vulnerable scan.sh: control ok, trufflehog reported Github on examples/bookstore/ci/fixtures/vulnerable $ examples/bookstore/ci/fixtures/make-history.sh scan-out/history $ $scan gitleaks scan-out/history $ $scan gitleaks-history scan-out/history; echo "exit $?" scan.sh: gitleaks clean on scan-out/history scan.sh: gitleaks-history flagged scan-out/history (exit 1, report scan-reports/gitleaks-history.json) exit 1 $ $scan trufflehog-history scan-out/history $ $scan --expect github-pat gitleaks-history scan-out/history $ $scan --expect Github trufflehog-history scan-out/history scan.sh: trufflehog-history clean on scan-out/history scan.sh: control ok, gitleaks-history reported github-pat on scan-out/history scan.sh: control ok, trufflehog-history reported Github on scan-out/history ## step 3 $ $scan semgrep examples/bookstore/app $ $scan gosec examples/bookstore/app/catalog scan.sh: semgrep clean on examples/bookstore/app scan.sh: gosec clean on examples/bookstore/app/catalog $ $scan --expect bookstore-sql-string-concat semgrep examples/bookstore/ci/fixtures/vulnerable $ $scan --expect G202 gosec examples/bookstore/ci/fixtures/vulnerable $ jq -r '.Issues[] | "\(.rule_id) \(.details)"' scan-reports/gosec.json | sort -u scan.sh: control ok, semgrep reported bookstore-sql-string-concat on examples/bookstore/ci/fixtures/vulnerable scan.sh: control ok, gosec reported G202 on examples/bookstore/ci/fixtures/vulnerable G104 Errors unhandled G114 Use of net/http serve function that has no support for setting timeouts G124 http.Cookie missing or has insecure Secure, HttpOnly, or SameSite attribute G202 SQL string concatenation G204 Subprocess launched with a potential tainted input or cmd arguments G401 Use of weak cryptographic primitive G501 Blocklisted import crypto/md5: weak cryptographic primitive G701 SQL injection via taint analysis: (*database/sql.DB).Query G702 Command injection via taint analysis: os/exec.Command G705 XSS via taint analysis: fmt.Fprintf ## step 4 $ $scan govulncheck examples/bookstore/app/catalog $ $scan trivy-fs examples/bookstore/app/catalog scan.sh: govulncheck clean on examples/bookstore/app/catalog scan.sh: trivy-fs clean on examples/bookstore/app/catalog $ $scan --expect GO-2021-0113 govulncheck examples/bookstore/ci/fixtures/vulnerable $ grep -E 'GO-2021-0113|calls language' scan-reports/govulncheck.txt | head -4 $ $scan --expect CVE-2021-38561 trivy-fs examples/bookstore/ci/fixtures/vulnerable scan.sh: control ok, govulncheck reported GO-2021-0113 on examples/bookstore/ci/fixtures/vulnerable #1: main.go:21:45: vulnerable.main calls language.ParseAcceptLanguage Vulnerability #2: GO-2021-0113 More info: https://pkg.go.dev/vuln/GO-2021-0113 #1: main.go:21:45: vulnerable.main calls language.ParseAcceptLanguage scan.sh: control ok, trivy-fs reported CVE-2021-38561 on examples/bookstore/ci/fixtures/vulnerable ## step 5 $ docker build -q -t bookstore/catalog:dev examples/bookstore/app/catalog >/dev/null $ docker save -o scan-out/catalog.tar bookstore/catalog:dev $ $scan hadolint examples/bookstore/app/catalog/Dockerfile $ $scan dockle scan-out/catalog.tar scan.sh: hadolint clean on examples/bookstore/app/catalog/Dockerfile scan.sh: dockle clean on scan-out/catalog.tar $ docker build -q -t bookstore/vulnerable:fixture -f examples/bookstore/ci/fixtures/vulnerable/vulnerable.Dockerfile examples/bookstore/ci/fixtures/vulnerable >/dev/null $ docker save -o scan-out/vulnerable.tar bookstore/vulnerable:fixture $ $scan --expect DL3002 hadolint examples/bookstore/ci/fixtures/vulnerable/vulnerable.Dockerfile $ $scan --expect CIS-DI-0001 dockle scan-out/vulnerable.tar scan.sh: control ok, hadolint reported DL3002 on examples/bookstore/ci/fixtures/vulnerable/vulnerable.Dockerfile scan.sh: control ok, dockle reported CIS-DI-0001 on scan-out/vulnerable.tar ## step 6 $ $scan trivy-image scan-out/catalog.tar scan.sh: trivy-image clean on scan-out/catalog.tar $ $scan --expect CVE-2022-37434 trivy-image scan-out/vulnerable.tar scan.sh: control ok, trivy-image reported CVE-2022-37434 on scan-out/vulnerable.tar ## step 7 $ $scan syft scan-out/catalog.tar $ $scan grype scan-reports/sbom.cdx.json $ $scan trivy-sbom scan-reports/sbom.cdx.json scan.sh: syft clean on scan-out/catalog.tar scan.sh: grype clean on scan-reports/sbom.cdx.json scan.sh: trivy-sbom clean on scan-reports/sbom.cdx.json $ $scan syft scan-out/vulnerable.tar $ $scan --expect CVE-2021-38561 grype scan-reports/sbom.cdx.json $ $scan --expect CVE-2021-38561 trivy-sbom scan-reports/sbom.cdx.json scan.sh: syft clean on scan-out/vulnerable.tar scan.sh: control ok, grype reported CVE-2021-38561 on scan-reports/sbom.cdx.json scan.sh: control ok, trivy-sbom reported CVE-2021-38561 on scan-reports/sbom.cdx.json ## step 9 $ kubectl kustomize examples/bookstore/kustomize/overlays/prod > scan-reports/prod-overlay.yaml $ $scan kube-linter scan-reports/prod-overlay.yaml $ $scan kubesec scan-reports/prod-overlay.yaml $ $scan trivy-config scan-reports/prod-overlay.yaml scan.sh: kube-linter clean on scan-reports/prod-overlay.yaml scan.sh: kubesec clean on scan-reports/prod-overlay.yaml scan.sh: trivy-config clean on scan-reports/prod-overlay.yaml $ $scan --expect KSV-0017 trivy-config examples/bookstore/ci/fixtures/vulnerable/deployment.json $ $scan --expect privileged-container kube-linter examples/bookstore/ci/fixtures/vulnerable/deployment.json $ $scan --expect Privileged kubesec examples/bookstore/ci/fixtures/vulnerable/deployment.json scan.sh: control ok, trivy-config reported KSV-0017 on examples/bookstore/ci/fixtures/vulnerable/deployment.json scan.sh: control ok, kube-linter reported privileged-container on examples/bookstore/ci/fixtures/vulnerable/deployment.json scan.sh: control ok, kubesec reported Privileged on examples/bookstore/ci/fixtures/vulnerable/deployment.json ## step 10 $ cd .. $ scan=full-guide/examples/bookstore/ci/scan.sh $ $scan zizmor ".github/workflows/bookstore-pipeline.yml .github/workflows/bookstore-pipeline-check.yml" $ $scan actionlint ".github/workflows/bookstore-pipeline.yml .github/workflows/bookstore-pipeline-check.yml" $ $scan expiry "full-guide/examples/bookstore/ci/zap/baseline.conf full-guide/examples/bookstore/ci/kube-linter.yaml" scan.sh: zizmor clean on .github/workflows/bookstore-pipeline.yml .github/workflows/bookstore-pipeline-check.yml scan.sh: actionlint clean on .github/workflows/bookstore-pipeline.yml .github/workflows/bookstore-pipeline-check.yml scan.sh: expiry clean on full-guide/examples/bookstore/ci/zap/baseline.conf full-guide/examples/bookstore/ci/kube-linter.yaml $ $scan --expect template-injection zizmor full-guide/examples/bookstore/ci/fixtures/vulnerable/bad-workflow.yml $ $scan --expect 'potentially untrusted' actionlint full-guide/examples/bookstore/ci/fixtures/vulnerable/bad-workflow.yml $ $scan --expect 'lapsed on 2020-01-01' expiry full-guide/examples/bookstore/ci/fixtures/vulnerable/exceptions.conf $ $scan --expect 'no Revisit by DATE' expiry full-guide/examples/bookstore/ci/fixtures/vulnerable/exceptions.conf scan.sh: control ok, zizmor reported template-injection on full-guide/examples/bookstore/ci/fixtures/vulnerable/bad-workflow.yml scan.sh: control ok, actionlint reported potentially untrusted on full-guide/examples/bookstore/ci/fixtures/vulnerable/bad-workflow.yml scan.sh: control ok, expiry reported lapsed on 2020-01-01 on full-guide/examples/bookstore/ci/fixtures/vulnerable/exceptions.conf scan.sh: control ok, expiry reported no Revisit by DATE on full-guide/examples/bookstore/ci/fixtures/vulnerable/exceptions.conf $ cd full-guide $ scan=examples/bookstore/ci/scan.sh ## step 11 $ kubectl create namespace dast $ kubectl label namespace dast pod-security.kubernetes.io/enforce=restricted pod-security.kubernetes.io/warn=restricted $ kubectl apply --namespace dast -f - <<'EOF' # the default-deny NetworkPolicy from the chapter $ kubectl create serviceaccount catalog-sa --namespace dast $ kind load docker-image bookstore/catalog:dev --name bookstore $ kubectl apply --namespace dast -f examples/bookstore/raw-manifests/01-catalog-pod.yaml $ kubectl wait --namespace dast --for=condition=Ready pod/catalog --timeout=90s namespace/dast created namespace/dast labeled networkpolicy.networking.k8s.io/default-deny created serviceaccount/catalog-sa created Image: "bookstore/catalog:dev" with ID "sha256:ed20b252119884dbb2d045629c2333e6c2d48c9660d98b0ed2ea5518cec66be2" not yet present on node "bookstore-control-plane", loading... pod/catalog created pod/catalog condition met $ kubectl --namespace dast port-forward pod/catalog 8080:8080 >/dev/null & $ curl --silent --fail --retry 15 --retry-delay 1 --retry-all-errors --output /dev/null http://127.0.0.1:8080/books $ $scan zap http://127.0.0.1:8080/books $ grep -E '^(FAIL-NEW|WARN-NEW|INFO)' scan-reports/zap.log scan.sh: zap clean on http://127.0.0.1:8080/books INFO: X-Content-Type-Options Header Missing [10021] x 1 INFO: Storable and Cacheable Content [10049] x 4 INFO: Cross-Origin-Resource-Policy Header Missing or Invalid [90004] x 1 FAIL-NEW: 0 FAIL-INPROG: 0 WARN-NEW: 0 WARN-INPROG: 0 INFO: 3 IGNORE: 0 PASS: 65 $ docker run -d --name fixture -p 127.0.0.1:18080:8080 bookstore/vulnerable:fixture >/dev/null $ curl --silent --fail --retry 15 --retry-delay 1 --retry-all-errors --output /dev/null http://127.0.0.1:18080/books $ $scan --expect 10010 zap http://127.0.0.1:18080/books $ grep -E '^(FAIL-NEW|WARN-NEW|INFO)' scan-reports/zap.log $ docker rm -f fixture >/dev/null scan.sh: control ok, zap reported 10010 on http://127.0.0.1:18080/books INFO: Missing Anti-clickjacking Header [10020] x 1 INFO: X-Content-Type-Options Header Missing [10021] x 1 INFO: Content Security Policy (CSP) Header Not Set [10038] x 1 INFO: Storable and Cacheable Content [10049] x 3 INFO: Permissions Policy Header Not Set [10063] x 1 INFO: Cross-Origin-Embedder-Policy Header Missing or Invalid [90004] x 3 WARN-NEW: Cookie No HttpOnly Flag [10010] x 1 WARN-NEW: Cookie without SameSite Attribute [10054] x 1 WARN-NEW: Session Management Response Identified [10112] x 1 FAIL-NEW: 0 FAIL-INPROG: 0 WARN-NEW: 3 WARN-INPROG: 0 INFO: 6 IGNORE: 0 PASS: 59 # Steps 8, 10 and 12, recorded on 2026-10-31 from GitHub's own runs. # Unlike steps 1 to 11, these were not run on the Linux machine. They were # run from a Mac with gh 2.90.0, cosign v3.1.4, jq 1.8.1 and kubectl v1.37.2 # (embedded Kustomize v5.8.1), against the public image and the repository's # own Actions runs: run 41154561661 (the second dispatch of # bookstore-release.yml, service catalog, which is the one that worked), run # 41158667785 (the third dispatch, service orders, the first to run the # corrected promotion template; its sections are at the end of this file) and, # where a step says so, run 41151540459 (the first, which found the defects). # Every section ran with DOCKER_CONFIG pointing at an empty directory, so no # stored registry login could help a command. Job logs were fetched with # `gh api` and the leading timestamps removed with sed. As above, terminal # colour codes are removed and tabs are expanded to spaces. The recorded names # are the guide repository's real ones, because the runs are. ## step 8, the release run (run 41154561661, service catalog) $ REPO=abd-ulbasit/bookstore-kubernetes-guide $ RUN=41154561661 $ gh run view $RUN --repo $REPO --json event,headBranch,conclusion,jobs --jq '"\(.event) on \(.headBranch): \(.conclusion)", (.jobs[] | " \(.name): \(.conclusion)")' workflow_dispatch on main: success release (catalog) / workflow-hardening: success release (catalog) / secrets: success release (catalog) / sast: success release (catalog) / sca: success release (catalog) / image-lint: success release (catalog) / build-test: success release (catalog) / manifests: success release (catalog) / sbom: success release (catalog) / image-scan: success release (catalog) / dast: success release (catalog) / sign: success promote (catalog): success checks on the promotion PR (catalog): success $ SIGN=$(gh run view $RUN --repo $REPO --json jobs --jq '.jobs[] | select(.name == "release (catalog) / sign") | .databaseId') $ gh api repos/$REPO/actions/jobs/$SIGN --jq '.steps[] | select(.name | test("Push|Cosign|attest")) | "\(.name): \(.conclusion)"' Push, and read the digest the registry computed: success Cosign, sign the digest and attach the SBOM: success Run actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8: success $ gh api repos/$REPO/actions/jobs/$SIGN/logs | sed -E 's/^[0-9T:.-]+Z //' | grep -E -A1 'Attestation (signature uploaded|uploaded to repository)' Attestation signature uploaded to Rekor transparency log https://search.sigstore.dev?logIndex=3607069208 Attestation uploaded to repository https://github.com/abd-ulbasit/bookstore-kubernetes-guide/attestations/62001352 $ D=$(gh api repos/$REPO/actions/jobs/$SIGN/logs | grep -oE 'digest: sha256:[0-9a-f]{64}' | head -1 | cut -d' ' -f2) $ echo $D sha256:eaa26ada0a2e1575026a5e71e74572ed0bfdde80f50012e91a7be28f0de16ced $ IMAGE=ghcr.io/abd-ulbasit/bookstore-catalog@$D $ ID="https://github.com/$REPO/.github/workflows/bookstore-pipeline.yml@refs/heads/main" $ cosign verify --certificate-identity "$ID" --certificate-oidc-issuer https://token.actions.githubusercontent.com "$IMAGE" 2>&1 >/dev/null | grep -E '^(Verification for| - )' Verification for ghcr.io/abd-ulbasit/bookstore-catalog@sha256:eaa26ada0a2e1575026a5e71e74572ed0bfdde80f50012e91a7be28f0de16ced -- - The cosign claims were validated - Existence of the claims in the transparency log was verified offline - The code-signing certificate was verified using trusted certificate authority certificates $ cosign verify --certificate-identity "${ID%main}other" --certificate-oidc-issuer https://token.actions.githubusercontent.com "$IMAGE" 2>&1 | head -1; echo "exit status: ${PIPESTATUS[0]}" Error: no matching attestations: failed to verify certificate identity: no matching CertificateIdentity found, last error: expected SAN value "https://github.com/abd-ulbasit/bookstore-kubernetes-guide/.github/workflows/bookstore-pipeline.yml@refs/heads/other", got "https://github.com/abd-ulbasit/bookstore-kubernetes-guide/.github/workflows/bookstore-pipeline.yml@refs/heads/main" exit status: 1 $ cosign verify-attestation --type cyclonedx --certificate-identity "$ID" --certificate-oidc-issuer https://token.actions.githubusercontent.com "$IMAGE" 2>/dev/null | jq -r .payload | base64 -d | jq '{bomFormat: .predicate.bomFormat, specVersion: .predicate.specVersion, components: (.predicate.components | length)}' { "bomFormat": "CycloneDX", "specVersion": "1.7", "components": 972 } $ GH_FORCE_TTY=100 gh attestation verify oci://$IMAGE --repo $REPO 2>&1 | grep 'Subject Alternative Name' - Subject Alternative Name must match regex: (?i)^https://github.com/abd-ulbasit/bookstore-kubernetes-guide/ $ GH_FORCE_TTY=100 gh attestation verify oci://$IMAGE --repo $REPO --cert-identity "$ID" Loaded digest sha256:eaa26ada0a2e1575026a5e71e74572ed0bfdde80f50012e91a7be28f0de16ced for oci://ghcr.io/abd-ulbasit/bookstore-catalog@sha256:eaa26ada0a2e1575026a5e71e74572ed0bfdde80f50012e91a7be28f0de16ced Loaded 1 attestation from GitHub API The following policy criteria will be enforced: - Predicate type must match:............. https://slsa.dev/provenance/v1 - Source Repository Owner URI must match: https://github.com/abd-ulbasit - Source Repository URI must match:...... https://github.com/abd-ulbasit/bookstore-kubernetes-guide - Subject Alternative Name must match:... https://github.com/abd-ulbasit/bookstore-kubernetes-guide/.github/workflows/bookstore-pipeline.yml@refs/heads/main - OIDC Issuer must match:................ https://token.actions.githubusercontent.com ✓ Verification succeeded! The following 1 attestation matched the policy criteria - Attestation #1 - Build repo:..... abd-ulbasit/bookstore-kubernetes-guide - Build workflow:. .github/workflows/bookstore-release.yml@refs/heads/main - Signer repo:.... abd-ulbasit/bookstore-kubernetes-guide - Signer workflow: .github/workflows/bookstore-pipeline.yml@refs/heads/main $ TOKEN=$(curl -fsS "https://ghcr.io/token?scope=repository:abd-ulbasit/bookstore-catalog:pull" | jq -r .token) $ curl -fsS -o /dev/null -w '%{http_code}\n' -H "Authorization: Bearer $TOKEN" -H 'Accept: application/vnd.oci.image.index.v1+json, application/vnd.oci.image.manifest.v1+json' "https://ghcr.io/v2/abd-ulbasit/bookstore-catalog/manifests/$D" 200 ## step 10, workflow-hardening and sast in the same run $ REPO=abd-ulbasit/bookstore-kubernetes-guide $ RUN=41154561661 $ HARDEN=$(gh run view $RUN --repo $REPO --json jobs --jq '.jobs[] | select(.name == "release (catalog) / workflow-hardening") | .databaseId') $ gh api repos/$REPO/actions/jobs/$HARDEN --jq '.steps[] | select(.name | test("Scorecard")) | "\(.name): \(.conclusion)"' OpenSSF Scorecard (default branch only): success Scorecard aggregate score: success Scorecard produced no result: skipped $ gh api repos/$REPO/actions/jobs/$HARDEN/logs | sed -E 's/^[0-9T:.-]+Z //' | grep -E '^ (Event name|Default branch|Publication enabled):' Event name: workflow_dispatch Publication enabled: false Default branch: main $ gh api repos/$REPO/actions/jobs/$HARDEN/logs | sed -E 's/^[0-9T:.-]+Z //' | grep -A18 '^Scorecard aggregate score' Scorecard aggregate score: 6.7 / 10 10 Maintained 0 Code-Review 10 Security-Policy 10 Dependency-Update-Tool 10 Dangerous-Workflow 10 Token-Permissions 10 Binary-Artifacts 0 CII-Best-Practices 10 SAST 10 Packaging 10 License 0 Vulnerabilities 0 Fuzzing 3 Branch-Protection -1 Signed-Releases 0 Contributors 6 Pinned-Dependencies 10 CI-Tests $ gh api repos/$REPO/actions/jobs/$HARDEN/logs | sed -E 's/^[0-9T:.-]+Z //' | grep '^{"date"' | jq -r '.checks[] | select(.score < 10) | "\(.name) \(.score): \(.reason)"' Code-Review 0: Found 0/2 approved changesets -- score normalized to 0 CII-Best-Practices 0: no effort to earn an OpenSSF best practices badge detected Vulnerabilities 0: 49 existing vulnerabilities detected Fuzzing 0: project is not fuzzed Branch-Protection 3: branch protection is not maximal on development and all release branches Signed-Releases -1: no releases found Contributors 0: project has 0 contributing companies or organizations -- score normalized to 0 Pinned-Dependencies 6: dependency not pinned by hash detected -- score normalized to 6 $ gh api repos/$REPO/actions/jobs/$HARDEN/logs | sed -E 's/^[0-9T:.-]+Z //' | grep -E '^(\[harden-runner\]|https://app.stepsecurity.io)' [harden-runner] pre-step https://app.stepsecurity.io/github/abd-ulbasit/bookstore-kubernetes-guide/actions/runs/41154561661 [harden-runner] main-step https://app.stepsecurity.io/github/abd-ulbasit/bookstore-kubernetes-guide/actions/runs/41154561661 [harden-runner] post-step $ gh api repos/$REPO/actions/jobs/$HARDEN/logs | sed -E 's/^[0-9T:.-]+Z //' | grep -o 'domain: [^,]*' | sort | uniq -c 1 domain: api.deps.dev. 1 domain: api.github.com. 1 domain: api.osv.dev. 2 domain: auth.docker.io. 1 domain: codeload.github.com. 1 domain: gcr.io. 1 domain: ghcr.io. 1 domain: github.com. 1 domain: index.docker.io. 1 domain: oss-fuzz-build-logs.storage.googleapis.com. 1 domain: pkg-containers.githubusercontent.com. 1 domain: production.cloudfront.docker.com. 1 domain: productionresultssa17.blob.core.windows.net. 1 domain: registry-1.docker.io. 1 domain: results-receiver.actions.githubusercontent.com. 1 domain: tuf-repo-cdn.sigstore.dev. 1 domain: www.bestpractices.dev. $ gh api repos/$REPO/actions/jobs/$HARDEN/logs | sed -E 's/^[0-9T:.-]+Z //' | grep 'process: scorecard-action' | grep -o 'domain: [^,]*' | sort -u domain: api.deps.dev. domain: api.github.com. domain: api.osv.dev. domain: auth.docker.io. domain: codeload.github.com. domain: gcr.io. domain: index.docker.io. domain: oss-fuzz-build-logs.storage.googleapis.com. domain: www.bestpractices.dev. $ SIGN=$(gh run view $RUN --repo $REPO --json jobs --jq '.jobs[] | select(.name == "release (catalog) / sign") | .databaseId') $ gh api repos/$REPO/actions/jobs/$SIGN/logs | sed -E 's/^[0-9T:.-]+Z //' | grep 'process: cosign' | grep -o 'domain: [^,]*' | sort -u domain: fulcio.sigstore.dev. domain: ghcr.io. domain: rekor.sigstore.dev. domain: run-actions-1-azure-eastus.actions.githubusercontent.com. domain: timestamp.sigstore.dev. domain: tuf-repo-cdn.sigstore.dev. $ SAST=$(gh run view $RUN --repo $REPO --json jobs --jq '.jobs[] | select(.name == "release (catalog) / sast") | .databaseId') $ gh api repos/$REPO/actions/jobs/$SAST/logs | sed -E 's/^[0-9T:.-]+Z //' | grep -E '^(\[36/36 eval|CodeQL results:| upload-database:)' upload-database: false [36/36 eval 148ms] Evaluation done; writing results to codeql/go-queries/Security/CWE-681/IncorrectIntegerConversionQuery.bqrs. CodeQL results: 0 $ gh run view 41151540459 --repo $REPO --json jobs --jq '.jobs[] | select(.name | test("workflow-hardening")) | .databaseId' 124388967169 $ gh api repos/$REPO/actions/jobs/124388967169 --jq '.steps[] | select(.name | test("Scorecard")) | "\(.name): \(.conclusion)"' OpenSSF Scorecard (default branch only): skipped $ gh api repos/$REPO/actions/jobs/124388967226/logs | sed -E 's/^[0-9T:.-]+Z //' | grep -E '^(CodeQL results:|##\[error\]|##\[warning\]Failed to upload)' | cut -c1-110 ##[error]Maximum retry attempts exhausted (4), aborting database upload ##[warning]Failed to upload database for go: Resource not accessible by integration - https://docs.github.com/ CodeQL results: 0 ## step 12, what the promotion did, first and second time $ REPO=abd-ulbasit/bookstore-kubernetes-guide $ RUN=41154561661 $ gh api repos/$REPO/actions/jobs/124390881605/logs | sed -E 's/^[0-9T:.-]+Z //' | grep -B1 -E '^ [0-9]+ files? changed' | head -2 .../kustomize/overlays/prod/kustomization.yaml | 288 ++++++++++----------- 1 file changed, 143 insertions(+), 145 deletions(-) $ gh pr view 8 --repo $REPO --json state,changedFiles,additions,deletions --jq '"PR 8 (\(.state)): \(.changedFiles) file, +\(.additions) -\(.deletions)"' PR 8 (CLOSED): 1 file, +143 -145 $ gh pr view 8 --repo $REPO --json body --jq .body | grep -E 'OWNER|REPO|DIGEST' cosign verify ghcr.io/OWNER/bookstore-catalog@DIGEST \ --certificate-identity-regexp 'https://github.com/OWNER/REPO/.github/workflows/bookstore-pipeline.yml@.*' \ $ gh pr view 8 --repo $REPO --json statusCheckRollup --jq '.statusCheckRollup | length' 0 $ PROMOTE=$(gh run view $RUN --repo $REPO --json jobs --jq '.jobs[] | select(.name == "promote (catalog)") | .databaseId') $ gh api repos/$REPO/actions/jobs/$PROMOTE/logs | sed -E 's/^[0-9T:.-]+Z //' | grep -B2 '^changed lines:' .../bookstore/kustomize/overlays/prod/images/kustomization.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) changed lines: 6 $ gh pr view 10 --repo $REPO --json state,changedFiles,additions,deletions --jq '"PR 10 (\(.state)): \(.changedFiles) file, +\(.additions) -\(.deletions)"' PR 10 (MERGED): 1 file, +3 -3 $ gh pr diff 10 --repo $REPO diff --git a/full-guide/examples/bookstore/kustomize/overlays/prod/images/kustomization.yaml b/full-guide/examples/bookstore/kustomize/overlays/prod/images/kustomization.yaml index 8e7c6f0..79b21a7 100644 --- a/full-guide/examples/bookstore/kustomize/overlays/prod/images/kustomization.yaml +++ b/full-guide/examples/bookstore/kustomize/overlays/prod/images/kustomization.yaml @@ -23,9 +23,9 @@ apiVersion: kustomize.config.k8s.io/v1alpha1 kind: Component images: -- name: bookstore/catalog - newName: registry.example.com/bookstore/catalog - newTag: 1.0.0 +- digest: sha256:eaa26ada0a2e1575026a5e71e74572ed0bfdde80f50012e91a7be28f0de16ced + name: bookstore/catalog + newName: ghcr.io/abd-ulbasit/bookstore-catalog - name: bookstore/orders newName: registry.example.com/bookstore/orders newTag: 1.0.0 $ gh pr view 10 --repo $REPO --json body --jq .body | grep -c -E 'OWNER|REPO|DIGEST' 0 $ CHECKS=$(gh run view $RUN --repo $REPO --json jobs --jq '.jobs[] | select(.name | startswith("checks on")) | .databaseId') $ gh api repos/$REPO/actions/jobs/$CHECKS/logs | sed -E 's/^[0-9T:.-]+Z //' | grep '^dispatched' dispatched example-trees-check.yml on ci/promote-catalog dispatched security-gates.yml on ci/promote-catalog $ gh run view 41155073279 --repo $REPO --json workflowName,event,headBranch,conclusion --jq '"\(.workflowName), \(.event) on \(.headBranch): \(.conclusion)"' security-gates, workflow_dispatch on ci/promote-catalog: success $ gh run view 41155073279 --repo $REPO --json jobs --jq '.jobs[] | select(.name | test("runtime")) | "\(.name): \(.conclusion)"' G4 runtime (kustomize-prod): success G4 runtime (kustomize-dev): success G4 runtime (helm): success G4 runtime (kustomize-staging): success G4 runtime (raw): success $ gh run view 41155071392 --repo $REPO --json workflowName,event,headBranch,conclusion --jq '"\(.workflowName), \(.event) on \(.headBranch): \(.conclusion)"' example-trees-check, workflow_dispatch on ci/promote-catalog: success $ gh run view 41155071392 --repo $REPO --json jobs --jq '.jobs[] | select(.name == "kustomize-counts") | "\(.name): \(.conclusion)"' kustomize-counts: success $ gh api "repos/$REPO/actions/runs?branch=ci/promote-catalog&per_page=50" --jq '.workflow_runs[] | select(.event == "pull_request" and (.head_sha | startswith("0a137b8"))) | "\(.name) by \(.triggering_actor.login): \(.conclusion)"' | sort docs by abd-ulbasit: success docs by github-actions[bot]: failure example-trees-check by abd-ulbasit: success example-trees-check by github-actions[bot]: failure secret-scan by abd-ulbasit: success secret-scan by github-actions[bot]: failure security-gates by abd-ulbasit: success security-gates by github-actions[bot]: failure security-scan by abd-ulbasit: success security-scan by github-actions[bot]: failure $ git log -1 --format=%s ci: promote catalog to prod (signed digest) $ kubectl kustomize examples/bookstore/kustomize/overlays/prod | grep -c '^kind:' 48 $ kubectl kustomize examples/bookstore/kustomize/overlays/prod | grep 'image:.*catalog' image: ghcr.io/abd-ulbasit/bookstore-catalog@sha256:eaa26ada0a2e1575026a5e71e74572ed0bfdde80f50012e91a7be28f0de16ced ## step 12, the runs GitHub created for the bot's PR (output captured at 01:23 UTC, before the PR was closed and reopened) $ gh run list --repo $REPO --branch ci/promote-catalog --limit 10 --json databaseId,workflowName,status,conclusion,event,headSha --jq '.[]|[.databaseId,.workflowName,.status,.conclusion,.event,.headSha[0:7]]|@tsv' 41155073279 security-gates in_progress workflow_dispatch 0a137b8 41155071392 example-trees-check in_progress workflow_dispatch 0a137b8 41155056676 secret-scan completed action_required pull_request 0a137b8 41155056641 security-gates completed action_required pull_request 0a137b8 41155056931 docs completed action_required pull_request 0a137b8 41155056744 security-scan completed action_required pull_request 0a137b8 41155056756 example-trees-check completed action_required pull_request 0a137b8 41152171565 docs completed failure pull_request 0c95d61 41152171727 secret-scan completed failure pull_request 0c95d61 41152171604 security-gates completed failure pull_request 0c95d61 ## step 12, the ruleset on main $ REPO=abd-ulbasit/bookstore-kubernetes-guide $ gh api repos/$REPO/rulesets/25746874 --jq '[.name, .enforcement, (.rules | map(.type) | join(", "))] | join(": ")' protect main: active: deletion, non_fast_forward # The third release run, service orders, run 41158667785. These sections were # recorded later on the same day as those above, with the same tools. The # first two (step 8, then step 12 before the merge) ran in one shell, in order, # while PR 12 was open and before main moved. The rest ran after PR 12's # branch was updated from main and PR 12 was merged. ## step 8, the third release run (run 41158667785, service orders) $ REPO=abd-ulbasit/bookstore-kubernetes-guide $ RUN=41158667785 $ gh run view $RUN --repo $REPO --json event,headBranch,conclusion,jobs --jq '"\(.event) on \(.headBranch): \(.conclusion)", (.jobs[] | " \(.name): \(.conclusion)")' workflow_dispatch on main: success release (orders) / sast: success release (orders) / build-test: success release (orders) / manifests: success release (orders) / image-lint: success release (orders) / secrets: success release (orders) / sca: success release (orders) / workflow-hardening: success release (orders) / sbom: success release (orders) / dast: success release (orders) / image-scan: success release (orders) / sign: success promote (orders): success checks on the promotion PR (orders): success $ SIGN=$(gh run view $RUN --repo $REPO --json jobs --jq '.jobs[] | select(.name == "release (orders) / sign") | .databaseId') $ gh api repos/$REPO/actions/jobs/$SIGN --jq '.steps[] | select(.name | test("Push|Cosign|attest")) | "\(.name): \(.conclusion)"' Push, and read the digest the registry computed: success Cosign, sign the digest and attach the SBOM: success Run actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8: success $ gh api repos/$REPO/actions/jobs/$SIGN/logs | sed -E 's/^[0-9T:.-]+Z //' | grep -E -A1 'Attestation (signature uploaded|uploaded to repository)' Attestation signature uploaded to Rekor transparency log https://search.sigstore.dev?logIndex=3607767425 Attestation uploaded to repository https://github.com/abd-ulbasit/bookstore-kubernetes-guide/attestations/62011300 $ D=$(gh api repos/$REPO/actions/jobs/$SIGN/logs | grep -oE 'digest: sha256:[0-9a-f]{64}' | head -1 | cut -d' ' -f2) $ echo $D sha256:78ad1a65b9647607b5903035685a864882f8f38f85a45c21d86089f4f7371caf $ IMAGE=ghcr.io/abd-ulbasit/bookstore-orders@$D $ ID="https://github.com/$REPO/.github/workflows/bookstore-pipeline.yml@refs/heads/main" $ cosign verify-attestation --type cyclonedx --certificate-identity "$ID" --certificate-oidc-issuer https://token.actions.githubusercontent.com "$IMAGE" 2>/dev/null | jq -r .payload | base64 -d | jq '{bomFormat: .predicate.bomFormat, specVersion: .predicate.specVersion, components: (.predicate.components | length)}' { "bomFormat": "CycloneDX", "specVersion": "1.7", "components": 971 } ## step 12, the promotion PR of the third run (PR 12, orders), read before it was merged $ REPO=abd-ulbasit/bookstore-kubernetes-guide $ RUN=41158667785 $ PROMOTE=$(gh run view $RUN --repo $REPO --json jobs --jq '.jobs[] | select(.name == "promote (orders)") | .databaseId') $ gh api repos/$REPO/actions/jobs/$PROMOTE/logs | sed -E 's/^[0-9T:.-]+Z //' | grep -B2 '^changed lines:' .../bookstore/kustomize/overlays/prod/images/kustomization.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) changed lines: 6 $ gh pr view 12 --repo $REPO --json state,changedFiles,additions,deletions --jq '"PR 12 (\(.state)): \(.changedFiles) file, +\(.additions) -\(.deletions)"' PR 12 (OPEN): 1 file, +3 -3 $ gh pr view 12 --repo $REPO --json body --jq .body | grep -c -E 'OWNER|REPO|DIGEST' 0 $ gh pr view 10 --repo $REPO --json body --jq .body | grep -c -e '--cert-identity' 0 $ gh pr view 12 --repo $REPO --json body --jq .body | grep -c -e '--cert-identity' 1 $ gh pr view 12 --repo $REPO --json body --jq .body | grep -E -e '--(certificate|cert)-identity' --certificate-identity 'https://github.com/abd-ulbasit/bookstore-kubernetes-guide/.github/workflows/bookstore-pipeline.yml@refs/heads/main' \ --cert-identity 'https://github.com/abd-ulbasit/bookstore-kubernetes-guide/.github/workflows/bookstore-pipeline.yml@refs/heads/main' $ gh pr view 12 --repo $REPO --json body --jq .body | awk '/^ cosign verify/,/^$/' | sed 's/^ //' > pasted-cosign.sh $ gh pr view 12 --repo $REPO --json body --jq .body | awk '/^ gh attestation verify/,/^$/' | sed 's/^ //' > pasted-attest.sh $ bash pasted-cosign.sh >/dev/null 2>&1; echo "cosign verify, as pasted: exit $?" cosign verify, as pasted: exit 0 $ bash pasted-attest.sh >/dev/null 2>&1; echo "gh attestation verify, as pasted: exit $?" gh attestation verify, as pasted: exit 0 $ GH_FORCE_TTY=100 bash pasted-attest.sh 2>&1 | grep -E "Subject Alternative Name|Verification succeeded|Signer workflow" - Subject Alternative Name must match:... https://github.com/abd-ulbasit/bookstore-kubernetes-guide/.github/workflows/bookstore-pipeline.yml@refs/heads/main ✓ Verification succeeded! - Signer workflow: .github/workflows/bookstore-pipeline.yml@refs/heads/main $ CHECKS=$(gh run view $RUN --repo $REPO --json jobs --jq '.jobs[] | select(.name | startswith("checks on")) | .databaseId') $ gh api repos/$REPO/actions/jobs/$CHECKS/logs | sed -E 's/^[0-9T:.-]+Z //' | grep '^dispatched' dispatched example-trees-check.yml on ci/promote-orders dispatched security-gates.yml on ci/promote-orders $ gh run list --repo $REPO --branch ci/promote-orders --limit 10 --json databaseId,workflowName,status,conclusion,event,headSha --jq '.[]|[.databaseId,.workflowName,.status,.conclusion,.event,.headSha[0:7]]|@tsv' 41159148867 security-gates completed success workflow_dispatch 64708d1 41159146728 example-trees-check completed success workflow_dispatch 64708d1 41159130086 docs completed action_required pull_request 64708d1 41159130026 security-gates completed action_required pull_request 64708d1 41159130033 secret-scan completed action_required pull_request 64708d1 41159130122 example-trees-check completed action_required pull_request 64708d1 41159130013 security-scan completed action_required pull_request 64708d1 $ SHA=$(gh pr view 12 --repo $REPO --json headRefOid --jq .headRefOid) $ gh api --paginate repos/$REPO/commits/$SHA/check-runs --jq '.check_runs[].conclusion' | sort | uniq -c 1 skipped 32 success $ gh pr view 12 --repo $REPO --json statusCheckRollup --jq '.statusCheckRollup | length' 0 $ gh pr checks 12 --repo $REPO; echo "exit status: $?" no checks reported on the 'ci/promote-orders' branch exit status: 1 ## step 12, what the catalog PR's body said (PR 10, opened by the second run) $ REPO=abd-ulbasit/bookstore-kubernetes-guide $ gh pr view 10 --repo $REPO --json body --jq .body | grep -E 'attestation verify|triggers no workflows' gh attestation verify oci://ghcr.io/abd-ulbasit/bookstore-catalog@sha256:eaa26ada0a2e1575026a5e71e74572ed0bfdde80f50012e91a7be28f0de16ced --repo abd-ulbasit/bookstore-kubernetes-guide because a pull request opened with GITHUB_TOKEN triggers no workflows. If ## step 12, the orders promotion PR after main moved, and its merge $ REPO=abd-ulbasit/bookstore-kubernetes-guide $ gh run list --repo $REPO --branch ci/promote-orders --limit 12 --json databaseId,workflowName,status,conclusion,event,headSha --jq '.[]|[.databaseId,.workflowName,.status,.conclusion,.event,.headSha[0:7]]|@tsv' 41160015467 secret-scan completed success pull_request a7f1148 41160015446 docs completed success pull_request a7f1148 41160015520 example-trees-check completed success pull_request a7f1148 41160015527 security-scan completed success pull_request a7f1148 41160015439 security-gates completed success pull_request a7f1148 41159148867 security-gates completed success workflow_dispatch 64708d1 41159146728 example-trees-check completed success workflow_dispatch 64708d1 41159130086 docs completed action_required pull_request 64708d1 41159130026 security-gates completed action_required pull_request 64708d1 41159130033 secret-scan completed action_required pull_request 64708d1 41159130122 example-trees-check completed action_required pull_request 64708d1 41159130013 security-scan completed action_required pull_request 64708d1 $ gh pr view 12 --repo $REPO --json state,headRefOid,mergeCommit --jq '"PR 12 (\(.state)): merge commit is the head: \(.mergeCommit.oid == .headRefOid)"' PR 12 (MERGED): merge commit is the head: true $ git log -2 --format=%s -- examples/bookstore/kustomize/overlays/prod/images ci: promote orders to prod (signed digest) ci: promote catalog to prod (signed digest) $ kubectl kustomize examples/bookstore/kustomize/overlays/prod | grep -c '^kind:' 48 $ kubectl kustomize examples/bookstore/kustomize/overlays/prod | grep -E 'image:.*(catalog|orders)' image: ghcr.io/abd-ulbasit/bookstore-catalog@sha256:eaa26ada0a2e1575026a5e71e74572ed0bfdde80f50012e91a7be28f0de16ced image: ghcr.io/abd-ulbasit/bookstore-orders@sha256:78ad1a65b9647607b5903035685a864882f8f38f85a45c21d86089f4f7371caf ## step 12, the merged promotion branches, before and after deleting them $ gh api repos/$REPO/branches --paginate --jq '.[].name | select(startswith("ci/"))' ci/promote-catalog ci/promote-orders $ gh api repos/$REPO/branches/ci/promote-catalog --jq .commit.sha[0:7] 0a137b8 $ gh pr view 10 --repo $REPO --json state,headRefOid --jq '"PR 10 (\(.state)): head \(.headRefOid[0:7])"' PR 10 (MERGED): head 0a137b8 $ gh api repos/$REPO/branches/ci/promote-orders --jq .commit.sha[0:7] a7f1148 $ gh pr view 12 --repo $REPO --json state,headRefOid --jq '"PR 12 (\(.state)): head \(.headRefOid[0:7])"' PR 12 (MERGED): head a7f1148 $ gh api -X DELETE repos/$REPO/git/refs/heads/ci/promote-catalog $ gh api -X DELETE repos/$REPO/git/refs/heads/ci/promote-orders $ gh api repos/$REPO/branches --paginate --jq '[.[].name | select(startswith("ci/"))] | length' 0 ## step 12, who could merge it $ REPO=abd-ulbasit/bookstore-kubernetes-guide $ gh api repos/$REPO/rules/branches/main --jq '[.[].type] | join(", ")' deletion, non_fast_forward $ gh api repos/$REPO/rulesets --jq 'length' 1 $ gh pr view 12 --repo $REPO --json reviews,mergedBy --jq '"PR 12: \(.reviews | length) reviews, merged by \(.mergedBy.login)"' PR 12: 0 reviews, merged by abd-ulbasit $ gh pr view 10 --repo $REPO --json reviews,mergedBy --jq '"PR 10: \(.reviews | length) reviews, merged by \(.mergedBy.login)"' PR 10: 0 reviews, merged by abd-ulbasit ## step 12, who started the orders PR's pull_request runs $ REPO=abd-ulbasit/bookstore-kubernetes-guide $ gh api "repos/$REPO/actions/runs?branch=ci/promote-orders&per_page=50" --jq '.workflow_runs[] | select(.event == "pull_request") | "\(.name) \(.head_sha[0:7]) by \(.triggering_actor.login): \(.conclusion)"' | sort docs 64708d1 by github-actions[bot]: action_required docs a7f1148 by abd-ulbasit: success example-trees-check 64708d1 by github-actions[bot]: action_required example-trees-check a7f1148 by abd-ulbasit: success secret-scan 64708d1 by github-actions[bot]: action_required secret-scan a7f1148 by abd-ulbasit: success security-gates 64708d1 by github-actions[bot]: action_required security-gates a7f1148 by abd-ulbasit: success security-scan 64708d1 by github-actions[bot]: action_required security-scan a7f1148 by abd-ulbasit: success