Skip to content

feat(server): let the environment set allowed hosts and the auth header - #104

Merged
plusky merged 1 commit into
mainfrom
feat/env-config
Aug 18, 2026
Merged

feat(server): let the environment set allowed hosts and the auth header#104
plusky merged 1 commit into
mainfrom
feat/env-config

Conversation

@plusky

@plusky plusky commented Aug 18, 2026

Copy link
Copy Markdown
Owner

Closes the last two env-less flags so container deployments (#31, #32) can configure bugwarden entirely through the environment: MCP_ALLOWED_HOSTS and BUGZILLA_USE_AUTH_HEADER.

The load-bearing detail

One variable must carry the whole host list, so Cli::resolved_allowed_hosts splits on commas and whitespace and drops empty entries. Without that drop, MCP_ALLOWED_HOSTS= parses to [""] — rmcp's host_is_allowed skips unparsable entries and matches what's left, so validation switches ON with nothing matchable and every Host is refused. Empty now reads as unset, the BUGZILLA_API_KEY_FILE= convention. Mutation-proven; a guard-lens reviewer probed 24 inputs end-to-end (unicode whitespace, lone commas, Helm join artifacts) and found no input that enables validation when "unset" was plausibly meant, and none that serves a Host the list doesn't name. I9 verified both directions: env can only tighten, CLI wins outright.

Adversarial review before opening

Two reviewers, both initially NOT MERGE-SAFE; all findings fixed:

  • Ambient env broke the suite invisibly to CI: MCP_ALLOWED_HOSTS=example.com failed 11/13 http-transport tests (harness never neutralised the newly env-fed field). Fixed; whole suite now green under three ambient vars at once.
  • binary_user_agent's env-scrub list claimed completeness while missing entries — and the new sweep test that pins it immediately exposed three pre-existing gaps (MCP_HOST, MCP_PORT, MCP_API_KEY_HEADER), now closed.
  • The resolved_allowed_hosts rustdoc claimed flag∪env union; clap takes one source (CLI suppresses env). Corrected — on a security-control resolver that was a real deployment trap.
  • DESIGN.md Testing list gains the sixth test binary (env_config.rs, ONE test by construction — it mutates process-global env); the command-line-only decision for --allowed-hosts is recorded as SUPERSEDED rather than deleted.

Verification

All five AGENTS.md commands on the rebased tree: fmt/clippy×2 clean, 441 passed / 0 failed, cargo deny check fully green (post-h2-bump). Assets regenerated, second run byte-identical.

Out of scope, tracked separately: no startup log of effective Host-validation state; * and similar unparsable entries silently deny-all; allowed_origins has no knob at all.

Container deployments configure bugwarden entirely through the
environment (#31, #32), and two flags were still command line only:
--allowed-hosts deliberately so, --use-auth-header by omission. Both now
carry an env fallback, MCP_ALLOWED_HOSTS and BUGZILLA_USE_AUTH_HEADER.

One variable has to carry the whole host list, so
Cli::resolved_allowed_hosts splits every entry on commas and whitespace
and drops the empty ones. That drop is load-bearing: rmcp's
host_is_allowed skips an entry it cannot parse and matches against what
is left, so the single empty entry MCP_ALLOWED_HOSTS= produces would
switch validation on with nothing matchable and refuse every Host.
Dropping it makes MCP_ALLOWED_HOSTS= read as unset instead, the same
convention BUGZILLA_API_KEY_FILE= already follows.

Environment-backed flags leak into test processes, so the http harness
now neutralises allowed_hosts like the two key fields, and the
binary_user_agent scrub list is pinned by a sweep test that fails when
any env-bearing flag is missing from it — which promptly exposed
MCP_HOST, MCP_PORT and MCP_API_KEY_HEADER as pre-existing gaps, now
closed.

DESIGN.md records the reversal of the command-line-only decision rather
than deleting it, and its Testing list gains the new env_config binary
(one test by construction: it mutates the process environment). A unit
test fails the moment any flag ships without an env fallback. Man page
and completions regenerated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant