diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..90ad73a3 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,22 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Attach to Backend (Docker)", + "type": "go", + "request": "attach", + "mode": "remote", + "substitutePath": [ + { + "from": "${workspaceFolder}", + "to": "/app" + } + ], + "port": 2345, + "host": "127.0.0.1", + "showLog": true, + "trace": "log", + "logOutput": "rpc" + } + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..ebbec94a --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,26 @@ +{ + "gopls": { + "buildFlags": ["-tags=integration"] + }, + "[go]": { + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.organizeImports": "explicit" + } + }, + "go.useLanguageServer": true, + "go.lintOnSave": "workspace", + "go.vetOnSave": "workspace", + "yaml.validate": false, + "yaml.schemaStore.enable": false, + "files.exclude": {}, + "search.exclude": {}, + "files.associations": {}, + "python-envs.pythonProjects": [ + { + "path": "", + "envManager": "ms-python.python:system", + "packageManager": "ms-python.python:pip" + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..4129a91f --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,555 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Docker Compose Up", + "type": "shell", + "command": "docker compose -f .docker/compose/docker-compose.test.yml up -d && echo 'Charon running at http://localhost:8787'", + "group": "build", + "problemMatcher": [] + }, + { + "label": "Build & Run: Local Docker Image", + "type": "shell", + "command": "docker build -t charon:local . && docker compose -f .docker/compose/docker-compose.test.yml up -d && echo 'Charon running at http://localhost:8787'", + "group": "build", + "problemMatcher": [] + }, + { + "label": "Build & Run: Local Docker Image No-Cache", + "type": "shell", + "command": "docker build --no-cache -t charon:local . && docker compose -f .docker/compose/docker-compose.test.yml up -d && echo 'Charon running at http://localhost:8787'", + "group": "build", + "problemMatcher": [] + }, + { + "label": "Build: Backend", + "type": "shell", + "command": "cd backend && go build ./...", + "group": "build", + "problemMatcher": ["$go"] + }, + { + "label": "Build: Frontend", + "type": "shell", + "command": "cd frontend && npm run build", + "group": "build", + "problemMatcher": [] + }, + { + "label": "Build: All", + "type": "shell", + "dependsOn": ["Build: Backend", "Build: Frontend"], + "dependsOrder": "sequence", + "command": "echo 'Build complete'", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [] + }, + { + "label": "Test: Backend Unit Tests", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh test-backend-unit", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Test: Backend Unit (Verbose)", + "type": "shell", + "command": "cd backend && if command -v gotestsum &> /dev/null; then gotestsum --format testdox ./...; else go test -v ./...; fi", + "group": "test", + "problemMatcher": ["$go"] + }, + { + "label": "Test: Backend Unit (Quick)", + "type": "shell", + "command": "cd backend && go test -short ./...", + "group": "test", + "problemMatcher": ["$go"] + }, + { + "label": "Test: Backend with Coverage", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh test-backend-coverage", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Test: Frontend", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh test-frontend-unit", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Test: Frontend with Coverage", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh test-frontend-coverage", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Test: E2E Playwright (Chromium)", + "type": "shell", + "command": "npm run e2e", + "group": "test", + "problemMatcher": [], + "presentation": { + "reveal": "always", + "panel": "dedicated", + "close": false + } + }, + { + "label": "Test: E2E Playwright (Chromium) - Cerberus: Real-Time Logs", + "type": "shell", + "command": "PLAYWRIGHT_HTML_OPEN=never npx playwright test --project=chromium tests/monitoring/real-time-logs.spec.ts", + "group": "test", + "problemMatcher": [], + "presentation": { + "reveal": "always", + "panel": "dedicated", + "close": false + } + }, + { + "label": "Test: E2E Playwright (Chromium) - Cerberus: Security Dashboard", + "type": "shell", + "command": "PLAYWRIGHT_HTML_OPEN=never npx playwright test --project=chromium tests/security/security-dashboard.spec.ts", + "group": "test", + "problemMatcher": [], + "presentation": { + "reveal": "always", + "panel": "dedicated", + "close": false + } + }, + { + "label": "Test: E2E Playwright (Chromium) - Cerberus: Rate Limiting", + "type": "shell", + "command": "PLAYWRIGHT_HTML_OPEN=never npx playwright test --project=chromium tests/security/rate-limiting.spec.ts", + "group": "test", + "problemMatcher": [], + "presentation": { + "reveal": "always", + "panel": "dedicated", + "close": false + } + }, + { + "label": "Test: E2E Playwright (All Browsers)", + "type": "shell", + "command": "npm run e2e:all", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Test: E2E Playwright (Headed)", + "type": "shell", + "command": "npm run e2e:headed", + "group": "test", + "problemMatcher": [], + "presentation": { + "reveal": "always", + "panel": "dedicated" + } + }, + { + "label": "Lint: Pre-commit (All Files)", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh qa-precommit-all", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Lint: Go Vet", + "type": "shell", + "command": "cd backend && go vet ./...", + "group": "test", + "problemMatcher": ["$go"] + }, + { + "label": "Lint: Staticcheck (Fast)", + "type": "shell", + "command": "cd backend && golangci-lint run --config .golangci-fast.yml ./...", + "group": "test", + "problemMatcher": ["$go"], + "presentation": { + "reveal": "always", + "panel": "dedicated" + } + }, + { + "label": "Lint: Staticcheck Only", + "type": "shell", + "command": "cd backend && golangci-lint run --config .golangci-fast.yml --disable-all --enable staticcheck ./...", + "group": "test", + "problemMatcher": ["$go"] + }, + { + "label": "Lint: GolangCI-Lint (Docker)", + "type": "shell", + "command": "cd backend && docker run --rm -v $(pwd):/app:ro -w /app golangci/golangci-lint:latest golangci-lint run -v", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Lint: Frontend", + "type": "shell", + "command": "cd frontend && npm run lint", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Lint: Frontend (Fix)", + "type": "shell", + "command": "cd frontend && npm run lint -- --fix", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Lint: TypeScript Check", + "type": "shell", + "command": "cd frontend && npm run type-check", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Lint: Markdownlint", + "type": "shell", + "command": "markdownlint '**/*.md' --ignore node_modules --ignore frontend/node_modules --ignore .venv --ignore test-results --ignore codeql-db --ignore codeql-agent-results", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Lint: Markdownlint (Fix)", + "type": "shell", + "command": "markdownlint '**/*.md' --fix --ignore node_modules --ignore frontend/node_modules --ignore .venv --ignore test-results --ignore codeql-db --ignore codeql-agent-results", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Lint: Hadolint Dockerfile", + "type": "shell", + "command": "docker run --rm -i hadolint/hadolint < Dockerfile", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Security: Trivy Scan", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh security-scan-trivy", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Security: Scan Docker Image (Local)", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh security-scan-docker-image", + "group": "test", + "problemMatcher": [], + "presentation": { + "reveal": "always", + "panel": "dedicated", + "close": false + } + }, + { + "label": "Security: CodeQL Go Scan (DEPRECATED)", + "type": "shell", + "command": "codeql database create codeql-db-go --language=go --source-root=backend --overwrite && codeql database analyze codeql-db-go /projects/codeql/codeql/go/ql/src/codeql-suites/go-security-extended.qls --format=sarif-latest --output=codeql-results-go.sarif", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Security: CodeQL JS Scan (DEPRECATED)", + "type": "shell", + "command": "codeql database create codeql-db-js --language=javascript --source-root=frontend --overwrite && codeql database analyze codeql-db-js /projects/codeql/codeql/javascript/ql/src/codeql-suites/javascript-security-extended.qls --format=sarif-latest --output=codeql-results-js.sarif", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Security: CodeQL Go Scan (CI-Aligned) [~60s]", + "type": "shell", + "command": "rm -rf codeql-db-go && codeql database create codeql-db-go --language=go --source-root=backend --codescanning-config=.github/codeql/codeql-config.yml --overwrite --threads=0 && codeql database analyze codeql-db-go --additional-packs=codeql-custom-queries-go --format=sarif-latest --output=codeql-results-go.sarif --sarif-add-baseline-file-info --threads=0", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Security: CodeQL JS Scan (CI-Aligned) [~90s]", + "type": "shell", + "command": "rm -rf codeql-db-js && codeql database create codeql-db-js --language=javascript --build-mode=none --source-root=frontend --codescanning-config=.github/codeql/codeql-config.yml --overwrite --threads=0 && codeql database analyze codeql-db-js --format=sarif-latest --output=codeql-results-js.sarif --sarif-add-baseline-file-info --threads=0", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Security: CodeQL All (CI-Aligned)", + "type": "shell", + "dependsOn": ["Security: CodeQL Go Scan (CI-Aligned) [~60s]", "Security: CodeQL JS Scan (CI-Aligned) [~90s]"], + "dependsOrder": "sequence", + "command": "echo 'CodeQL complete'", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Security: CodeQL Scan (Skill)", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh security-scan-codeql", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Security: Go Vulnerability Check", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh security-scan-go-vuln", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Docker: Start Dev Environment", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh docker-start-dev", + "group": "none", + "problemMatcher": [] + }, + { + "label": "Docker: Stop Dev Environment", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh docker-stop-dev", + "group": "none", + "problemMatcher": [] + }, + { + "label": "Docker: Start Local Environment", + "type": "shell", + "command": "docker compose -f .docker/compose/docker-compose.local.yml up -d", + "group": "none", + "problemMatcher": [] + }, + { + "label": "Docker: Stop Local Environment", + "type": "shell", + "command": "docker compose -f .docker/compose/docker-compose.local.yml down", + "group": "none", + "problemMatcher": [] + }, + { + "label": "Docker: View Logs", + "type": "shell", + "command": "docker compose -f .docker/compose/docker-compose.yml logs -f", + "group": "none", + "problemMatcher": [], + "isBackground": true + }, + { + "label": "Docker: Prune Unused Resources", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh docker-prune", + "group": "none", + "problemMatcher": [] + }, + { + "label": "Integration: Run All", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh integration-test-all", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Integration: Coraza WAF", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh integration-test-coraza", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Integration: CrowdSec", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh integration-test-crowdsec", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Integration: CrowdSec Decisions", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh integration-test-crowdsec-decisions", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Integration: CrowdSec Startup", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh integration-test-crowdsec-startup", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Utility: Check Version Match Tag", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh utility-version-check", + "group": "none", + "problemMatcher": [] + }, + { + "label": "Utility: Clear Go Cache", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh utility-clear-go-cache", + "group": "none", + "problemMatcher": [] + }, + { + "label": "Utility: Bump Beta Version", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh utility-bump-beta", + "group": "none", + "problemMatcher": [] + }, + { + "label": "Utility: Database Recovery", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh utility-db-recovery", + "group": "none", + "problemMatcher": [] + }, + { + "label": "Security: Verify SBOM", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh security-verify-sbom ${input:dockerImage}", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Security: Sign with Cosign", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh security-sign-cosign docker charon:local", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Security: Generate SLSA Provenance", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh security-slsa-provenance generate ./backend/main", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Security: Full Supply Chain Audit", + "type": "shell", + "dependsOn": [ + "Security: Verify SBOM", + "Security: Sign with Cosign", + "Security: Generate SLSA Provenance" + ], + "dependsOrder": "sequence", + "command": "echo '✅ Supply chain audit complete'", + "group": "test", + "problemMatcher": [] + }, + { + "label": "Test: E2E Playwright (Skill)", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh test-e2e-playwright", + "group": "test", + "problemMatcher": [], + "presentation": { + "reveal": "always", + "panel": "dedicated", + "close": false + } + }, + { + "label": "Test: E2E Playwright with Coverage", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh test-e2e-playwright-coverage", + "group": "test", + "problemMatcher": [], + "presentation": { + "reveal": "always", + "panel": "dedicated", + "close": false + } + }, + { + "label": "Test: E2E Playwright - View Report", + "type": "shell", + "command": "npx playwright show-report --port 9323", + "group": "none", + "problemMatcher": [], + "isBackground": true, + "presentation": { + "reveal": "always", + "panel": "dedicated", + "close": false + } + }, + { + "label": "Docker: Rebuild E2E Environment", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh docker-rebuild-e2e", + "group": "build", + "problemMatcher": [], + "presentation": { + "reveal": "always", + "panel": "dedicated", + "close": false + } + }, + { + "label": "Docker: Rebuild E2E Environment (Clean)", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh docker-rebuild-e2e --clean --no-cache", + "group": "build", + "problemMatcher": [], + "presentation": { + "reveal": "always", + "panel": "dedicated", + "close": false + } + }, + { + "label": "Test: E2E Playwright (Debug Mode)", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh test-e2e-playwright-debug", + "group": "test", + "problemMatcher": [], + "presentation": { + "reveal": "always", + "panel": "dedicated", + "close": false + } + }, + { + "label": "Test: E2E Playwright (Debug with Inspector)", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh test-e2e-playwright-debug --inspector", + "group": "test", + "problemMatcher": [], + "presentation": { + "reveal": "always", + "panel": "dedicated", + "close": false + } + }, + { + "label": "Utility: Update Go Version", + "type": "shell", + "command": ".github/skills/scripts/skill-runner.sh utility-update-go-version", + "group": "none", + "problemMatcher": [], + "presentation": { + "reveal": "always", + "panel": "shared" + } + } + ], + "inputs": [ + { + "id": "dockerImage", + "type": "promptString", + "description": "Docker image name or tag to verify", + "default": "charon:local" + } + ] +}