- Go 54.2%
- TypeScript 43.9%
- Shell 1.7%
- Dockerfile 0.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
Some checks failed
security-scan / security-scan (push) Successful in 2m0s
codecov/project 54.97% (No base report)
codecov/patch Patch coverage: N/A (not in PR context)
test / go (push) Successful in 4m40s
test / web (push) Failing after 10m42s
test / coverage-badge (push) Has been skipped
Reviewed-on: #70 |
||
| .forgejo | ||
| api | ||
| cmd/server | ||
| deploy | ||
| internal | ||
| scripts | ||
| web | ||
| .dockerignore | ||
| .gitignore | ||
| .ojoignore | ||
| AGENTS.md | ||
| DESIGN.md | ||
| go.mod | ||
| go.sum | ||
| Makefile | ||
| PRODUCT.md | ||
| README.md | ||
| renovate.json | ||
| STATUS.md | ||
| TODO.md | ||
Balam
Self-hosted vulnerability management with a DefectDojo-style API and a modern UI. Go API · PostgreSQL · React/TypeScript frontend.
Features
- Multi-tenant — every record is isolated by organization; RBAC roles
owner > admin > writer > readerwith per-productProductMemberoverrides. - Auth — Argon2id passwords with account lockout, short-lived JWT access
tokens, rotating refresh tokens (stored hashed), personal API tokens,
UI-configurable OIDC SSO (PKCE + state + nonce) and SAML 2.0 SP-initiated
SSO, plus SCIM 2.0 user provisioning (
/scim/v2/Users). - Resources — product types, products, engagements, tests, findings, endpoints, risk acceptances, teams, questionnaires, tags (DefectDojo parity).
- Scan import — 14 scanner formats (Trivy, Semgrep, generic SARIF, Grype, Bandit, Gosec, Gitleaks, Checkov, Nuclei, ZAP, npm-audit, OSV, Snyk, OJO), with hash-based finding deduplication and reimport reconciliation.
- SBOM component inventory — CycloneDX and SPDX imports
(
/api/v2/import-sbom) build a per-product inventory of package versions with purl, ecosystem and license. Each import is recorded with a diff (added / upgraded / removed), admins are alerted when components are added, and/componentssearches every product ("which products ship lodash 4.17.20?") with each package's open findings. - SBOM vulnerability matching — components are checked against OSV after every SBOM import and again daily, so a newly published advisory becomes a finding without a new scan (in each product's "SBOM Monitoring" engagement; fixed packages close their findings). By default Balam downloads OSV's public per-ecosystem exports and matches locally, so the inventory never leaves the server. Matches use ojo's identifiers, so a package ojo already reported is filed as a duplicate rather than twice.
- License policy — a deny list in System Settings (SPDX ids or names,
GPL-*style prefixes) is checked against SBOM component licenses after every import and whenever the policy changes. SPDX expressions are evaluated (MIT OR GPL-3.0-onlyis fine if MIT is allowed); violations become findings with a configurable severity and close when the component or the policy changes. - AI — optional, off by default. An admin picks a provider under System
Settings → AI: the Anthropic API, the OpenAI API, or any OpenAI-compatible
endpoint (Ollama, vLLM, llama.cpp, LM Studio, LiteLLM) for a model on your
own network. Features:
- Mitigation advice per finding: urgency, steps, fixed version, workarounds, verification; can be copied into the finding.
- SBOM analysis per product: a prioritized upgrade plan grouped by package, license issues and overall dependency risk.
- ASVS assessment per product: a suggested level for each chapter V1–V14 with rationale, gaps and evidence; levels change only when a writer applies them on the Benchmark page.
- Security digest: a summary of what changed (new and fixed findings, riskiest products, expiring risk acceptances, SBOM changes), sent to owners and admins as alerts and optionally to Slack. Each feature runs on the cheapest tier that does it well; unchanged inputs reuse earlier results; bulk jobs use Anthropic's half-price batch API. API keys are encrypted at rest and never returned, requests go through the outbound SSRF guard, every request is logged with its tier, model and tokens, and an optional monthly token limit caps spend. Scanner text is passed to the model as data, and AI output never changes a record without a person acting on it. See AI providers.
- Integrations — Code Repository (GitHub, GitLab, Gitea/Forgejo, Bitbucket)
and Linear issue creation and note sync on import, plus Jira and Slack
configuration and background status-sync worker.
Integration.SecretEnc,SlackConfiguration.WebhookURL, andAuthProvidersecrets are encrypted at rest (AES-256-GCM viacrypto.SecretBox). - Security baseline — security headers, rate limiting, audit logging,
tenant-scoped data access, secrets hidden from API responses (
json:"-").
Quick start (local)
# Requires Go 1.26+ and a PostgreSQL instance.
export BALAM_DATABASE_URL="postgres://balam:balam@localhost:5432/balam?sslmode=disable"
export BALAM_JWT_SECRET="$(openssl rand -base64 32)"
make run
On first start the server migrates the schema and bootstraps a default
organization plus an admin user (BALAM_BOOTSTRAP_EMAIL /
BALAM_BOOTSTRAP_PASSWORD, default [email protected] / admin). Change the
admin password immediately in production.
The API is served at /api/v2; interactive docs at
/api/v2/oa3/swagger-ui.
For frontend work, run cd web && npm install && npm run dev and open
http://localhost:5173; Vite proxies /api to the server on :8080. In the
container image the server also serves the built frontend itself
(BALAM_WEB_DIR), so the whole app is one process on one port.
Docker Compose
docker compose -f deploy/docker/docker-compose.yml up --build
Configuration
All configuration is via BALAM_* environment variables:
| Variable | Default | Purpose |
|---|---|---|
BALAM_ENV |
development |
production enables HSTS and quiet logs |
BALAM_HTTP_ADDR |
:8080 |
Listen address |
BALAM_DATABASE_URL |
local postgres DSN | PostgreSQL connection |
BALAM_JWT_SECRET |
dev placeholder | Required. Signs JWTs and derives the SecretBox encryption key |
BALAM_ACCESS_TOKEN_TTL |
15m |
Access token lifetime |
BALAM_REFRESH_TOKEN_TTL |
720h |
Refresh token lifetime |
BALAM_PUBLIC_URL |
http://localhost:8080 |
Used for OIDC/SAML redirect and metadata URIs |
BALAM_CORS_ORIGINS |
localhost dev origins | Comma-separated allowed origins |
BALAM_BOOTSTRAP_EMAIL / _PASSWORD / _ORG |
admin defaults | First-run seed |
BALAM_UPLOAD_DIR |
./uploads |
Directory on disk for file attachments (/api/v2/files) |
BALAM_MAX_UPLOAD_MB |
50 |
Maximum multipart upload size in MiB |
BALAM_WEB_DIR |
unset (/app/web in the image) |
Built frontend (web/dist) to serve at /; unset disables it |
BALAM_TRUSTED_PROXIES |
unset | Comma-separated CIDRs (or private_ranges) of reverse proxies allowed to set X-Forwarded-For. Read right to left; other peers' forwarding headers are ignored |
BALAM_OUTBOUND_ALLOW |
unset | Comma-separated CIDRs/IPs (or private_ranges) that integrations, SAML metadata, OIDC and AI providers may reach even though they are internal. Needed for a self-hosted Jira, GitLab, Gitea, IdP or local AI model on a private network; everything internal is refused otherwise |
BALAM_OUTBOUND_ALLOW_HTTP |
false |
Allow plain http:// integration, IdP and AI provider URLs (e.g. a local Ollama server at http://ollama:11434/v1). Off by default because those requests may carry API tokens |
BALAM_OSV_MODE |
mirror |
SBOM vulnerability matching: mirror downloads OSV's public exports and matches locally; offline uses only exports already in BALAM_OSV_DIR (air-gapped); api queries BALAM_OSV_API_URL (sends package names and versions); off disables it |
BALAM_OSV_MIRROR_URL |
https://osv-vulnerabilities.storage.googleapis.com |
Where mirror mode downloads {ecosystem}/all.zip. An internal mirror must also be in BALAM_OUTBOUND_ALLOW |
BALAM_OSV_API_URL |
https://api.osv.dev |
osv.dev-compatible API for api mode |
BALAM_OSV_DIR |
<BALAM_UPLOAD_DIR>/osv-cache (/var/lib/balam/osv-cache in the image) |
Cache for downloaded exports (npm's is the largest, a few hundred MB) |
BALAM_OSV_INTERVAL |
24h |
How often OSV data is refreshed and every product re-matched |
AI providers
AI is configured per organization in System Settings → AI (admins), not with environment variables. Choose a provider, set models per tier if you don't want the defaults, enter the API key, click Test saved settings, then enable.
| Tier | Used for | Anthropic default | OpenAI default | Effort |
|---|---|---|---|---|
| fast | classification, short drafting, connection tests | claude-haiku-5-5 |
gpt-6-luna |
low |
| standard | per-finding work (mitigation advice) | claude-sonnet-5-5 |
gpt-6.2-sol |
medium |
| deep | per-product analysis (SBOM review, ASVS assessment) | claude-opus-5-5 |
gpt-6.2-astra |
high |
The fast tier also writes the security digest.
A blank tier uses its default; the settings page also suggests
alternatives per tier (for example claude-fable-5-2 for deep,
gpt-6.1-terra for fast or standard), and any model id can be typed in.
Effort is sent as output_config.effort (Anthropic) or reasoning_effort
(OpenAI reasoning models). OpenAI-compatible endpoints have no defaults:
set at least the standard model; blank tiers use it, and no effort
parameter is sent.
Local models (Ollama, vLLM, llama.cpp, LM Studio). Choose
OpenAI-compatible and set the base URL including /v1, for example
http://ollama:11434/v1. The API key is optional. Because the outbound
guard refuses internal addresses and plain http, also set
BALAM_OUTBOUND_ALLOW to the model host (or private_ranges) and, without
TLS, BALAM_OUTBOUND_ALLOW_HTTP=true.
What is sent. For mitigation advice: the finding's title, severity, identifiers (CVE, CWE, CVSS, EPSS), component and version, file and line, service, tags and free-text fields (each capped at 8,000 characters), the product name, the scan type, up to 10 endpoints, and up to 10 matching SBOM components. Notes, attachments and raw scan files are not sent. Balam stores the parsed advice and a usage row (feature, tier, model, token counts, outcome); prompts and raw responses are not stored.
Bulk jobs and the digest. The AI section can run each feature for the whole organization, on demand or daily or weekly: mitigation advice for every active finding at or above a chosen severity (default Low), and the SBOM analysis and ASVS assessment for every product (SBOM analysis only for products with an SBOM inventory). Findings that are mitigated, duplicates, false positives, risk accepted or out of scope are left out, and anything whose result is still current is skipped, so repeat runs only pay for what changed. On Anthropic jobs use the Message Batches API (half price, usually done within an hour, at most 24); other providers run requests two at a time. With a monthly token limit, the advice job takes the most severe findings that fit. Each job shows an estimate before it runs, progress, and a cancel button; jobs survive restarts and run on one replica at a time, and stop when AI is disabled. Large jobs are split into several batches. If a job is cancelled or a refresh fails, earlier advice and analyses are kept. The digest covers the period since the last successful one, so a failed digest's activity is included in the next; failed scheduled digests are retried after an hour, and a quiet period is recorded without calling the model. Slack posts are escaped and kept within Slack's size limits. Product analyses send aggregates, not raw data: vulnerable components grouped by package and version (at most 150 groups), license violations, ecosystem counts, open findings grouped by CWE and severity (at most 60 groups) and the current benchmark levels.
Limits. The monthly token limit (input + output, per UTC month) is checked before each request, so requests already running can go slightly past it. At most 4 AI requests run at once per server; each has a 10-minute timeout. Connection tests count toward usage.
Development
make build # compile the server
make test # run all tests (crypto, parsers, auth, tenant isolation)
make vet # static analysis
Source of truth for validation is the CLI (go build ./..., go vet ./...,
go test ./...). Tests use in-memory SQLite; production runs on PostgreSQL.
Layout
cmd/server entrypoint (config, migrate, bootstrap, serve)
internal/config env-driven configuration
internal/models GORM domain models (OrgScoped tenant boundary)
internal/crypto Argon2id, AES-256-GCM SecretBox, token hashing
internal/database connect, AutoMigrate, bootstrap seed
internal/auth JWT, refresh rotation, API tokens, RBAC, OIDC, SAML, SCIM
internal/api chi router + middleware + handlers
internal/parsers scanner (14 formats) & SBOM (CycloneDX/SPDX) import framework
internal/integrations Jira/Linear/Slack + CodeRepository issue push + sync worker
internal/ai provider-neutral AI layer (Anthropic, OpenAI, OpenAI-compatible) + finding advice
api/openapi.yaml OpenAPI 3 spec (served via Swagger UI)
web/ React + TypeScript + Vite frontend
deploy/ Docker and Kubernetes manifests