Skip to content

Commit

Permalink
fix: leaking env to node process and log cmd (native provider)
Browse files Browse the repository at this point in the history
  • Loading branch information
pepoviola committed May 14, 2024
1 parent 11ea125 commit 93e9b41
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions crates/provider/src/native/node.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use std::{
collections::HashMap,
env,
path::{Path, PathBuf},
process::Stdio,
sync::{Arc, Weak},
Expand Down Expand Up @@ -225,8 +227,14 @@ where
}

async fn initialize_process(&self) -> Result<(ChildStdout, ChildStderr), ProviderError> {
let filtered_env: HashMap<String, String> = env::vars()
.filter(|(k, _)| k == "TZ" || k == "LANG" || k == "PATH")
.collect();

let mut process = Command::new(&self.program)
.args(&self.args)
.env_clear()
.envs(&filtered_env) // minimal environment
.envs(self.env.to_vec())
.stdin(Stdio::null())
.stdout(Stdio::piped())
Expand Down Expand Up @@ -397,8 +405,11 @@ where
}

fn log_cmd(&self) -> String {
let base_dir = format!("{}/{}", self.base_dir().to_string_lossy(), self.name());
format!("tail -f {}/{}.log", base_dir, self.name())
format!(
"tail -f {}/{}.log",
self.base_dir().to_string_lossy(),
self.name()
)
}

fn path_in_node(&self, file: &Path) -> PathBuf {
Expand Down

0 comments on commit 93e9b41

Please sign in to comment.