Implement lab7 security and compromised worker recovery evidence

This commit is contained in:
2026-11-27 22:04:57 +03:00
parent 20afc2c790
commit 2bd97c8838
256 changed files with 36364 additions and 36 deletions
+5
View File
@@ -0,0 +1,5 @@
set -eu
export INSTANCE_ID="$(cat /proc/sys/kernel/random/uuid)"
printf '%s' "$INSTANCE_ID" > /tmp/instance-id
export OTEL_RESOURCE_ATTRIBUTES="deployment.environment.name=lab,service.version=7.0.0,service.instance.id=$INSTANCE_ID"
exec java -Dfile.encoding=UTF-8 ${JAVA_OPTS:-} -jar app.jar
+6
View File
@@ -0,0 +1,6 @@
storage_source "file" { path = "/old" }
storage_destination "raft" {
path = "/bao/file"
node_id = "bao-1"
}
cluster_addr = "https://127.0.0.1:8201"
+14
View File
@@ -0,0 +1,14 @@
ui = true
storage "raft" {
path = "/bao/file"
node_id = "bao-1"
}
listener "tcp" {
address = "0.0.0.0:8200"
tls_cert_file = "/identity/service.crt"
tls_key_file = "/identity/service.key"
tls_client_ca_file = "/pki/ca.crt"
}
api_addr = "https://openbao:8200"
cluster_addr = "https://openbao:8201"
+42
View File
@@ -0,0 +1,42 @@
pid /tmp/nginx.pid;
worker_shutdown_timeout 5s;
error_log /dev/stderr warn;
events { worker_connections 1024; }
http { access_log off; client_body_temp_path /tmp/body; proxy_temp_path /tmp/proxy; client_max_body_size 11m; ssl_certificate /identity/service.crt; ssl_certificate_key /identity/service.key; ssl_client_certificate /pki/ca.crt; ssl_crl /pki/ca.crl; ssl_protocols TLSv1.2 TLSv1.3; ssl_session_tickets off; ssl_session_cache off; server { listen 3000 ssl; location / { proxy_pass http://127.0.0.1:13000; proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto https; } }
map $ssl_client_s_dn $allowed_4318 { default 0; CN=api 1; CN=worker 1; CN=dispatcher 1; }
server { listen 4318 ssl; ssl_verify_client on;
location / { if ($allowed_4318 = 0) { return 403; } proxy_pass http://127.0.0.1:14318; proxy_http_version 1.1; }
}
map $ssl_client_s_dn $allowed_8888 { default 0; CN=prometheus 1; }
server { listen 8888 ssl; ssl_verify_client on;
location / { if ($allowed_8888 = 0) { return 403; } proxy_pass http://127.0.0.1:18888; proxy_http_version 1.1; }
}
map $ssl_client_s_dn $allowed_8889 { default 0; CN=prometheus 1; }
server { listen 8889 ssl; ssl_verify_client on;
location / { if ($allowed_8889 = 0) { return 403; } proxy_pass http://127.0.0.1:18889; proxy_http_version 1.1; }
}
map $ssl_client_s_dn $allowed_9090 { default 0; CN=grafana 1; CN=operator 1; }
server { listen 9090 ssl; ssl_verify_client on;
location / { if ($allowed_9090 = 0) { return 403; } proxy_pass http://127.0.0.1:19090; proxy_http_version 1.1; }
}
map "$ssl_client_s_dn:$request_method:$uri" $loki_action {
default 0;
~^CN=collector:POST:/otlp/v1/logs$ 1;
~^CN=(grafana|operator):GET:/(loki/api/v1/|ready) 1;
}
map $ssl_client_s_dn $allowed_3100 { default 0; CN=collector 1; CN=grafana 1; CN=operator 1; }
server { listen 3100 ssl; ssl_verify_client on;
location / { if ($loki_action = 0) { return 403; } proxy_pass http://127.0.0.1:13100; proxy_http_version 1.1; }
}
map $ssl_client_s_dn $allowed_3200 { default 0; CN=grafana 1; CN=operator 1; }
server { listen 3200 ssl; ssl_verify_client on;
location / { if ($request_method != GET) { return 403; } if ($allowed_3200 = 0) { return 403; } proxy_pass http://127.0.0.1:13200; proxy_http_version 1.1; }
}
}
stream { ssl_certificate /identity/service.crt; ssl_certificate_key /identity/service.key; ssl_client_certificate /pki/ca.crt; ssl_crl /pki/ca.crl; ssl_protocols TLSv1.2 TLSv1.3; ssl_session_tickets off; ssl_session_cache off; map $ssl_client_s_dn $target_6379 { default 127.0.0.1:9; CN=worker 127.0.0.1:16379; CN=dispatcher 127.0.0.1:16379; CN=api 127.0.0.1:16379; CN=operator 127.0.0.1:16379; }
server { listen 6379 ssl; ssl_verify_client on; proxy_connect_timeout 2s; proxy_timeout 10s; proxy_pass $target_6379; }
map $ssl_client_s_dn $target_6380 { default 127.0.0.1:9; CN=api 127.0.0.1:16380; CN=operator 127.0.0.1:16380; }
server { listen 6380 ssl; ssl_verify_client on; proxy_connect_timeout 2s; proxy_timeout 10s; proxy_pass $target_6380; }
map $ssl_client_s_dn $target_4317 { default 127.0.0.1:9; CN=collector 127.0.0.1:14317; }
server { listen 4317 ssl; ssl_alpn h2; ssl_verify_client on; proxy_connect_timeout 2s; proxy_timeout 10s; proxy_pass $target_4317; }
}
+5
View File
@@ -0,0 +1,5 @@
set -eu
export TLS_CA="$(cat /pki/ca.crt)"
export TLS_CERT="$(cat /identity/service.crt)"
export TLS_KEY="$(cat /identity/service.key)"
exec /run.sh
+3
View File
@@ -0,0 +1,3 @@
local all all trust
hostssl messenger api,worker,dispatcher,pipeline_operator all scram-sha-256
host all all all reject
+1
View File
@@ -0,0 +1 @@
{"Version": "2012-10-17", "Statement": [{"Effect": "Allow", "Action": ["s3:GetBucketLocation", "s3:ListBucket"], "Resource": ["arn:aws:s3:::messenger-attachments"]}, {"Effect": "Allow", "Action": ["s3:PutObject", "s3:GetObject", "s3:DeleteObject"], "Resource": ["arn:aws:s3:::messenger-attachments/staging/*"]}, {"Effect": "Allow", "Action": ["s3:GetObject"], "Resource": ["arn:aws:s3:::messenger-attachments/results/*"]}]}
+2
View File
@@ -0,0 +1,2 @@
path "secret/data/api" { capabilities = ["read"] }
path "auth/token/revoke-self" { capabilities = ["update"] }
@@ -0,0 +1 @@
{"Version": "2012-10-17", "Statement": [{"Effect": "Allow", "Action": ["s3:GetBucketLocation", "s3:ListBucket"], "Resource": ["arn:aws:s3:::messenger-attachments"]}, {"Effect": "Allow", "Action": ["s3:DeleteObject"], "Resource": ["arn:aws:s3:::messenger-attachments/staging/*"]}, {"Effect": "Allow", "Action": ["s3:DeleteObject"], "Resource": ["arn:aws:s3:::messenger-attachments/results/*"]}]}
+2
View File
@@ -0,0 +1,2 @@
path "secret/data/dispatcher" { capabilities = ["read"] }
path "auth/token/revoke-self" { capabilities = ["update"] }
+1
View File
@@ -0,0 +1 @@
{"Version": "2012-10-17", "Statement": [{"Effect": "Allow", "Action": ["s3:GetBucketLocation"], "Resource": ["arn:aws:s3:::messenger-attachments"]}, {"Effect": "Allow", "Action": ["s3:GetObject", "s3:DeleteObject"], "Resource": ["arn:aws:s3:::messenger-attachments/staging/*"]}, {"Effect": "Allow", "Action": ["s3:PutObject", "s3:GetObject"], "Resource": ["arn:aws:s3:::messenger-attachments/results/*"]}]}
+2
View File
@@ -0,0 +1,2 @@
path "secret/data/worker" { capabilities = ["read"] }
path "auth/token/revoke-self" { capabilities = ["update"] }
+7
View File
@@ -0,0 +1,7 @@
set -eu
mkdir -p /tmp/pg-tls
cp /identity/service.crt /tmp/pg-tls/server.crt
cp /identity/service.key /tmp/pg-tls/server.key
chown -R postgres:postgres /tmp/pg-tls
chmod 600 /tmp/pg-tls/server.key
exec /usr/local/bin/docker-entrypoint.sh "$@"