Skip to content
Closed
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
10 changes: 2 additions & 8 deletions crates/bashkit/tests/integration/python_security_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,14 +612,8 @@ mod whitebox_env_security {
.exec("INTERNAL_VAR=secret\npython3 -c \"import os\nprint(os.getenv('INTERNAL_VAR', 'none'))\"")
.await
.unwrap();
// Unexported vars should not be visible to Python
// (bash semantics: only exported vars are in env)
// Note: bashkit merges variables, so this tests that behavior
if r.exit_code == 0 {
// If visible, verify it's the expected value (no corruption)
let out = r.stdout.trim();
assert!(out == "none" || out == "secret");
}
assert_eq!(r.exit_code, 0);
assert_eq!(r.stdout.trim(), "none");
Comment on lines +615 to +616
}

#[tokio::test]
Expand Down
14 changes: 11 additions & 3 deletions crates/bashkit/tests/spec_cases/python/env_leak.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,22 @@ python3 -c "import os; print(os.getenv('_READONLY_x', 'none'))"
none
### end

### user_variable_still_visible
# Regular user variables should still be accessible from Python
MY_VAR=hello
### exported_variable_visible
# Exported variables are visible in Python via os.environ
export MY_VAR=hello
python3 -c "import os; print(os.getenv('MY_VAR', 'missing'))"
### expect
hello
### end

### unexported_variable_not_visible
# Non-exported shell variables are NOT visible in Python (matches bash semantics)
UNEXPORTED_VAR=secret
python3 -c "import os; print(os.getenv('UNEXPORTED_VAR', 'none'))"
### expect
none
### end

### shopt_not_visible
# SHOPT_ variables should not be visible in Python
python3 -c "import os; shopt_vars = [k for k in os.environ if k.startswith('SHOPT_')]; print(len(shopt_vars))"
Expand Down
Loading