Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windsock: apply shell escaping where needed #1334

Merged
merged 2 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 3 additions & 2 deletions shotover-proxy/benches/windsock/aws/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,9 @@ sudo docker system prune -af"#,
// start container
let mut env_args = String::new();
for (key, value) in envs {
// TODO: shell escape key and value
env_args.push_str(&format!(" -e \"{key}={value}\""))
let key_value =
String::from_utf8(shell_quote::bash::escape(format!("{key}={value}"))).unwrap();
env_args.push_str(&format!(" -e {key_value}"))
}
let output = self
.instance
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
4 changes: 3 additions & 1 deletion windsock-cloud-docker/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ 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| String::from_utf8(shell_quote::bash::escape(x)).unwrap())
.collect();
let args = args.join(" ");

// ensure container is setup
Expand Down
Loading