Skip to content

Commit 1354b5c

Browse files
committed
fix(runtime-config): enforce launch limits and redact args/env in debug
Address wolfyy970's #5321 re-review by mirroring #5349's hard limits at construction time, so an invalid launch document cannot be built — let alone serialized out through any Serialize path: - enforce 16-server / 128-arg / 128-env / 64KiB limits inside from_runtime_config (now returns Result) and re-check the 64KiB bound on the encoded bytes in to_json - drop the derived Debug on LaunchStdioServer for a manual impl that prints only the name and arg/env counts - redact both args and env values in the mcp_launch_mapper sample output - report environment entry issues by 1-based index rather than echoing (possibly secret) keys - add regression tests: too many servers/args/env rejected, oversized document rejected before encoding, and debug + sample output never leak arg/env secrets Co-authored-by: whyihaveyou <[email protected]> Signed-off-by: whyihaveyou <[email protected]>
1 parent 80dfdaf commit 1354b5c

2 files changed

Lines changed: 234 additions & 30 deletions

File tree

‎crates/buzz-runtime-config/examples/mcp_launch_mapper.rs‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ use buzz_runtime_config::McpServerConfig;
1717
fn redacted_json(doc: &McpLaunchConfigDocument) -> serde_json::Value {
1818
let mut value = serde_json::to_value(doc).expect("doc serializes");
1919
for server in value["servers"].as_array_mut().expect("servers array") {
20+
// Arguments may carry secrets too (e.g. an API key passed as a CLI
21+
// flag), so redact both args and environment values before emitting
22+
// a shareable sample.
23+
if let Some(args) = server["args"].as_array_mut() {
24+
for arg in args.iter_mut() {
25+
*arg = serde_json::Value::String("***".to_string());
26+
}
27+
}
2028
if let Some(env) = server["env"].as_object_mut() {
2129
for val in env.values_mut() {
2230
*val = serde_json::Value::String("***".to_string());
@@ -46,9 +54,9 @@ fn main() {
4654
path.display()
4755
)
4856
});
49-
let doc = McpLaunchConfigDocument::from_runtime_config(&native);
50-
doc.validate()
51-
.unwrap_or_else(|err| panic!("mapped document is invalid: {err}"));
57+
let doc = McpLaunchConfigDocument::from_runtime_config(&native).unwrap_or_else(|err| {
58+
panic!("mapped document is invalid (no launch document can be built): {err}")
59+
});
5260

5361
let total = native.servers.len();
5462
let enabled = native

0 commit comments

Comments
 (0)