Repository navigation
Expand file tree
/
Copy pathdev-credential-requester-image.yml
More file actions
128 lines (117 loc) · 5.49 KB
/
Copy pathdev-credential-requester-image.yml
File metadata and controls
128 lines (117 loc) · 5.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: Dev credential requester image artifact
# Retain an inspectable parent helper image for a separately authorized Dev
# rollout. This workflow never transfers, installs, or starts it on EC2.
on:
workflow_dispatch:
permissions:
contents: read
jobs:
build:
if: >-
github.repository == 'MaplePrivacyLabs/Maple' &&
github.ref == 'refs/heads/master' &&
github.event_name == 'workflow_dispatch'
runs-on: ubuntu-24.04-arm
timeout-minutes: 30
permissions:
contents: read
id-token: write
attestations: write
defaults:
run:
shell: bash
working-directory: services/opensecret
env:
CONTEXT: nitro-toolkit/credential_requester
IMAGE: credential-requester:dev-${{ github.sha }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ github.sha }}
persist-credentials: false
- name: Check exact source and pinned base
run: |
set -euo pipefail
test "$(git rev-parse HEAD)" = "$GITHUB_SHA"
test -z "$(git status --porcelain)"
base_image="$(sed -n '1s/^FROM //p' "$CONTEXT/Dockerfile")"
[[ "$base_image" =~ @sha256:[0-9a-f]{64}$ ]]
- name: Build Linux ARM64 image
run: |
set -euo pipefail
docker build --pull --platform linux/arm64 \
--label "org.opencontainers.image.revision=$GITHUB_SHA" \
--tag "$IMAGE" "$CONTEXT"
- name: Check image architecture and runtime packages
run: |
set -euo pipefail
test "$(docker image inspect --format '{{.Os}}/{{.Architecture}}' "$IMAGE")" = linux/arm64
test "$(docker image inspect --format '{{index .Config.Labels "org.opencontainers.image.revision"}}' "$IMAGE")" = "$GITHUB_SHA"
docker run --rm --network none --entrypoint python "$IMAGE" -c \
'import boto3, botocore, urllib3, importlib.util; assert importlib.util.find_spec("pip") is None; assert importlib.util.find_spec("ensurepip") is None'
- name: Run six offline helper and CA trust tests
run: |
set -euo pipefail
docker run --rm --network none \
--mount "type=bind,src=$PWD/$CONTEXT,dst=/tests,readonly" \
--entrypoint python "$IMAGE" \
-B -m unittest discover -s /tests -p 'test_*.py' -v 2>&1 \
| tee "$RUNNER_TEMP/credential-requester-tests.log"
grep -Eq '^Ran 6 tests in ' "$RUNNER_TEMP/credential-requester-tests.log"
- name: Scan finished image for fixable high and critical vulnerabilities
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
version: v0.75.0
image-ref: ${{ env.IMAGE }}
format: table
exit-code: '1'
ignore-unfixed: true
severity: HIGH,CRITICAL
scanners: vuln
- name: Save image and exact-source metadata
run: |
set -euo pipefail
out="$RUNNER_TEMP/credential-requester-artifact"
mkdir -p "$out"
image_id="$(docker image inspect --format '{{.Id}}' "$IMAGE")"
[[ "$image_id" =~ ^sha256:[0-9a-f]{64}$ ]]
base_image="$(sed -n '1s/^FROM //p' "$CONTEXT/Dockerfile")"
source_tree="$(git rev-parse "HEAD:services/opensecret/$CONTEXT")"
requirements_sha256="$(sha256sum "$CONTEXT/requirements.txt" | cut -d' ' -f1)"
dockerfile_sha256="$(sha256sum "$CONTEXT/Dockerfile" | cut -d' ' -f1)"
docker save --output "$out/credential-requester-linux-arm64.tar" "$IMAGE"
tar_sha256="$(sha256sum "$out/credential-requester-linux-arm64.tar" | cut -d' ' -f1)"
jq -n \
--arg environment dev \
--arg source_commit "$GITHUB_SHA" \
--arg source_tree "$source_tree" \
--arg image_tag "$IMAGE" \
--arg image_id "$image_id" \
--arg architecture linux/arm64 \
--arg base_image "$base_image" \
--arg requirements_sha256 "$requirements_sha256" \
--arg dockerfile_sha256 "$dockerfile_sha256" \
--arg archive_sha256 "$tar_sha256" \
--arg run_id "$GITHUB_RUN_ID" \
--arg run_attempt "$GITHUB_RUN_ATTEMPT" \
'{environment: $environment, source_commit: $source_commit, source_tree: $source_tree,
image_tag: $image_tag, image_id: $image_id, architecture: $architecture,
base_image: $base_image, requirements_sha256: $requirements_sha256,
dockerfile_sha256: $dockerfile_sha256, archive_sha256: $archive_sha256,
run_id: $run_id, run_attempt: $run_attempt}' \
> "$out/manifest.json"
(cd "$out" && sha256sum credential-requester-linux-arm64.tar manifest.json > SHA256SUMS)
cat "$out/manifest.json"
cat "$out/SHA256SUMS"
- name: Attest image archive and manifest
uses: actions/attest@281a49d4cbb0a72c9575a50d18f6deb515a11deb # v4
with:
subject-checksums: ${{ runner.temp }}/credential-requester-artifact/SHA256SUMS
- name: Upload immutable Dev handoff artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: dev-credential-requester-linux-arm64-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/credential-requester-artifact/*
if-no-files-found: error
retention-days: 7
compression-level: 0