feat(server): let the environment set allowed hosts and the auth header - #104
Merged
Conversation
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.
This was referenced Aug 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the last two env-less flags so container deployments (#31, #32) can configure bugwarden entirely through the environment:
MCP_ALLOWED_HOSTSandBUGZILLA_USE_AUTH_HEADER.The load-bearing detail
One variable must carry the whole host list, so
Cli::resolved_allowed_hostssplits on commas and whitespace and drops empty entries. Without that drop,MCP_ALLOWED_HOSTS=parses to[""]— rmcp'shost_is_allowedskips unparsable entries and matches what's left, so validation switches ON with nothing matchable and every Host is refused. Empty now reads as unset, theBUGZILLA_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:
MCP_ALLOWED_HOSTS=example.comfailed 11/13 http-transport tests (harness never neutralised the newly env-fed field). Fixed; whole suite now green under three ambient vars at once.MCP_HOST,MCP_PORT,MCP_API_KEY_HEADER), now closed.resolved_allowed_hostsrustdoc claimed flag∪env union; clap takes one source (CLI suppresses env). Corrected — on a security-control resolver that was a real deployment trap.env_config.rs, ONE test by construction — it mutates process-global env); the command-line-only decision for--allowed-hostsis 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 checkfully 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_originshas no knob at all.