MCPcopy Index your code
hub / github.com/Rust-API/Rust-API-Bypass-Checker / dump_invocation

Function dump_invocation

src/bin/mir_wrapper.rs:103–137  ·  view source on GitHub ↗
(path: &str, argv: &Vec<String>)

Source from the content-addressed store, hash-verified

101}
102
103fn dump_invocation(path: &str, argv: &Vec<String>) {
104 let cwd = env::current_dir()
105 .ok()
106 .map(|p| p.to_string_lossy().to_string())
107 .unwrap_or_else(|| ".".to_string());
108
109 // 只保存一小撮关键 env,避免 dump 文件过大
110 let keys = [
111 "RUSTUP_TOOLCHAIN",
112 "RUSTFLAGS",
113 "CARGO_ENCODED_RUSTFLAGS",
114 "CARGO_TARGET_DIR",
115 "PATH",
116 "RUST_BACKTRACE",
117 "RUST_LOG",
118 "BYPASSER_ARGS",
119 "MIR_CHECKER_ARGS",
120 ];
121
122 let mut env_obj = serde_json::Map::new();
123 for k in keys {
124 if let Ok(v) = env::var(k) {
125 env_obj.insert(k.to_string(), Value::String(v));
126 }
127 }
128
129 let j = json!({
130 "cwd": cwd,
131 "argv": argv,
132 "env": env_obj
133 });
134
135 let text = serde_json::to_string_pretty(&j).expect("json serialize failed");
136 fs::write(path, text).expect("failed to write dump file");
137}

Callers 1

mainFunction · 0.85

Calls 1

insertMethod · 0.45

Tested by

no test coverage detected