Skip to content

Contributing

Every kind of help is welcome: bug reports, false-positive reports, ideas, translations, documentation fixes and code. Small and imperfect contributions are fine; we are happy to help finish them. This guide adds the details a first contribution needs to CONTRIBUTING.md.

Looking for something to start with? Issues labelled good first issue are small and self-contained. Comment on the issue so that nobody else starts on it at the same time.

How Corvus is built

Corvus runs as one container with three parts:

 Internet ──80/443──▶ gateway/        OpenResty (nginx + LuaJIT): per-request checks, proxy_pass
                        │   ▲ reads policy.json, queue state in the built-in Redis (127.0.0.1)
          access log ───┘   │ writes nginx.conf + hosts/*.conf + policy.json, reloads
     (Unix socket)      ▼   │
                      control/        corvus-control (Go, PID 1): API, config compiler, deploy,
                        ▲             ACME, traffic stats, alerts, auto-ban; SQLite (or PostgreSQL)
                        │ JSON API on :9443
                      web/            Admin console (React + TypeScript), embedded in the Go binary
  • Gateway (data plane, Lua). OpenResty handles every request. The Lua modules in gateway/lua/corvus/ run the checks in a fixed order: IP bans, security rules, exploit-path and body checks, the under-attack challenge, rate limits, the login page and the access queue, then the request is proxied to the service. The access queue keeps its state in the Redis server built into the container (gateway/redis/ holds its Lua scripts). Every request is logged once to the control plane over a Unix datagram socket. The gateway's own pages (block, error, challenge, login, waiting room) are in gateway/html/.
  • Control plane (Go). control/cmd/corvus-control starts and supervises Redis and OpenResty and serves the console. Settings live in a database (control/internal/store, SQLite by default). The config compiler (control/internal/compiler, templates in templates/) renders the stored settings into a self-contained version directory: nginx.conf, hosts/*.conf and policy.json, which the Lua code reads for rules, lists and limits. control/internal/deploy tests that directory with openresty -t, switches to it, reloads and verifies; if anything fails, the change is rolled back and the running configuration stays as it was.
  • Console (React). web/ is the admin console. It talks only to the JSON API (control/internal/api, described in docs/API.md) and is built into control/internal/webui/dist, so it ships inside the Go binary.
Path What is there
gateway/lua/corvus/ Request checks: rules.lua, body.lua, challenge.lua, waitroom.lua (access queue), login.lua, accesslog.lua, …
gateway/test/ Lua unit tests (*_test.lua)
control/internal/api HTTP API, sessions, role checks, input validation
control/internal/compiler Settings → nginx configuration and policy.json
control/internal/store Database and migrations
control/internal/… acme, certs, traffic, history, alerts, autoban, sigs, feeds, npmimport, … one package per feature
web/src/ Console pages, components and locales/
deploy/ Dockerfile, compose files; deploy/dev/ test stack and integration checks
website/ This documentation (en/, ko/) and the homepage (landing/)

More detail, including how a configuration change is applied step by step, is in docs/ARCHITECTURE.md.

Local development

Requirements: Go (version from go.mod), Node.js 22+, and Docker for the full image. The commands below are the ones CI runs, so if they pass locally, the checks will most likely pass too.

Console and control plane

npm --prefix web ci && npm --prefix web run build      # console → control/internal/webui/dist
go build -o bin/corvus-control ./control/cmd/corvus-control
CORVUS_GATEWAY=0 CORVUS_ADMIN_TLS=0 CORVUS_DATA_DIR=./tmp bin/corvus-control   # console only, no OpenResty

The console is then on port 9443 (plain HTTP with CORVUS_ADMIN_TLS=0). For quick UI work, run npm --prefix web run dev: Vite serves the console with hot reload and proxies /api to the control plane (CORVUS_API, default https://localhost:9443).

Tests

Check (CI job) Command
Go (go) gofmt -l control (must print nothing), go vet ./..., go test -race ./...
Go coverage go test -race -coverpkg=./control/... -coverprofile=cover.out ./... then go tool cover -func=cover.out: the control plane must stay at 80% or more
Console (web) npm --prefix web run build: TypeScript strict mode, fails on type errors
Lua (lua) for f in gateway/test/*_test.lua; do luajit "$f" \|\| exit 1; done, and every module must compile: luajit -bl gateway/lua/corvus/<file>.lua > /dev/null
Integration (integration) see below

Go tests need the console build directory to exist. Without a console build, create it first: mkdir -p control/internal/webui/dist && touch control/internal/webui/dist/.gitkeep.

The Lua tests cover the pure helpers with a stubbed ngx (gateway/test/stub.lua), so plain LuaJIT is enough; no OpenResty needed.

Full image and integration checks

docker build -f deploy/Dockerfile -t corvus/gateway:ci .   # compiles OpenResty, takes a while
CORVUS_IMAGE=corvus/gateway:ci deploy/dev/ci-itest.sh
deploy/dev/upgrade-test.sh ghcr.io/corvus-gateway/gateway:latest corvus/gateway:ci

deploy/dev/ci-itest.sh does what CI does: it prepares fixtures, starts the test stack in deploy/dev/ (a Pebble ACME test CA and a demo backend), creates an admin and a first proxy host, and runs deploy/dev/itest.sh against it. KEEP_STACK=1 leaves the stack running afterwards. upgrade-test.sh upgrades from the latest release on the same data volume. It needs Docker (compose v2), curl, python3 and openssl.

Documentation

pip install --require-hashes -r website/requirements.txt
sh website/build.sh                      # homepage + en/ko docs into site/, strict mode
mkdocs serve -f website/mkdocs.yml       # live preview of the English docs

build.sh runs MkDocs in strict mode, so a broken internal link fails the build, as it does in CI.

Pull requests

  1. Start with an issue (or comment on an existing one) for anything bigger than a typo, so we can agree on the approach before you write code. Larger changes (new features, the configuration format, the API, the security model) always start as an issue or a discussion.
  2. Fork the repository, create a branch, and keep the change to one topic.
  3. Open a pull request and write Fixes #123 in the description so the issue closes on merge. A draft is fine if you want early feedback.
  4. The required checks are go, web, lua and integration; dependency and security scans run as well. If something fails and you are not sure why, just ask in the pull request.
  5. Pull requests are squash-merged, so the PR title becomes the commit message on main.

All changes, including the maintainer's own, reach main this way.

What reviewers look for (we can help with any of it):

  • Tests. New behaviour comes with automated tests (Go unit tests, fuzz tests for parsers, Lua tests, or a case in deploy/dev/itest.sh); bug fixes add a test that fails without the fix. Changes to the rules engine, authentication or configuration generation are not merged without tests. See the test policy.
  • Style. Go is formatted with gofmt; TypeScript follows the surrounding code.
  • Upgrades keep working. The rendered configuration stays valid and existing installations keep working after an upgrade.
  • Docs and strings. User-facing changes update the documentation (website/en and website/ko) and add console strings.
  • License. Contributions are licensed under the Apache License 2.0.

Translating

The console is available in 8 languages: English, Korean, Simplified Chinese, Japanese, Russian, French, German and Spanish. Users switch it in the user menu (Language) or on the sign-in page. English is the default and the fallback for any missing string.

Where the strings are

All console strings are in web/src/locales/:

File Contents
ko.ts, *.i18n.ts, security.ts, users.ts, alerts.ts Korean source strings; they define the keys
en.ts, en/*.ts, security.en.ts, users.en.ts, alerts.en.ts English (must have every key; the type check enforces it)
<lang>.ts and <lang>/*.ts The other languages (zh, ja, ru, fr, de, es); a missing key falls back to English
audit.i18n.ts Extra audit log labels for all languages

Each feature has its own module: for example notes.i18n.ts holds the Korean strings for notes, en/notes.ts the English ones and de/notes.ts the German ones. The larger shared dictionary is in ko.ts / en.ts / <lang>.ts themselves. Rule field and audit labels for each language are exported from <lang>.ts (deRuleLabels, deAuditLabels, …).

Placeholders in braces, such as {n} or {name}, are filled in by the console. Keep them as they are.

Fix a wording

  1. Find the text: search web/src/locales/ for the current wording, e.g. grep -rn "Zugriff verweigert" web/src/locales/.
  2. Change it in that file. Keep the key and any {placeholder}.
  3. Run npm --prefix web run build if you can (it checks that nothing else broke) and open a pull request. A pull request from the GitHub web editor is fine for a one-line fix.

Review a language

The translations other than English and Korean have not yet been reviewed by native speakers. Issue #93 tracks the review. Use the console in your language and send corrections as a pull request, or list them in a comment on #93 (screen, current text, better text) if you prefer not to edit files.

Pages served by the gateway

Visitors see a few pages that come from the gateway, not the console. They pick the visitor's browser language and have their texts inline:

  • gateway/html/blocked.html, error.html, challenge.html, login.html, wait.html: a var L = { ko: [...], zh: [...], … } table in each page's script.
  • control/internal/compiler/staticpage.go: the built-in parked, coming-soon and maintenance pages (pageTexts).

Add a new language

A new language is welcome if you (or someone you know) can keep it up to date. Open an issue first. The pieces to add, using xx for the language code:

  1. web/src/locales/xx.ts (copy an existing language such as de.ts, including its rule and audit labels xxRuleLabels and xxAuditLabels) and web/src/locales/xx/ with one file per feature module.
  2. web/src/i18n.tsx: add xx to LANGS, its native name to LANG_NAMES, its BCP 47 tag to LOCALE_TAG and a loader in loaders.
  3. web/src/locales/audit.i18n.ts (auditMore). npm --prefix web run build reports any map keyed by language that still lacks the new one.
  4. The gateway pages above (gateway/html/*.html) and pageTexts in control/internal/compiler/staticpage.go.
  5. The places that say "8 languages" in the README (all languages) and the docs.

Documentation

The documentation is in English (website/en/) and Korean (website/ko/), with the same file names in both. A change to a page goes into both languages; if you can write only one of them, say so in the pull request and we will do the other. The docs are not translated into other languages. The README exists in 8 languages (README.md and docs/readme/).