1 Commits
Author SHA1 Message Date
dizi 97a52eeee6 chore: finalize lab7 security verification
CI / verify (pull_request) Failing after 3m27s
2026-11-06 21:39:31 +03:00
10 changed files with 92 additions and 11 deletions
+18 -6
View File
@@ -25,6 +25,8 @@ jobs:
TEMPO_BIND_ADDRESS: 127.0.0.1:0
OPENBAO_BIND_ADDRESS: 127.0.0.1:0
BAO_ADDR: https://openbao:8200
DOCKER_WORKSPACE_MIRROR: "1"
CI_WORKSPACE: /tmp/mtusi2026lab7-${{ github.run_id }}
steps:
- name: Checkout exact commit
run: |
@@ -67,9 +69,14 @@ jobs:
- name: Prepare local stack
run: |
mkdir -p "$CI_WORKSPACE"
git archive HEAD | tar -x -C "$CI_WORKSPACE"
cd "$CI_WORKSPACE"
cp lab7.env.example .env
docker compose config --quiet
./infra/pki/bootstrap.sh
./scripts/openbao-seed.sh .env
./scripts/sync-docker-workspace.sh
docker compose up -d security-bootstrap openbao-permissions openbao
docker network connect "${COMPOSE_PROJECT_NAME}_secrets" "$HOSTNAME"
./scripts/bootstrap-local.sh .env
@@ -82,6 +89,7 @@ jobs:
- name: Integration checks
run: |
cd "$CI_WORKSPACE"
test "$(curl --noproxy '*' --cacert .runtime/security/internal-ca/ca.crt -s -o /dev/null -w '%{http_code}' "https://s3:9000/messenger-attachments")" = "403"
make test BASE_URL=https://nginx:8443 CA_FILE=.runtime/security/public-ca/ca.crt
make test-security BASE_URL=https://nginx:8443 CA_FILE=.runtime/security/public-ca/ca.crt
@@ -101,24 +109,28 @@ jobs:
make scan-security
ENV_FILE=.env CA_FILE=.runtime/security/public-ca/ca.crt PROMETHEUS_URL=http://prometheus:9090 TEMPO_URL=http://tempo:3200 LOKI_URL=http://loki:3100 make test-lab6-smoke BASE_URL=https://nginx:8443
- name: Container logs
if: failure()
run: if [ -f "$CI_WORKSPACE/.env" ]; then cd "$CI_WORKSPACE"; docker compose logs --no-color --tail=200; fi
- name: Upload security evidence
if: always()
uses: actions/upload-artifact@v3
env:
ACTIONS_RUNTIME_URL: https://gitea.privcloud.tech/api/actions_pipeline/
with:
name: lab7-security-${{ github.sha }}
path: |
evidence/lab7-*.json
evidence/runtime/security-scan
${{ env.CI_WORKSPACE }}/evidence/lab7-*.json
${{ env.CI_WORKSPACE }}/evidence/runtime/security-scan
if-no-files-found: warn
retention-days: 14
- name: Container logs
if: failure()
run: if [ -f .env ]; then docker compose logs --no-color --tail=200; fi
- name: Stop local stack
if: always()
run: |
test -d "$CI_WORKSPACE" || exit 0
cd "$CI_WORKSPACE"
docker network disconnect "${COMPOSE_PROJECT_NAME}_secrets" "$HOSTNAME" 2>/dev/null || true
docker network disconnect "${COMPOSE_PROJECT_NAME}_application" "$HOSTNAME" 2>/dev/null || true
docker network disconnect "${COMPOSE_PROJECT_NAME}_data" "$HOSTNAME" 2>/dev/null || true
+11 -1
View File
@@ -32,6 +32,8 @@ jobs:
TEMPO_BIND_ADDRESS: 127.0.0.1:0
OPENBAO_BIND_ADDRESS: 127.0.0.1:0
BAO_ADDR: https://openbao:8200
DOCKER_WORKSPACE_MIRROR: "1"
CI_WORKSPACE: /tmp/mtusi2026lab7-${{ github.run_id }}
API_IMAGE: gitea.privcloud.tech/${{ github.repository_owner }}/mtusi2026lab7-api:${{ github.sha }}
NGINX_IMAGE: gitea.privcloud.tech/${{ github.repository_owner }}/mtusi2026lab7-nginx:${{ github.sha }}
SWAGGER_IMAGE: gitea.privcloud.tech/${{ github.repository_owner }}/mtusi2026lab7-swagger:${{ github.sha }}
@@ -81,9 +83,14 @@ jobs:
- name: Prepare local stack
run: |
mkdir -p "$CI_WORKSPACE"
git archive HEAD | tar -x -C "$CI_WORKSPACE"
cd "$CI_WORKSPACE"
cp lab7.env.example .env
docker compose config --quiet
./infra/pki/bootstrap.sh
./scripts/openbao-seed.sh .env
./scripts/sync-docker-workspace.sh
docker compose up -d security-bootstrap openbao-permissions openbao
docker network connect "${COMPOSE_PROJECT_NAME}_secrets" "$HOSTNAME"
./scripts/bootstrap-local.sh .env
@@ -96,6 +103,7 @@ jobs:
- name: Integration checks
run: |
cd "$CI_WORKSPACE"
test "$(curl --noproxy '*' --cacert .runtime/security/internal-ca/ca.crt -s -o /dev/null -w '%{http_code}' "https://s3:9000/messenger-attachments")" = "403"
make test BASE_URL=https://nginx:8443 CA_FILE=.runtime/security/public-ca/ca.crt
make test-security BASE_URL=https://nginx:8443 CA_FILE=.runtime/security/public-ca/ca.crt
@@ -142,11 +150,13 @@ jobs:
- name: Container logs
if: failure()
run: if [ -f .env ]; then docker compose logs --no-color --tail=200; fi
run: if [ -f "$CI_WORKSPACE/.env" ]; then cd "$CI_WORKSPACE"; docker compose logs --no-color --tail=200; fi
- name: Stop local stack
if: always()
run: |
test -d "$CI_WORKSPACE" || exit 0
cd "$CI_WORKSPACE"
docker network disconnect "${COMPOSE_PROJECT_NAME}_secrets" "$HOSTNAME" 2>/dev/null || true
docker network disconnect "${COMPOSE_PROJECT_NAME}_application" "$HOSTNAME" 2>/dev/null || true
docker network disconnect "${COMPOSE_PROJECT_NAME}_data" "$HOSTNAME" 2>/dev/null || true
+14 -2
View File
@@ -21,6 +21,8 @@ jobs:
TEMPO_BIND_ADDRESS: 127.0.0.1:0
OPENBAO_BIND_ADDRESS: 127.0.0.1:0
BAO_ADDR: https://openbao:8200
DOCKER_WORKSPACE_MIRROR: "1"
CI_WORKSPACE: /tmp/mtusi2026lab7-${{ github.run_id }}
steps:
- name: Checkout exact commit
run: |
@@ -36,9 +38,14 @@ jobs:
- name: Prepare stack
run: |
mkdir -p "$CI_WORKSPACE"
git archive HEAD | tar -x -C "$CI_WORKSPACE"
cd "$CI_WORKSPACE"
cp lab7.env.example .env
docker compose config --quiet
./infra/pki/bootstrap.sh
./scripts/openbao-seed.sh .env
./scripts/sync-docker-workspace.sh
docker compose up -d security-bootstrap openbao-permissions openbao
docker network connect "${COMPOSE_PROJECT_NAME}_secrets" "$HOSTNAME"
./scripts/bootstrap-local.sh .env
@@ -51,6 +58,7 @@ jobs:
- name: Reproduce SLO incidents
run: |
cd "$CI_WORKSPACE"
ENV_FILE=.env \
BASE_URL=https://nginx:8443 \
CA_FILE=.runtime/security/public-ca/ca.crt \
@@ -63,19 +71,23 @@ jobs:
- name: Upload sanitized evidence
if: always()
uses: actions/upload-artifact@v3
env:
ACTIONS_RUNTIME_URL: https://gitea.privcloud.tech/api/actions_pipeline/
with:
name: lab6-incidents-${{ github.sha }}
path: evidence/runtime/ci
path: ${{ env.CI_WORKSPACE }}/evidence/runtime/ci
if-no-files-found: warn
retention-days: 14
- name: Container logs
if: failure()
run: docker compose logs --no-color --tail=200
run: if [ -f "$CI_WORKSPACE/.env" ]; then cd "$CI_WORKSPACE"; docker compose logs --no-color --tail=200; fi
- name: Stop local stack
if: always()
run: |
test -d "$CI_WORKSPACE" || exit 0
cd "$CI_WORKSPACE"
docker network disconnect "${COMPOSE_PROJECT_NAME}_secrets" "$HOSTNAME" 2>/dev/null || true
docker network disconnect "${COMPOSE_PROJECT_NAME}_application" "$HOSTNAME" 2>/dev/null || true
docker network disconnect "${COMPOSE_PROJECT_NAME}_data" "$HOSTNAME" 2>/dev/null || true
+1
View File
@@ -343,6 +343,7 @@ services:
openbao-cli:
profiles: ["tools"]
image: openbao/openbao:2.7.1
user: "0:0"
environment:
BAO_ADDR: https://openbao:8200
BAO_CACERT: /run/security/openbao/ca.crt
+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 "$@"
+3 -2
View File
@@ -20,6 +20,7 @@ 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
if [ -z "${BAO_ADDR:-}" ]; then
openbao_address=$(compose port openbao 8200)
@@ -29,7 +30,7 @@ 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 ] || {
@@ -42,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 ] || {
+1
View File
@@ -79,6 +79,7 @@ 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
+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
}