Let reviewers label decisions from the Grafana review dashboard #24

Merged
james merged 3 commits from review-labels into main 2026-10-27 21:37:26 +00:00
Owner

Reviewers can now mark a decision False positive or Should be blocked from the review dashboard. Labels are recorded for retraining and change nothing live.

How it works

  • Buttons: each row of the review dashboard's Requests table gets two Grafana actions, each behind a confirmation showing the request (method, host, path, verdict, source).
  • Route: the actions go through an Infinity data source (uid centinela-labels), so the request comes from Grafana's server inside the cluster. Only people who can sign in to Grafana can label, and nothing new faces the internet.
  • Endpoint: centinela serves them on a new review listener, off by default. review.listen serves POST /v1/labels, which needs CENTINELA_REVIEW_TOKEN as a bearer token. The token is env only, at least 32 characters, or startup fails.
  • Contents: a label carries the row's id, host, path, method, client, verdict, source, status, reasons and scores, so it stands on its own for requests the model never saw. The fields arrive as URL query parameters, which Grafana encodes; a JSON body built from row values would break on paths containing quotes. A JSON body is also accepted.
  • Who and when: the reviewer comes from the X-Grafana-User header that Grafana's data source proxy adds, and the time from the server. Neither can be set in the label itself.
  • Storage: labels are appended to review.labels / CENTINELA_LABELS (one JSON line each) and logged as msg=label. A new Labels panel lists them, and the Requests table gains a Status column.

Testing

  • Recording: a label is stored with the reviewer and time from the server; values for them sent in the label are ignored.
  • Rejected: no token, a wrong token, a token without Bearer, an unknown label, a bad id, a body that isn't JSON, an oversized body.
  • Long fields: truncated to 1 KiB.
  • Query parameters: a path with quotes and markup is stored intact.
  • Config: a review listener without a token fails at startup, and a token in the config file is refused.
  • Token check: disabling it on purpose makes the rejection tests fail.
  • go vet and go test ./... pass.

Rollout (gitops, after merge)

  • Grafana: install the Infinity plugin, add a data source with uid centinela-labels that sends the token as a secure header, set [dataproxy] send_user_header = true, and update the review dashboard copy.
  • centinela:
    • the new image, review.listen: 0.0.0.0:9110, and CENTINELA_LABELS=/var/lib/centinela/labels-$(POD_NAME).jsonl as env;
    • the token in a Secret;
    • a centinela-review Service on port 9110, and a NetworkPolicy admitting only Grafana to that port.
Reviewers can now mark a decision **False positive** or **Should be blocked** from the review dashboard. Labels are recorded for retraining and change nothing live. ## How it works - **Buttons:** each row of the review dashboard's Requests table gets two Grafana actions, each behind a confirmation showing the request (method, host, path, verdict, source). - **Route:** the actions go through an Infinity data source (uid `centinela-labels`), so the request comes from Grafana's server inside the cluster. Only people who can sign in to Grafana can label, and nothing new faces the internet. - **Endpoint:** centinela serves them on a new review listener, off by default. `review.listen` serves `POST /v1/labels`, which needs `CENTINELA_REVIEW_TOKEN` as a bearer token. The token is env only, at least 32 characters, or startup fails. - **Contents:** a label carries the row's id, host, path, method, client, verdict, source, status, reasons and scores, so it stands on its own for requests the model never saw. The fields arrive as URL query parameters, which Grafana encodes; a JSON body built from row values would break on paths containing quotes. A JSON body is also accepted. - **Who and when:** the reviewer comes from the `X-Grafana-User` header that Grafana's data source proxy adds, and the time from the server. Neither can be set in the label itself. - **Storage:** labels are appended to `review.labels` / `CENTINELA_LABELS` (one JSON line each) and logged as `msg=label`. A new **Labels** panel lists them, and the Requests table gains a **Status** column. ## Testing - **Recording:** a label is stored with the reviewer and time from the server; values for them sent in the label are ignored. - **Rejected:** no token, a wrong token, a token without `Bearer`, an unknown label, a bad id, a body that isn't JSON, an oversized body. - **Long fields:** truncated to 1 KiB. - **Query parameters:** a path with quotes and markup is stored intact. - **Config:** a review listener without a token fails at startup, and a token in the config file is refused. - **Token check:** disabling it on purpose makes the rejection tests fail. - `go vet` and `go test ./...` pass. ## Rollout (gitops, after merge) - **Grafana:** install the Infinity plugin, add a data source with uid `centinela-labels` that sends the token as a secure header, set `[dataproxy] send_user_header = true`, and update the review dashboard copy. - **centinela:** - the new image, `review.listen: 0.0.0.0:9110`, and `CENTINELA_LABELS=/var/lib/centinela/labels-$(POD_NAME).jsonl` as env; - the token in a Secret; - a `centinela-review` Service on port 9110, and a NetworkPolicy admitting only Grafana to that port.
Each row of the review dashboard's Requests table gets two actions,
"False positive" and "Should be blocked", each behind a confirmation. They
call centinela through an Infinity data source (uid centinela-labels), so
the request goes from Grafana's server inside the cluster: only people who
can sign in to Grafana can label, and nothing new faces the internet.

centinela serves them on a new review listener, off by default:

- review.listen (CENTINELA_REVIEW_LISTEN) serves POST /v1/labels, which
  needs CENTINELA_REVIEW_TOKEN (environment only, at least 32 characters)
  as a bearer token.
- A label carries the row's decision id, host, path, client, verdict,
  source, status, reasons and scores, so it stands on its own for requests
  the model never saw. They arrive as URL query parameters, which Grafana
  encodes; a JSON body built from row values would break on paths
  containing quotes. A JSON body is accepted too.
- The reviewer comes from the X-Grafana-User header Grafana's data source
  proxy adds, and the time from the server, never from the label itself.
- Labels are appended to review.labels (CENTINELA_LABELS), one JSON line
  each, and logged as msg=label. A new Labels panel lists them.

Labels change nothing live; they are input for retraining. The Requests
table also gains a Status column.
Document reviewer labels
Some checks failed
security-scan / security-scan (pull_request) Successful in 27s
test / laya (pull_request) Successful in 4s
test / go (pull_request) Has been cancelled
27b96a5c16

🔎 ojo scan results

No findings.

<!-- ojo-scan-summary --> ### 🔎 ojo scan results No findings.
Upgrade golang.org/x/net for GO-2026-6860, and draw the test token at random
All checks were successful
test / laya (pull_request) Successful in 4s
security-scan / security-scan (pull_request) Successful in 1m19s
test / go (pull_request) Successful in 3m14s
4e429edbe7
- golang.org/x/net 0.60.0 -> 0.62.0 fixes GO-2026-6860 (CVE-2026-78661),
  quadratic time when the HTML parser coalesces text nodes. Coraza's
  transformations import golang.org/x/net/html. govulncheck finds no call
  path to the affected code, but the module is in the binary, so it is
  upgraded rather than accepted. go mod tidy also moves x/sync to 0.24.0
  and x/text to 0.43.0.
- The review tests' bearer token is now random per run instead of a fixed
  string, which OJO flagged as a hardcoded secret. The tests never relied
  on its value.
james merged commit 3f0c2986de into main 2026-10-27 21:37:26 +00:00
james deleted branch review-labels 2026-10-27 21:37:26 +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!24
No description provided.