Files
ss-tools/docker/nginx.conf
busya 20071b8c7a security: fullstack hardening — task ownership, mapping validation, API-key scoping, test fixes
Backend:
- Add validate_mapping_database_ownership() to verify source/target UUIDs
  belong to declared environments before persisting mappings (mappings.py)
- Add API-key environment scoping to get_mappings (filter) and
  suggest_mappings_api (enforce) (mappings.py)
- Add user_id Column to TaskRecord model + Alembic migration (task.py)
- Persist task.user_id on save, restore on load (persistence.py)
- Wire current_user.id into migrate_dashboards + backup_dashboards
  task creation (_action_routes.py)
- Fix test_migration_routes.py: module-level patch leak → autouse fixture,
  SupersetClient→AsyncSupersetClient, AsyncMock for sync_environment/run
- Fix 7 Pydantic serializer warnings: 'PENDING'→TaskStatus.PENDING
  in test_tasks.py + import TaskStatus

Frontend:
- Deepen isDryRunResult(): validate selection field, risk.items entries
  (all 5 fields), and diff object uuids individually (ExecutorModel.svelte.ts)

Prior work included: task password redaction, resume ownership checks,
canonical dry-run DTO alignment, migration UI callback fixes, credential
exposure reduction, assistant dry-run await fix.
2026-07-15 23:02:23 +03:00

92 lines
3.5 KiB
Nginx Configuration File

# #region docker.nginx.conf [C:3] [TYPE Module] [SEMANTICS nginx,proxy,frontend,api,ws,observability]
# @BRIEF HTTP-only nginx config — serves SvelteKit static files, proxies API/WS, and emits correlated JSON access logs.
# @PRE Docker DNS resolves backend:8000; built SvelteKit output at /usr/share/nginx/html.
# @POST Static SPA fallback works; /api/ and /ws/ reach backend with upgrade headers.
# Proxy access records are JSON on stdout and include client X-Trace-ID/timings.
# @LAYER Infrastructure
# @RELATION DEPENDS_ON -> [docker.frontend.entrypoint]
# @RELATION BINDS_TO -> [backend:8000]
# @INVARIANT /api/ and /ws/ preserve request URI, Authorization, and X-Trace-ID headers.
# @RATIONALE stdout JSON logs survive container log aggregation and make nginx/backend/agent event correlation queryable.
# @REJECTED Nginx HTTPS in this file rejected — SSL variant selected only when certificates exist.
# #endregion docker.nginx.conf
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# JSON access records are container-stdout friendly and correlate proxy, backend,
# and Gradio agent activity through the client-provided X-Trace-ID header.
log_format observability_json escape=json '{'
'"ts":"$time_iso8601",'
'"trace_id":"$http_x_trace_id",'
'"request_id":"$request_id",'
'"remote_addr":"$remote_addr",'
'"method":"$request_method",'
'"uri":"$uri",'
'"status":$status,'
'"upstream_status":"$upstream_status",'
'"request_time":$request_time,'
'"upstream_response_time":"$upstream_response_time"'
'}';
access_log /dev/stdout observability_json;
error_log /dev/stderr warn;
server {
listen 80;
server_name _;
resolver 127.0.0.11 ipv6=off;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
# Gradio agent proxy — must be before /api/ (longest prefix match wins)
location /api/agent/gradio/ {
set $agent_api http://agent:7860;
proxy_pass $agent_api;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header Authorization $http_authorization;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Trace-ID $http_x_trace_id;
proxy_redirect http://agent:7860/ /api/agent/gradio/;
proxy_read_timeout 300s;
}
location /api/ {
set $backend_api http://backend:8000;
proxy_pass $backend_api;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Trace-ID $http_x_trace_id;
proxy_read_timeout 300s;
}
location /ws/ {
set $backend_ws http://backend:8000;
proxy_pass $backend_ws;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Trace-ID $http_x_trace_id;
proxy_read_timeout 300s;
}
}