Overview
Megatron answers one question for an organization: which of our dependencies are vulnerable, where, and how bad is it? It connects to the organization's source control, catalogues every package in every repository, matches them against public vulnerability data, and keeps the answer current as new advisories appear, even when the code doesn't change.
I built it alone, from the first commit to production, in two weeks: a Go API and worker, a Next.js web app, CI, and deployment.
Architecture
- API (Go, chi + Huma). A typed HTTP API with generated OpenAPI docs, JWT sessions with refresh-token rotation and reuse detection, Google sign-in, a four-level role model (platform, tenant, business client, read-only user), and an audit log.
- Database (PostgreSQL, sqlc, goose). Queries are written in SQL and compiled to type-safe Go with sqlc. Migrations are embedded in the binary and serialized with an advisory lock, so any number of instances can start at once.
- Worker (River). Repository scans, feed syncs, imports, and forwarding all run as jobs on River, a Postgres-backed queue that spreads work across any number of workers with no separate broker.
- Web app (Next.js). TanStack Query, Zustand, and nuqs for state, an OpenAPI-typed client, charts, bulk triage, and live updates.
Scanning without trusting the code
Client repositories are untrusted input. A scan:
- Fetches the default branch into a temporary folder. For git, the token travels as an HTTP header through environment variables, and hooks, submodules, LFS, symlinks, and redirects are all off. The address must be on the integration's own server.
- Lists packages with syft, reading lockfiles and manifests only. Nothing from the repository is ever executed.
- Matches packages against the local vulnerability data using each ecosystem's own version rules, merges duplicate advisories, and enriches them with exploit data.
- Stores components, the dependency graph, and findings, then deletes the checkout.
Integration secrets are encrypted with AES-256-GCM, and every outbound request goes through an SSRF-safe HTTP client.
Vulnerability intelligence
Five feeds sync in the background:
| Feed | What it adds |
|---|---|
| OSV | Package advisories across ecosystems, and malicious-package reports |
| CISA KEV | Vulnerabilities known to be exploited |
| FIRST EPSS | The probability that a CVE gets exploited |
| CVE List | Official records: CWE, CVSS, CISA SSVC |
| NVD | NIST's own CVSS analysis, for advisories that come without a severity |
The CVE List starts from a ~620 MB snapshot and then applies only the changes, so feeds stay current without re-downloading everything.
SBOMs and VEX
Every finished scan produces CycloneDX 1.6 and SPDX 2.3 SBOMs with CISA's 2026 minimum elements, stating anything unknown explicitly rather than leaving it out. Each SBOM gets a detached Ed25519 signature that anyone can verify against a public key endpoint. Triage decisions ("not affected", "accepted risk") export as OpenVEX and CycloneDX VEX documents.
Enterprise integrations
- In: Veracode findings (every request signed with Veracode's HMAC scheme) and SonarQube vulnerabilities and security hotspots, upserted in a single statement so findings keep their identity across syncs.
- Out: ServiceNow incidents, Cortex XSOAR incidents, and Cortex XSIAM events. A new finding opens exactly one ticket, and a fixed or ignored finding resolves it. Each delivery is keyed by a stable finding key, a per-tenant lock keeps runs apart, and failures retry and back off without stalling the whole run.
Live, without polling
A Postgres trigger fires on every scan status change, and LISTEN/NOTIFY fans it out to a Server-Sent Events stream. The web app refreshes exactly what changed, and it works across any number of API and worker processes.
Shipping
GitLab CI runs formatting, vetting, and the test suite against a throwaway Postgres on every push. It also runs riq-scan, Megatron's own scanner as a command-line tool, against Megatron itself, and fails the build on any high or critical finding. Production runs as distroless, non-root Docker images behind Caddy.
