forked from mtusi2026/mtusi2026lab7
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6e91c0c22 |
+6
-18
@@ -25,8 +25,6 @@ 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: |
|
||||
@@ -69,14 +67,9 @@ 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
|
||||
@@ -89,7 +82,6 @@ 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
|
||||
@@ -109,28 +101,24 @@ 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: |
|
||||
${{ env.CI_WORKSPACE }}/evidence/lab7-*.json
|
||||
${{ env.CI_WORKSPACE }}/evidence/runtime/security-scan
|
||||
evidence/lab7-*.json
|
||||
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
|
||||
|
||||
@@ -32,8 +32,6 @@ 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 }}
|
||||
@@ -83,14 +81,9 @@ 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
|
||||
@@ -103,7 +96,6 @@ 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
|
||||
@@ -150,13 +142,11 @@ jobs:
|
||||
|
||||
- name: Container logs
|
||||
if: failure()
|
||||
run: if [ -f "$CI_WORKSPACE/.env" ]; then cd "$CI_WORKSPACE"; docker compose logs --no-color --tail=200; fi
|
||||
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
|
||||
|
||||
@@ -21,8 +21,6 @@ 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: |
|
||||
@@ -38,14 +36,9 @@ 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
|
||||
@@ -58,7 +51,6 @@ 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 \
|
||||
@@ -71,23 +63,19 @@ 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: ${{ env.CI_WORKSPACE }}/evidence/runtime/ci
|
||||
path: evidence/runtime/ci
|
||||
if-no-files-found: warn
|
||||
retention-days: 14
|
||||
|
||||
- name: Container logs
|
||||
if: failure()
|
||||
run: if [ -f "$CI_WORKSPACE/.env" ]; then cd "$CI_WORKSPACE"; docker compose logs --no-color --tail=200; fi
|
||||
run: docker compose logs --no-color --tail=200
|
||||
|
||||
- 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
|
||||
|
||||
@@ -343,7 +343,6 @@ 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
|
||||
|
||||
@@ -6,7 +6,5 @@ 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 "$@"
|
||||
|
||||
@@ -20,7 +20,6 @@ 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)
|
||||
@@ -30,7 +29,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 --connect-timeout 2 --max-time 3 --cacert "$BAO_CACERT" \
|
||||
until curl --silent --show-error --cacert "$BAO_CACERT" \
|
||||
--output /dev/null "$BAO_ADDR/v1/sys/health"; do
|
||||
remaining=$((remaining - 1))
|
||||
[ "$remaining" -gt 0 ] || {
|
||||
@@ -43,7 +42,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 --connect-timeout 2 --max-time 3 --cacert "$BAO_CACERT" \
|
||||
until curl --fail --silent --show-error --cacert "$BAO_CACERT" \
|
||||
--output /dev/null "$BAO_ADDR/v1/sys/health"; do
|
||||
remaining=$((remaining - 1))
|
||||
[ "$remaining" -gt 0 ] || {
|
||||
|
||||
@@ -79,7 +79,6 @@ 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
|
||||
|
||||
@@ -17,7 +17,6 @@ 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" \
|
||||
@@ -51,8 +50,6 @@ 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
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
#!/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"
|
||||
@@ -25,7 +25,6 @@ compose_rotated() {
|
||||
}
|
||||
|
||||
install_security_material() {
|
||||
"$script_dir/sync-docker-workspace.sh"
|
||||
compose run --rm --no-deps security-bootstrap >/dev/null
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user