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

Static evaluation of CARGO_WORKSPACE_DIR env var leaks to consumers. #41

Open
rcgoodfellow opened this issue Sep 12, 2023 · 0 comments
Open
Labels

Comments

@rcgoodfellow
Copy link
Collaborator

rcgoodfellow commented Sep 12, 2023

In the following code

falcon/ztest/src/lib.rs

Lines 298 to 337 in 29deea1

pub fn copy_bin_to_zone(&self, name: &str, bin: &str) -> Result<()> {
let profile = if cfg!(debug_assertions) {
"debug"
} else {
"release"
};
let from = match env!("CARGO_WORKSPACE_DIR") {
"" => format!("target/{}/{}", profile, bin),
path => format!("{}target/{}/{}", path, profile, bin),
};
let to = format!("opt/{}", bin);
self.copy_to_zone(name, &from, &to)
}
pub fn copy_workspace_to_zone(
&self,
name: &str,
from: &str,
to: &str,
) -> Result<()> {
let from = match env!("CARGO_WORKSPACE_DIR") {
"" => from.into(),
path => format!("{}{}", path, from),
};
self.copy_to_zone(name, &from, to)
}
pub fn copy_workspace_to_zone_recursive(
&self,
name: &str,
from: &str,
to: &str,
) -> Result<()> {
let from = match env!("CARGO_WORKSPACE_DIR") {
"" => from.into(),
path => format!("{}{}", path, from),
};
self.copy_to_zone_recursive(name, &from, to)
}
}

the falcon ztest library is evaluating CARGO_WORKSPACE_DIR at compile time. This check also happens in any crate that consumes ztest and then goes on to transitively impact all crates in a dependency tree involving ztest. This is highly undesirable behavior. Figure out a better way to find workspace binaries than the current approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant