/home/techb158/balavpn.abdallabala.com/docs
NameSizeModeActions
00-design-study.md36780644editdlrm
01-uml-class-diagram.puml118690644editdlrm
02-use-case-diagram.puml37630644editdlrm
03-sequence-diagrams.puml97320644editdlrm
04-database-entity-model.mmd70510644editdlrm
05-database-schema.sql133720644editdlrm
06-diagram-preview.html50210644editdlrm
07-design-checklist.md32560644editdlrm
08-step-2-storage-layer.md53250644editdlrm
09-step-3-risk-crud-ui.md33800644editdlrm
10-step-4-mitigation-workflow.md39960644editdlrm
11-step-5-deployment-gate-workflow.md22920644editdlrm
12-step-6-multi-pm-integration.md37700644editdlrm
13-step-6-1-microsoft-planner-integration.md23350644editdlrm
14-step-7-reporting-export.md41580644editdlrm
15-step-7-1-oauth-live-connectors.md45450644editdlrm
16-step-8-user-roles-access-control.md32970644editdlrm
17-step-9-production-deployment-security.md42280644editdlrm
18-step-10-final-academic-submission.md31990644editdlrm
19-final-report-draft.md68140644editdlrm
20-instructor-submission-checklist.md36390644editdlrm
21-demo-script.md39480644editdlrm
22-traceability-matrix.md48470644editdlrm
23-testing-evidence.md29610644editdlrm
24-evaluation-rubric-mapping.md29100644editdlrm
25-final-deployment-runbook.md32140644editdlrm
26-known-limitations-and-future-work.md26320644editdlrm
27-final-qa-checklist.md28930644editdlrm
28-demo-rehearsal-script.md36180644editdlrm
29-submission-freeze-report.md27690644editdlrm
30-final-known-issues.md18760644editdlrm
31-saas-rebuild-implementation.md25710644editdlrm
application-documentation.md275150644editdlrm
conversation-log.md185030644editdlrm
dashboard-spec.md36910644editdlrm
database-guide.md378260644editdlrm
development-summary.md70700644editdlrm
github-architecture.svg62880644editdlrm
Edit: /home/techb158/balavpn.abdallabala.com/docs/17-step-9-production-deployment-security.md (4228B)
# Step 9, Production Deployment and Security Hardening ## Purpose Step 9 prepares the COSMIC AI-Risk Dashboard for controlled deployment on a server. This step does not change the risk model. It adds operational controls around the existing dashboard, API, OAuth connectors, reporting module, and role-based access control. ## Source alignment The project source positions COSMIC-Risk as a software prototype and REST API for automated, reproducible AI risk analysis and project-management integration. The production layer is an implementation extension needed to operate that prototype safely. ## Scope | Area | Implementation | |---|---| | Runtime configuration | Central `runtimeConfig` module using environment variables | | Security headers | CSP, no-sniff, referrer policy, permissions policy, frame policy, optional HSTS | | HTTPS support | Reverse-proxy aware HTTPS enforcement | | CORS control | Explicit origin allowlist through environment variables | | Readiness checks | `/api/ready` validates config, database access, and backup directory | | Security status | `/api/operations/security` exposes safe configuration summary | | Backups | Backup API and CLI script create database copy with SHA-256 manifest | | Deployment files | Dockerfile, docker-compose, Nginx example, systemd service | | Production scripts | Config check and backup scripts | | Tests | Production hardening test suite | ## New API endpoints | Method | Endpoint | Permission | Purpose | |---|---|---|---| | GET | `/api/ready` | public | Readiness probe for deployment monitoring | | GET | `/api/operations/security` | `audit:read` | Review safe security configuration status | | GET | `/api/operations/backups` | `audit:read` | List backup manifests | | POST | `/api/operations/backups` | `user:write` | Create a database backup | ## New environment variables | Variable | Default | Purpose | |---|---|---| | `NODE_ENV` | `development` | Runtime mode | | `COSMIC_SECURITY_HEADERS_ENABLED` | `true` | Enable security response headers | | `COSMIC_FORCE_HTTPS` | `false` in local `.env.example` | Redirect GET/HEAD traffic to HTTPS when enabled | | `COSMIC_TRUST_PROXY` | `false` in local `.env.example` | Trust `X-Forwarded-Proto` behind Nginx or another reverse proxy | | `COSMIC_HSTS_ENABLED` | `false` in local `.env.example` | Add HSTS when request is HTTPS | | `COSMIC_ALLOWED_ORIGINS` | empty | Comma-separated CORS allowlist | | `COSMIC_FRAME_ANCESTORS` | `'self'` | CSP frame ancestor list | | `COSMIC_MAX_BODY_BYTES` | `1048576` | API JSON body limit | | `COSMIC_BACKUP_DIR` | `./backups` | Backup output directory | | `COSMIC_BACKUP_RETENTION` | `10` | Number of backups retained | | `COSMIC_REQUEST_LOG_ENABLED` | `false` | Structured request logging | ## Production commands ```bash npm run check:config npm test npm run backup NODE_ENV=production npm start ``` ## Docker deployment ```bash cp .env.example .env # edit .env with production values mkdir -p data backups docker compose up --build -d curl http://localhost:8090/api/ready ``` ## Nginx deployment Use `deploy/nginx.conf` as a starting point. In production, terminate TLS at Nginx and set: ```env NODE_ENV=production COSMIC_TRUST_PROXY=true COSMIC_FORCE_HTTPS=true COSMIC_HSTS_ENABLED=true COSMIC_PUBLIC_BASE_URL=https://your-domain.example ``` ## Backup behavior The backup module copies the JSON database to the backup directory and creates a manifest file containing: - backup ID - actor user ID - source file - backup file path - creation timestamp - file size - SHA-256 digest The backup keeps OAuth token ciphertext as stored in the database. The backup directory must therefore be protected like a production secret store. ## Acceptance criteria | Check | Expected result | |---|---| | `/api/health` | Returns service version `2.0.0` | | `/api/ready` | Returns `ok: true` when database and backup directory are available | | Security headers | API and static responses include CSP, no-sniff, referrer policy, and permissions policy | | Backup script | `npm run backup` creates JSON backup and manifest | | Config script | `npm run check:config` prints safe runtime summary | | Tests | `npm test` passes including production hardening tests |