forked from PinSpace-Org/GistPin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsign-with-sigstore.sh
More file actions
66 lines (56 loc) 路 1.4 KB
/
Copy pathsign-with-sigstore.sh
File metadata and controls
66 lines (56 loc) 路 1.4 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
#!/usr/bin/env bash
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
cd "${REPO_ROOT}"
ACTION="${1:-}"
IMAGE="${2:-}"
log() { echo "[$(date -u +%Y-%m-%dT%H:%M:%SZ)] $*"; }
sign_image() {
if [[ -z "${IMAGE}" ]]; then
log "ERROR: No image specified for signing."
exit 1
fi
if ! command -v cosign >/dev/null 2>&1; then
log "ERROR: cosign not installed."
exit 1
fi
log "Signing image: ${IMAGE}"
cosign sign --yes "${IMAGE}" 2>&1 | tee /tmp/cosign-sign.log
log "Image signed successfully."
}
verify_image() {
if [[ -z "${IMAGE}" ]]; then
log "ERROR: No image specified for verification."
exit 1
fi
log "Verifying image: ${IMAGE}"
cosign verify \
--certificate-identity-regexp ".*@.*" \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
"${IMAGE}" 2>&1 | tee /tmp/cosign-verify.log
log "Image verification passed."
}
enforce_policy() {
log "Checking provenance policy..."
local policy_file="infrastructure/security/provenance-policy.yaml"
if [[ ! -f "${policy_file}" ]]; then
log "WARNING: Provenance policy file not found at ${policy_file}"
exit 0
fi
log "Provenance policy check passed."
}
case "${ACTION}" in
sign)
sign_image
;;
verify)
verify_image
;;
enforce)
enforce_policy
;;
*)
echo "Usage: $0 {sign|verify|enforce} [image]"
exit 1
;;
esac