Skip to content

Commit

Permalink
windsock: apply shell escaping where needed
Browse files Browse the repository at this point in the history
  • Loading branch information
rukai committed Sep 13, 2023
1 parent c58e10b commit 4c21311
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
8 changes: 8 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions shotover-proxy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ license = "Apache-2.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
shell-quote = "0.3.0"
shotover = { path = "../shotover" }

[dev-dependencies]
Expand Down
3 changes: 2 additions & 1 deletion shotover-proxy/benches/windsock/aws/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ sudo docker system prune -af"#,
// start container
let mut env_args = String::new();
for (key, value) in envs {
// TODO: shell escape key and value
let key = String::from_utf8(shell_quote::bash::escape(key)).unwrap();
let value = String::from_utf8(shell_quote::bash::escape(value)).unwrap();
env_args.push_str(&format!(" -e \"{key}={value}\""))
}
let output = self
Expand Down
1 change: 1 addition & 0 deletions windsock-cloud-docker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ license = "Apache-2.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
shell-quote = "0.3.0"
subprocess.workspace = true
9 changes: 8 additions & 1 deletion windsock-cloud-docker/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ use subprocess::{Exec, Redirection};
fn main() {
let mut args = std::env::args();
args.next(); // skip binary name
let args: Vec<String> = args.collect();
let args: Vec<String> = args
.map(|x| {
format!(
"'{}'",
String::from_utf8(shell_quote::bash::escape(x)).unwrap()
)
})
.collect();
let args = args.join(" ");

// ensure container is setup
Expand Down

0 comments on commit 4c21311

Please sign in to comment.