How gmax-13/guard-gate works
Purpose and Top-Level Entry Points
GuardGate is a pnpm monorepo for CI/CD security scanning plus a report dashboard. The CLI runs code, API, browser/E2E, dependency, and secrets scans; it emits console, JSON, and SARIF artifacts. The dashboard ingests JSON reports through authenticated APIs and presents runs/trends/settings.
• packages/cli/src/index.ts
• apps/dashboard/src/app/page.tsx
• packages/github-action/action.yml
CLI Orchestration and Configuration
The CLI is the main execution boundary: it resolves commands, loads/validates GuardGate configuration, selects scan modules, aggregates findings, applies baseline filtering, determines exit behavior, and delegates output serialization.
• packages/cli/src/index.ts
• packages/cli/src/config/loader.ts
• packages/cli/src/config/schema.ts
Repository/project configuration controls scanner targets, rules, API fuzzing, and browser workflows. Example inputs establish the expected user-authored extension model.
• guardgate.config.yml
• examples/guardgate.config.yml
• examples/flows/login-flow.yml
Scanner Pipeline
Each scanner produces a common report/finding representation consumed by formatters and the dashboard. The principal scanning stages are:
1. Semantic source analysis using TypeScript AST and JavaScript rule plugins.
2. API DAST: parse endpoint definitions, generate/run fuzz cases, and evaluate response matching.
3. Playwright-driven E2E flows with pluggable auth/session/IDOR checks.
4. SBOM generation from ecosystem manifests followed by OSV vulnerability matching.
5. Repository and Git-history secrets detection.
• packages/cli/src/types/report.ts
• packages/cli/src/types/scanner.ts
• packages/cli/src/scanners/code/index.ts
Code and Secrets Analysis Boundaries
The code scanner separates AST traversal from executable/custom rule definitions, allowing semantic rules beyond regex matching. Secrets scanning separates working-tree files, history, entropy/rule heuristics, and explicit allowlists; Git access is isolated in utilities.
• packages/cli/src/scanners/code/ast-parser.ts
• packages/cli/src/scanners/code/rules.ts
• packages/cli/src/scanners/secrets/index.ts
• packages/cli/src/utils/git.ts
Dynamic and Browser Security Testing
API scanning treats parser, runner, and endpoint payload logic as distinct layers. Browser security testing parses YAML flows into typed execution context, then invokes registered plugins for common authentication/session vulnerabilities. These stages interact with user-supplied target services and require runtime network/browser access.
• packages/cli/src/scanners/api/parser.ts
• packages/cli/src/scanners/api/runner.ts
• packages/cli/src/scanners/e2e/flow-runner.ts
• packages/cli/src/scanners/e2e/plugin-registry.ts
Reports, CI, and External Services
Scan results are formatted for humans or persisted under .guardgate; JSON is the dashboard ingestion contract, while SARIF integrates with GitHub/GitLab security UIs. Baseline logic compares findings against a Git revision to suppress existing debt. Dependency scanning calls the OSV vulnerability service. GitHub Actions can execute scans, upload SARIF, and POST reports to a hosted dashboard using an API key.
• packages/cli/src/report/json-writer.ts
• packages/cli/src/report/sarif-writer.ts
• packages/cli/src/utils/baseline.ts
• .github/workflows/guardgate.yml
Dashboard Application and Persistence
The dashboard is a Next.js application with auth routes/middleware, report ingestion/detail APIs, and trends/settings views. Its database adapter/schema and Drizzle migration define the persistence boundary for users, API keys, reports, and dashboard-derived views. It is intended for Vercel-hosted deployment, with CI clients posting reports over HTTP bearer authentication.
• apps/dashboard/src/middleware.ts
• apps/dashboard/src/app/api/reports/route.ts
• apps/dashboard/src/lib/schema.ts
• apps/dashboard/drizzle/0000_lame_xorn.sql
Main entry points: index.ts CLI entry · report.ts Common report model · route.ts Report ingestion API · action.yml GitHub Action
Components 20
GuardGate CLI
Scan orchestration and local artifacts.
- CLI entry · Resolves commands and coordinates scans.
packages/cli/src/index.ts - Config loader & schema · Loads and validates scan targets, rules, and workflows.
packages/cli/src/config/loader.ts - Common report model · Shared finding and scanner result representation.
packages/cli/src/types/report.ts - Baseline filter · Suppresses findings already present at a Git revision.
packages/cli/src/utils/baseline.ts - JSON reports · Dashboard ingestion contract persisted under .guardgate.
packages/cli/src/report/json-writer.ts - SARIF reports · Security UI artifact output.
packages/cli/src/report/sarif-writer.ts
Scan engines
Security analysis stages sharing a report model.
- Code scanner · Semantic source analysis using AST rules.
packages/cli/src/scanners/code/index.ts - AST traversal · Parses TypeScript and JavaScript source.
packages/cli/src/scanners/code/ast-parser.ts - API DAST runner · Runs generated fuzz cases and evaluates responses.
packages/cli/src/scanners/api/runner.ts - E2E flow runner · Executes browser flows against target services.
packages/cli/src/scanners/e2e/flow-runner.ts - E2E security plugins · Registers auth, session, and IDOR checks.
packages/cli/src/scanners/e2e/plugin-registry.ts - Dependency & OSV scan · Builds an SBOM and matches vulnerabilities.
- Secrets scanner · Scans working tree and Git history with heuristics and allowlists.
packages/cli/src/scanners/secrets/index.ts
Dashboard
Authenticated report ingestion and reporting UI.
- Report ingestion API · Accepts posted JSON reports with bearer authentication.
apps/dashboard/src/app/api/reports/route.ts - Dashboard UI · Presents runs, trends, and settings.
apps/dashboard/src/app/page.tsx - Auth middleware · Protects dashboard routes.
apps/dashboard/src/middleware.ts - Dashboard database · Stores users, API keys, reports, and derived views.
apps/dashboard/src/lib/schema.ts
Other components
- User scan config · Repository-authored scan configuration and flow inputs.
guardgate.config.yml - OSV service
- GitHub Action · Runs scans, uploads SARIF, and posts JSON reports.
packages/github-action/action.yml
Connections 25
- User scan config → Config loader & schema: loaded and validated
- Config loader & schema → CLI entry: scan settings
- CLI entry → Code scanner: selects
- CLI entry → API DAST runner: selects
- CLI entry → E2E flow runner: selects
- CLI entry → Dependency & OSV scan: selects
- CLI entry → Secrets scanner: selects
- AST traversal → Code scanner: semantic input
- E2E security plugins → E2E flow runner: security checks
- OSV service → Dependency & OSV scan: vulnerability matches
- Code scanner → Common report model: findings
- API DAST runner → Common report model: findings
- E2E flow runner → Common report model: findings
- Dependency & OSV scan → Common report model: findings
- Secrets scanner → Common report model: findings
- Common report model → Baseline filter: aggregated findings
- Baseline filter → JSON reports: filtered report
- Baseline filter → SARIF reports: filtered report
- GitHub Action → CLI entry: executes
- GitHub Action → SARIF reports: uploads artifact
- JSON reports → Report ingestion API: JSON report
- GitHub Action → Report ingestion API: posts with API key
- Auth middleware → Report ingestion API: protects
- Report ingestion API → Dashboard database: persists reports
- Dashboard UI → Dashboard database: reads runs and trends