fix: TOML-escape iris token and base URL in docker entrypoint (COD-470) - #15
Conversation
The entrypoint escaped RITE_IRIS_API_TOKEN SQL-style inside a TOML literal string. TOML literal strings cannot contain single quotes, so a token like o'brien produced an unparseable rite.toml and a crashing container. base_url was also interpolated unescaped into a basic string, breaking on quotes/backslashes. Emit TOML basic strings with backslash and double-quote escaped, newline as \n, tab left raw (legal), and every other control byte plus DEL as \uXXXX. Use GNU sed -z so embedded newlines are matchable without a sentinel byte. Add an integration test that runs the real entrypoint and parses its output through rite's production load_config: quote/backslash/control/multiline round- trips for both fields, full 0x01-0x1F/0x7F sweep, STX sentinel regression, token absence, blank base_url, and token-never-logged. Closes COD-470.
🤖 Automated Review PanelDual review of Reviewer A — BLOCK → resolved
Reviewer B — BLOCK → resolved
Panel outcome: all five blocking/major findings resolved in Note: this panel ran on glm-5.1 children (cron pin differed from the usual gpt-5.6-terra runner seat). Both seats produced reproducible, verified findings; Reviewer A re-ran the failing materializations manually before blocking. |
dash's builtin echo interprets backslash escapes in its arguments, so the \\n / \\b / \\f / \\r sequences produced by toml_escape were mangled when /bin/sh is dash — which it is on the production runtime image (Debian bookworm). Emit lines with printf, whose format string is the only escape-processed part. Verified under the actual production shell by running the script inside debian:bookworm-slim (dash + GNU sed 4.9).
🤖 Review Panel Addendum — CI-caught defect fixed in
|
Auto-Merge Gate — eligible (0.94)Rationale: COD-470's focused two-file fix replaces invalid TOML literal-string handling with escaped TOML basic strings for both Iris fields. The regression suite executes the real entrypoint through Rite's production parser, including quote, backslash, CRLF/newline, control-byte, DEL, and no-token-leak cases. Checks observed: GitHub CI Scope limits: No deployment/cutover, credentials, or destructive behavior is included. Linked Linear ticket has no manual-review marker and its acceptance criteria are satisfied by this PR. |
Summary
Fixes a TOML escaping defect in
docker-entrypoint.shdiscovered while executing the deferred COD-467 Docker materialization acceptance check against mergedmain(a868849).The defect: the entrypoint escaped
RITE_IRIS_API_TOKENSQL-style ('→'') inside a TOML literal string. TOML literal strings cannot contain single quotes and have no escape mechanism — a token likeo'briengenerated an unparseablerite.tomland a crashing container.base_urlwas also interpolated unescaped into a double-quoted basic string, breaking on"or\, and raw control characters are invalid in basic strings.Reproduction on merged main:
Fix
toml_escape()emits TOML basic strings:\\and\"escaped, newline →\n, tab left raw (legal), every other control byte (0x01–0x1F) plus DEL →\uXXXX— applied to bothapi_tokenandbase_url.sed -z(NUL-delimited records; env values cannot contain NUL) so embedded newlines are matchable without a sentinel byte.Test coverage (new:
crates/rite-server/tests/docker_entrypoint.rs)Runs the real entrypoint script and parses its output through rite's production parser (
rite_server::load_config), asserting exact round-trip:[sources.iris]emitted)o'brien,to"ken,back\slash, mixed delimitersbase_urlReview panel
Both seats BLOCKed the first version (correctly — findings below were fixed in this head):
sed -zremoves the sentinel entirely; STX regression test added.\uXXXXtable; full-sweep test added.base_url(Reviewer A MINOR) → fixed: dedicated test.generated_token_is_never_loggeddidn't assert exit success (Reviewer A MINOR) → fixed.std::env::varfails on non-UTF-8), andrite'sread_to_stringstartup path already requires UTF-8 configs, so non-UTF-8 values fail loudly at the same place they would have before. Documented in the script comment instead.Verification
cargo build --all-targets✅cargo test --all-targets✅ (36 tests / 6 suites, incl. 14 new)cargo clippy --all-targets -- -D warnings✅cargo fmt --all -- --check✅cargo run -p rite-codegen -- check✅sh -n docker-entrypoint.sh✅main(defect) and this branch (fix) withtomllib+odbyte-level inspection: raw SOH/STX/newline never appear on disk, only\uXXXX/\nescapes.Closes COD-470 (discovered during the COD-467 acceptance check).