Read settings from a YAML config file, with per-host settings; remove the local backend #23

Merged
james merged 6 commits from config-file into main 2026-10-27 17:08:56 +00:00
Owner

Centinela had 52 settings, all env variables. Two of them had outgrown that:
CENTINELA_UPSTREAMS is a 1,268-character host=url list and
CENTINELA_WAF_HARD_BLOCK_EXEMPT repeats the same hosts in 485 more. The next
features (learned missing-path areas, reviewed exceptions, recon action per site) are
all per host, so this adds a config file with a hosts: section. It also removes the
llama.cpp backend, which is no longer deployed.

Config file

  • CENTINELA_CONFIG names a YAML file that can hold any existing setting, grouped
    (waf.hard_block, shun.after, recon.not_found_after, …).
    • An env variable that is set overrides the file, and the file overrides the
      default, so env-only deployments work unchanged.
    • Values go through the same parsing and checks as before.
    • Unknown keys are startup errors, and a bad value names its key and the file.
  • Secrets stay in env. The file refuses state_url and the API keys, so they
    can't land in a ConfigMap.
  • hosts: section. Each host gets its own upstream, hard_block_exempt (all
    or path patterns) and bypass prefixes. Setting CENTINELA_UPSTREAMS or
    CENTINELA_WAF_HARD_BLOCK_EXEMPT still replaces that part of hosts: as a whole.
  • Bypass by host. A global prefix such as /ghost/ skipped every check on every
    host. Under hosts: it applies only to the host that serves it.
  • centinela.example.yaml is a complete, production-shaped example.

Local backend removed

The local backend called a llama.cpp server running Qwen 27B. That server is no
longer deployed (its GPU runs Laya), so the default backend pointed at a service that
doesn't exist.

  • laya is now the default backend.
  • Removed: CENTINELA_BACKEND=local, CENTINELA_LOCAL_URL, CENTINELA_LOCAL_MODEL
    and centinela-eval -backend local.
  • A deployment still setting CENTINELA_BACKEND=local fails at startup. Production
    already uses laya.

Docs

  • README, Run section: rewritten around a short centinela.yaml (proxy mode,
    embedded WAF, the Laya container, make run), with the responses to expect. I ran
    these steps against a real Laya server: a clean request got 200, a SQL injection 403.
  • README, settings table: gives each env variable's file key.
  • README, other sections: the hard-block, bypass and backend sections describe the
    hosts: form and no longer mention local.
  • DEPLOY.md: shows hosts: as the recommended proxy setup, and the ConfigMap +
    Secret pattern.
  • eval/README.md: uses the Laya backend and marks the old llama.cpp results as
    measured on a backend centinela no longer ships.

Testing

  • File values load, env variables override them, and defaults survive.
  • Lists, the hosts: section, and env variables replacing it.
  • A host's bypass applies only to that host.
  • Each error case: unknown key, secret, bad value, unknown host field, host with a
    port, bad exemption, missing file.
  • A test checks that every env variable Load reads has a file key and the other way
    round. Deleting one on purpose makes it fail.
  • centinela.example.yaml loads.
  • go vet, go test ./... and -race (config, engine) pass.

Rollout

Nothing changes until gitops sets CENTINELA_CONFIG. The follow-up gitops PR turns
the centinela ConfigMap's 25 CENTINELA_* keys into one config.yaml, with the
Valkey password still coming from its Secret.

Centinela had 52 settings, all env variables. Two of them had outgrown that: `CENTINELA_UPSTREAMS` is a 1,268-character `host=url` list and `CENTINELA_WAF_HARD_BLOCK_EXEMPT` repeats the same hosts in 485 more. The next features (learned missing-path areas, reviewed exceptions, recon action per site) are all per host, so this adds a config file with a `hosts:` section. It also removes the llama.cpp backend, which is no longer deployed. ## Config file - `CENTINELA_CONFIG` names a YAML file that can hold any existing setting, grouped (`waf.hard_block`, `shun.after`, `recon.not_found_after`, …). - An env variable that is set overrides the file, and the file overrides the default, so env-only deployments work unchanged. - Values go through the same parsing and checks as before. - Unknown keys are startup errors, and a bad value names its key and the file. - **Secrets stay in env.** The file refuses `state_url` and the API keys, so they can't land in a ConfigMap. - **`hosts:` section.** Each host gets its own `upstream`, `hard_block_exempt` (`all` or path patterns) and `bypass` prefixes. Setting `CENTINELA_UPSTREAMS` or `CENTINELA_WAF_HARD_BLOCK_EXEMPT` still replaces that part of `hosts:` as a whole. - **Bypass by host.** A global prefix such as `/ghost/` skipped every check on every host. Under `hosts:` it applies only to the host that serves it. - `centinela.example.yaml` is a complete, production-shaped example. ## Local backend removed The `local` backend called a llama.cpp server running Qwen 27B. That server is no longer deployed (its GPU runs Laya), so the default backend pointed at a service that doesn't exist. - `laya` is now the default backend. - Removed: `CENTINELA_BACKEND=local`, `CENTINELA_LOCAL_URL`, `CENTINELA_LOCAL_MODEL` and `centinela-eval -backend local`. - A deployment still setting `CENTINELA_BACKEND=local` fails at startup. Production already uses `laya`. ## Docs - **README, Run section:** rewritten around a short `centinela.yaml` (proxy mode, embedded WAF, the Laya container, `make run`), with the responses to expect. I ran these steps against a real Laya server: a clean request got 200, a SQL injection 403. - **README, settings table:** gives each env variable's file key. - **README, other sections:** the hard-block, bypass and backend sections describe the `hosts:` form and no longer mention `local`. - **DEPLOY.md:** shows `hosts:` as the recommended proxy setup, and the ConfigMap + Secret pattern. - **eval/README.md:** uses the Laya backend and marks the old llama.cpp results as measured on a backend centinela no longer ships. ## Testing - File values load, env variables override them, and defaults survive. - Lists, the `hosts:` section, and env variables replacing it. - A host's bypass applies only to that host. - Each error case: unknown key, secret, bad value, unknown host field, host with a port, bad exemption, missing file. - A test checks that every env variable `Load` reads has a file key and the other way round. Deleting one on purpose makes it fail. - `centinela.example.yaml` loads. - `go vet`, `go test ./...` and `-race` (config, engine) pass. ## Rollout Nothing changes until gitops sets `CENTINELA_CONFIG`. The follow-up gitops PR turns the centinela ConfigMap's 25 `CENTINELA_*` keys into one `config.yaml`, with the Valkey password still coming from its Secret.
CENTINELA_CONFIG names a YAML file holding any of the existing settings,
grouped (waf.hard_block, shun.after, recon.not_found_after, ...). An
environment variable that is set overrides the file, and the file
overrides the defaults, so current deployments keep working unchanged.
Values go through the same parsing and checks as before, and an error in
a file value names its key and the file.

A hosts section gives each host its upstream, hard-block exemptions ("all"
or path patterns) and bypass prefixes, replacing the long packed strings in
CENTINELA_UPSTREAMS and CENTINELA_WAF_HARD_BLOCK_EXEMPT. Setting either
variable still replaces that part of the hosts section as a whole.

Bypass prefixes can now be per host. A global prefix such as /ghost/
skipped every check on every host; under hosts it only applies to the
host that serves it.

Secrets stay environment-only: the file refuses state_url and the API
keys. Unknown keys are errors, so a typo cannot silently do nothing. A
test checks that every environment variable Load reads has a file key,
and that centinela.example.yaml loads.
The local backend called a llama.cpp server running Qwen 27B through the
parallel-decision engine. That server is no longer deployed (its GPU runs
Laya), so the default backend pointed at a service that does not exist.

laya is now the default backend. CENTINELA_BACKEND=local, CENTINELA_LOCAL_URL
and CENTINELA_LOCAL_MODEL are gone, as is -backend local in centinela-eval.
A deployment still setting CENTINELA_BACKEND=local fails at startup with
"unknown CENTINELA_BACKEND".
Rewrite the README's Run section around a config file
All checks were successful
security-scan / security-scan (pull_request) Successful in 27s
test / laya (pull_request) Successful in 4s
test / go (pull_request) Successful in 3m10s
b93dbd3e75
The section ran go run with the old local backend's default, showed only
forward-auth mode, and pointed CENTINELA_CONFIG at centinela.example.yaml,
whose production paths fail on a workstation. It now walks through a short
centinela.yaml in proxy mode with the embedded WAF, the Laya container and
make run, with the responses to expect. The commands were run against a
real Laya server: the clean request got 200, the SQL injection 403.

🔎 ojo scan results

No findings.

<!-- ojo-scan-summary --> ### 🔎 ojo scan results No findings.
Mark the two OJO findings on the config file change as false positives
All checks were successful
test / laya (pull_request) Successful in 4s
security-scan / security-scan (pull_request) Successful in 47s
test / go (pull_request) Successful in 4m12s
a2c1afd635
- go-path-traversal in internal/config/file.go: the path read is
  CENTINELA_CONFIG, which the operator sets in the deployment. Requests
  never reach it, and whoever can set it already controls the process.
- go-ssrf in internal/proxy/recon_test.go: the test requests its own
  httptest server.

Each entry names one rule in one file, so a real finding of another kind,
or the same rule elsewhere, still reports.
james merged commit 4630c1056b into main 2026-10-27 17:08:56 +00:00
james deleted branch config-file 2026-10-27 17:08:56 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ColibriSec/centinela!23
No description provided.