chore: finalize lab7 security verification
CI / verify (pull_request) Failing after 3m27s

This commit is contained in:
2026-11-06 21:39:31 +03:00
parent 5ac64f51fa
commit 97a52eeee6
41 changed files with 759 additions and 150 deletions
+2
View File
@@ -6,5 +6,7 @@ script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
repo_dir=$(CDPATH= cd -- "$script_dir/.." && pwd)
env_file=${ENV_FILE:-$repo_dir/lab7.env.example}
"$script_dir/sync-docker-workspace.sh"
exec docker compose --project-directory "$repo_dir" --env-file "$env_file" run --rm --no-deps -T \
-v "$repo_dir:$repo_dir:ro" openbao-cli "$@"
+7 -4
View File
@@ -20,14 +20,17 @@ if [ ! -f "$repo_dir/.runtime/security/openbao/tls.crt" ]; then
fi
"$script_dir/openbao-seed.sh" "$env_file"
"$script_dir/sync-docker-workspace.sh"
compose up -d security-bootstrap openbao-permissions openbao
openbao_address=$(compose port openbao 8200)
BAO_ADDR="https://$openbao_address"
if [ -z "${BAO_ADDR:-}" ]; then
openbao_address=$(compose port openbao 8200)
BAO_ADDR="https://$openbao_address"
fi
BAO_CACERT="$repo_dir/.runtime/security/openbao/ca.crt"
export BAO_ADDR BAO_CACERT ENV_FILE="$env_file"
remaining=60
until curl --silent --show-error --cacert "$BAO_CACERT" \
until curl --silent --show-error --connect-timeout 2 --max-time 3 --cacert "$BAO_CACERT" \
--output /dev/null "$BAO_ADDR/v1/sys/health"; do
remaining=$((remaining - 1))
[ "$remaining" -gt 0 ] || {
@@ -40,7 +43,7 @@ done
ENV_FILE="$env_file" "$script_dir/openbao-init.sh"
ENV_FILE="$env_file" "$script_dir/openbao-unseal.sh"
remaining=60
until curl --fail --silent --show-error --cacert "$BAO_CACERT" \
until curl --fail --silent --show-error --connect-timeout 2 --max-time 3 --cacert "$BAO_CACERT" \
--output /dev/null "$BAO_ADDR/v1/sys/health"; do
remaining=$((remaining - 1))
[ "$remaining" -gt 0 ] || {
+4 -2
View File
@@ -56,8 +56,10 @@ mkdir -p "$runtime_dir"
chmod 0700 "$repo_dir/.runtime/evidence" "$runtime_dir"
trap restore EXIT HUP INT TERM
openbao_address=$(compose port openbao 8200)
BAO_ADDR="https://$openbao_address"
if [ -z "${BAO_ADDR:-}" ]; then
openbao_address=$(compose port openbao 8200)
BAO_ADDR="https://$openbao_address"
fi
BAO_CACERT="$repo_dir/.runtime/security/openbao/ca.crt"
export BAO_ADDR BAO_CACERT
-1
View File
@@ -90,4 +90,3 @@ done
"$script_dir/openbao-issue-approle.sh" worker "$openbao_runtime_dir/approle/worker"
echo "OpenBao policies, AppRoles and KV v2 secrets configured"
+3 -2
View File
@@ -30,7 +30,9 @@ require_file() {
require_private_file() {
require_file "$1"
permissions=$(stat -f '%Lp' "$1" 2>/dev/null || stat -c '%a' "$1")
if ! permissions=$(stat -c '%a' "$1" 2>/dev/null); then
permissions=$(stat -f '%Lp' "$1")
fi
case "$permissions" in
600|400) ;;
*) fail "file must have permissions 0600 or 0400: $1" ;;
@@ -88,4 +90,3 @@ require_unsealed() {
[ "$initialized" = "true" ] || fail "OpenBao is not initialized"
[ "$sealed" = "false" ] || fail "OpenBao is sealed"
}
-1
View File
@@ -43,4 +43,3 @@ mv "$init_file" "$openbao_operator_file"
echo "OpenBao initialized; operator material saved to .runtime/openbao/operator/init.json"
echo "Keep this file offline and run scripts/openbao-unseal.sh"
+1 -1
View File
@@ -79,9 +79,9 @@ if [ -n "$old_accessor" ]; then
fi
if [ "$output_dir" = "$openbao_runtime_dir/approle/$service" ]; then
"$script_dir/sync-docker-workspace.sh"
docker compose --project-directory "$repo_dir" --env-file "${ENV_FILE:-$repo_dir/lab7.env.example}" \
run --rm --no-deps -e SERVICE="$service" openbao-identity-install
fi
echo "issued short-lived AppRole credentials for $service in ${output_dir#"$repo_dir/"}"
-1
View File
@@ -39,4 +39,3 @@ PY
"$script_dir/openbao-issue-approle.sh" "$service" "$openbao_runtime_dir/approle/$service"
echo "$service secret rotated; OpenBao Agent will render the new KV version"
-1
View File
@@ -137,4 +137,3 @@ expect_status worker GET sys/policies/acl 403
expect_status worker POST auth/token/renew-self 200 '{}'
echo "OpenBao AppRole allow/deny and renewal checks passed"
-1
View File
@@ -48,4 +48,3 @@ openbao_status "$status_file"
[ "$(json_field "$status_file" sealed)" = "false" ] || fail "OpenBao remains sealed"
echo "OpenBao unsealed"
+3
View File
@@ -17,6 +17,7 @@ if [ -z "$image_list" ]; then
fi
mkdir -p "$runtime_dir" "$cache_dir"
"$script_dir/sync-docker-workspace.sh"
docker run --rm \
-v "$repo_dir:/src:ro" \
@@ -50,6 +51,8 @@ for image in $image_list; do
image_reports="$image_reports $image=$report"
done
"$script_dir/sync-docker-workspace.sh" --pull-scan
python3 - "$raw_file" "$summary_file" $image_reports <<'PY'
import datetime
import json
+38
View File
@@ -0,0 +1,38 @@
#!/bin/sh
set -eu
[ "${DOCKER_WORKSPACE_MIRROR:-0}" = "1" ] || exit 0
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
repo_dir=$(CDPATH= cd -- "$script_dir/.." && pwd)
mode=${1:-sync}
case "$mode" in
sync|--pull-scan) ;;
*) echo "usage: $0 [--pull-scan]" >&2; exit 2 ;;
esac
[ -f "$repo_dir/compose.yaml" ] || {
echo "repository checkout is incomplete" >&2
exit 1
}
container=$(docker create --network none \
-v "$repo_dir:/workspace" \
alpine:3.24.2 /bin/true)
cleanup() {
docker rm -f "$container" >/dev/null 2>&1 || true
}
trap cleanup EXIT HUP INT TERM
if [ "$mode" = "--pull-scan" ]; then
destination=$repo_dir/evidence/runtime/security-scan
mkdir -p "$destination"
docker cp "$container:/workspace/evidence/runtime/security-scan/." "$destination"
exit 0
fi
docker cp "$repo_dir/." "$container:/workspace"
+1
View File
@@ -25,6 +25,7 @@ compose_rotated() {
}
install_security_material() {
"$script_dir/sync-docker-workspace.sh"
compose run --rm --no-deps security-bootstrap >/dev/null
}