Skip to content

Collector

Blank out string literals

Release: v0.1.0 (latest)

A branch condition can hold text from your code, such as "ENABLE_LEGACY_DISCOUNT" in an environment lookup, or a hard-coded key your code compares against input. The agent sends it as it is. The collector can replace that text with … before any payload leaves your network. Blanking is off until you set one of two environment variables. Blanking also needs a secret, which the collector uses to replace the agent’s branch and site keys. See replace branch and site keys.

Blanking happens only in the collector. The agent has no such setting, so an agent that posts straight to a backend sends literals and keys as they are.

What the collector blanks

A string literal part is a piece of a branch condition that holds a string constant from your class files, or the label of a when or switch case on a string. What the agent sends describes what the agent puts in one.

The collector looks at the condition parts in two places, in every branch site of the manifest and of the static baseline:

  • The condition of the branch site.
  • The case label of each outcome of the site.

The collector blanks a part when its kind is neither code nor placeholder and the settings select it. A part of a kind the collector does not recognise counts as a literal, so the same settings blank it. The part keeps its kind, and its text becomes ….

The class listing holds class names and the include and exclude rules. The collector keeps both as they arrive, as it keeps class names everywhere else.

Class, method, parameter and file names, line numbers, route templates and library paths pass through as they arrive. A condition’s code parts stay readable, so a blanked condition still shows its shape.

Choose what to blank

The collector blanks a literal when it matches a pattern in OTHERLODE_COLLECTOR_REDACT_BLOCKED_VALUES, or when OTHERLODE_COLLECTOR_REDACT_ALL_LITERALS is true. The collector reads both once at startup. Blanking is on when at least one pattern is set or when OTHERLODE_COLLECTOR_REDACT_ALL_LITERALS is true. While blanking is on, the collector also needs OTHERLODE_COLLECTOR_REDACT_SECRET or OTHERLODE_COLLECTOR_REDACT_SECRET_FILE, or it does not start.

VariableDefaultAccepted valuesEffect
OTHERLODE_COLLECTOR_REDACT_BLOCKED_VALUESunsetOne regular expression per line, in Go syntaxBlanks each literal that a pattern matches
OTHERLODE_COLLECTOR_REDACT_ALL_LITERALSunset (off)1, t, T, TRUE, true, True, 0, f, F, FALSE, false, Falsetrue blanks every literal

Blank every literal

OTHERLODE_COLLECTOR_REDACT_ALL_LITERALS=true
OTHERLODE_COLLECTOR_REDACT_SECRET_FILE=/run/secrets/otherlode-redact-secret

Use this when you do not want to judge which literals are safe to send.

Blank literals that match a pattern

Put one pattern on each line. Patterns use Go regular expression syntax. A pattern matches anywhere in the literal’s text unless you anchor it with ^ or $. The collector tests each pattern against one literal at a time, and the text is the string without quotes. The collector skips blank lines and uses any other line as written, so spaces at its start or end belong to the pattern.

OTHERLODE_COLLECTOR_REDACT_BLOCKED_VALUES='^sk_live_
(?i)password
^[0-9]{4}$'

These three patterns blank a literal that starts with sk_live_, a literal that contains password in any case, and a literal of exactly four digits. The collector sends a literal that matches no pattern as it is.

Startup errors

A value the collector cannot use stops startup with exit code 1. A typo cannot leave blanking off. The error is one JSON log line, and its msg field holds the text.

The error for a pattern that does not compile names its line number, counted from 1 with blank lines included:

OTHERLODE_COLLECTOR_REDACT_BLOCKED_VALUES line 3: error parsing regexp: missing closing ): `(oops`

A value that is not a boolean:

OTHERLODE_COLLECTOR_REDACT_ALL_LITERALS: strconv.ParseBool: parsing "yes": invalid syntax

The secret has its own startup errors. See secret errors at startup.

When blanking is on, the collector logs this line at startup. secret_fingerprint names the secret without revealing it. See compare the fingerprints.

{"time":"...","level":"INFO","msg":"redacting string literals and re-keying branch and site keys in ingested payloads","blocked_values":3,"all_literals":false,"secret_fingerprint":"765616210e4aabd4"}

Check that blanking works

The counter otherlode_collector_redacted_literals_total on /metrics counts the parts the collector blanked. otherlode_collector_redacted_case_keys_total counts the case keys it cleared. See case keys that are a hash code. The payload label of both is manifest or static_baseline. A class listing holds no string literal, so it adds to neither. Neither has a series until a payload arrives with something to blank or clear.

No counter and no log line holds a literal’s text, a key or the secret.

The collector drops unknown fields while blanking is on

The collector cannot see a literal inside a field it does not know. So while either setting is on, it drops every protobuf field it does not know from every payload, delta batches and class listings included. If a payload lost at least one field, the collector sets fields_stripped on the payload’s resource attributes and counts the payload in otherlode_collector_fields_stripped_total. Its payload label is deltas, manifest, static_baseline or class_listing.

The collector logs one warning for each run, with the first payload that loses a field. The line carries the namespace, service, instance, run, agent_version and payload fields:

{"time":"...","level":"WARN","msg":"dropped fields this collector does not know; its bindings are older than the agent's, so the server withholds findings from this run; upgrade to the latest collector","namespace":"...","service":"...","instance":"...","run":"...","agent_version":"...","payload":"..."}

A dropped field can be one that Otherlode judges by. Otherlode stores a marked run and shows it, but counts it in no finding. See a run with dropped or unknown fields makes no claim.

To fix it, run the latest collector. With both settings off, the collector drops nothing and marks nothing.

Replace branch and site keys

The agent names each branch outcome with a branch_key and each branch site with a site_key. Each key is a digest of the site’s bytecode, and that bytecode includes the site’s string literals. See branch and site keys in the agent’s docs. Every other input to a key is in the payload. So anyone who holds a blanked payload and a plain key can hash a guess at the blanked literal and compare the result with the key. A few guesses are enough to find a short literal, such as a flag name or a host name.

So while blanking is on, the collector replaces every branch_key and site_key in manifests and static baselines with HMAC-SHA256 of the key under a secret. It keeps the first 16 bytes, written as 32 lowercase hex characters, the same shape the agent sends. Equal keys stay equal, so Otherlode still joins one branch across builds and instances. Without the secret, a reader of your data in Otherlode who holds no agent token cannot test a guess against a key. An empty key stays empty.

The collector re-keys any key a payload carries. So anyone who holds an agent token, whichever service it was given to, can send keys built from guessed literals. The collector re-keys them, and Otherlode stores the results beside the real keys. Someone who can also read your data in Otherlode can then compare them. Give agent tokens only to the services that run the agent.

Set the secret

Set one of two variables. Setting both stops startup.

VariableHolds
OTHERLODE_COLLECTOR_REDACT_SECRETThe secret. The collector trims spaces around it.
OTHERLODE_COLLECTOR_REDACT_SECRET_FILEThe path of a file that holds the secret on one line. The file follows the rules of a token file. The collector skips blank lines and lines that start with #, and trims spaces around the line.

The secret must follow these rules, or the collector does not start:

  • It is at least 32 bytes long.
  • It holds no control character, such as a tab or a newline inside the value.
  • It differs from every agent token and from the forward key. Every agent holds an agent token, and Otherlode holds the forward key, so neither can keep the keys secret. The collector also checks this each time it re-reads a token file. The collector refuses a token file that holds the secret like any other bad re-read. It keeps the last good tokens and counts the failure in otherlode_collector_token_reload_failures_total.
  • It is set only while blanking is on. A secret with both blanking settings off stops startup.

Make a secret with openssl. It prints 64 hex characters, which is 64 bytes.

openssl rand -hex 32

The collector reads the secret once, at startup. Unlike the token files, it never reads the file again, because a secret that changed during a run would change every key from then on. A changed file takes effect at the next restart.

Use one secret for every collector of a tenant

Give the same secret to every collector that sends to one Otherlode tenant. That includes the collector in each environment and the collector that your test runs report through. Two collectors with different secrets give one branch two different keys, so Otherlode keeps two histories for that branch.

A JVM that reaches Otherlode without a redacting collector sends plain keys. A test JVM that posts straight to Otherlode, or through a collector with blanking off, sends the plain keys of every production class it loads. With those plain keys, anyone who reads your data in Otherlode can test guesses at the literals in those classes. Point the test JVM at a collector with the same blanking settings and the same secret as production’s. Test runs covers the agent’s side.

Compare the fingerprints

A collector cannot see another collector’s secret. It logs a fingerprint of its own secret instead, as secret_fingerprint in the startup line above. The fingerprint is 16 lowercase hex characters, taken from an HMAC of a fixed text under the secret. Two collectors with the same secret log the same fingerprint. Compare the fingerprints of all the collectors of a tenant to check that they share one secret.

Changing the secret starts new history

Turning blanking on changes every key. So does a new secret. Otherlode then treats every branch and site as new. The history it holds under the old keys stops growing, and the new keys start their own. No setting changes the secret without that break.

Pick the secret once, before you turn blanking on for a tenant, and keep it.

Case keys that are a hash code

A switch on a string that the agent cannot read back reaches the collector as a switch on the string’s hashCode(). Each case key of such a switch is the hash code of one string, usually one of your literals. A hash code is a 32-bit digest, so it also lets its holder test guesses. See switches in the agent’s docs.

While blanking is on, the collector clears two kinds of case key.

  • Every case key of a site the agent marks string_hash_code_switch. The collector cannot tell which literal a key hashes, so it clears every key of the site, even when the blanking settings would let that literal through.
  • A case key that equals the Java hash code of a literal that the collector blanked in the same method. This rule covers an agent that does not send the mark.

A cleared case has no key, so Otherlode shows it unnamed and cannot match it across builds. A case of an integer switch whose key equals the hash code of a literal blanked in the same method loses its key too. From an agent that does not send the mark, the collector does not clear a hash code whose literal is not in the payload. That happens when the agent could not write the condition of the equals check that holds the literal.

otherlode_collector_redacted_case_keys_total counts the cleared case keys of both kinds.

Let Otherlode refuse payloads that were not blanked

While blanking is on, the collector sends the secret’s fingerprint in an Otherlode-Redaction header on every request it forwards, for all four payloads. With blanking off it sends no such header.

A tenant can have Otherlode require the header. Otherlode then refuses a payload that has no header, such as one an agent posted to it directly, with 403 and the error code redaction_required. It refuses a payload with another fingerprint with 403 and redaction_secret_mismatch. The collector answers the agent with the same 403 and logs a warning that carries the code as backend_error:

{"time":"...","level":"WARN","msg":"sink refused delta batch","error":"sink answered Forbidden: backend returned 403 Forbidden for service \"demo\" instance \"i1\"","status":403,"unlogged_sink_refusals":0,"backend_error":"redaction_secret_mismatch"}

redaction_required means this collector has blanking off. redaction_secret_mismatch means its secret differs from the one Otherlode expects. Fix the setting and restart the collector. The agent keeps its counts, so it sends the refused payloads again on its next flush. Forwarding covers the log line.

The header catches a setup mistake. It does not prove which collector sent a payload, because the fingerprint is in every forwarded request and in the startup log.

Secret errors at startup

Each of these stops startup with exit code 1, as one ERROR line whose msg field holds the text. No error quotes the secret.

MistakeMessage
Blanking is on and no secret is setredaction is on but neither OTHERLODE_COLLECTOR_REDACT_SECRET nor OTHERLODE_COLLECTOR_REDACT_SECRET_FILE is set; refusing to start, since plain branch and site keys let anyone who holds them test guesses at a redacted literal
Both variables are setOTHERLODE_COLLECTOR_REDACT_SECRET and OTHERLODE_COLLECTOR_REDACT_SECRET_FILE are both set; set one
The secret is too shortOTHERLODE_COLLECTOR_REDACT_SECRET: the secret is 5 bytes, want at least 32
The secret holds a control characterOTHERLODE_COLLECTOR_REDACT_SECRET: the secret holds a control character at byte 16
The variable holds only spacesOTHERLODE_COLLECTOR_REDACT_SECRET holds only spaces
The secret is an agent tokenOTHERLODE_COLLECTOR_AUTH_TOKEN: the list holds the redaction secret, which equals an agent auth token that every agent holds; use a secret of its own
A token file holds the secretOTHERLODE_COLLECTOR_AUTH_TOKEN_FILE: /run/secrets/collector-tokens: the file holds the redaction secret, which equals an agent auth token that every agent holds; use a secret of its own
The secret is the forward keyOTHERLODE_COLLECTOR_FORWARD_AUTH_TOKEN: the value is the redaction secret, which equals the forward key that the backend holds; use a secret of its own
The forward key file holds the secretOTHERLODE_COLLECTOR_FORWARD_AUTH_TOKEN_FILE: /run/secrets/forward-key: the file holds the redaction secret, which equals the forward key that the backend holds; use a secret of its own
A secret is set and blanking is offOTHERLODE_COLLECTOR_REDACT_SECRET or OTHERLODE_COLLECTOR_REDACT_SECRET_FILE is set but redaction is off; set OTHERLODE_COLLECTOR_REDACT_BLOCKED_VALUES or OTHERLODE_COLLECTOR_REDACT_ALL_LITERALS, or unset the secret variable
The file holds two secretsOTHERLODE_COLLECTOR_REDACT_SECRET_FILE: /run/secrets/otherlode-redact-secret: found 2 tokens, want exactly one

A secret from the file gives the same messages under the name OTHERLODE_COLLECTOR_REDACT_SECRET_FILE. A file that is missing, is not a regular file or is larger than 1 MiB gives the file errors of a token file.