Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(saas): harden isolation test harness

Steven Enamakel689da75a7f21
diff --git a/tests/saas_isolation/probes.rs b/tests/saas_isolation/probes.rs
index 63a4ddb047..23e9e7bcf1 100644
--- a/tests/saas_isolation/probes.rs
+++ b/tests/saas_isolation/probes.rs
@@ -184,7 +184,7 @@ fn host_tool_probes_are_refused_under_the_profile_policy() {
d.root.join("users/alice/sandbox/link-to-bob"),
)
.unwrap();
- let probes: Vec<(&str, &str, Value)> = vec![
+ let mut probes: Vec<(&str, &str, Value)> = vec![
("host-read", "file_read", json!({ "path": host_secret })),
(
"operator-read",
@@ -237,17 +237,19 @@ fn host_tool_probes_are_refused_under_the_profile_policy() {
"path": pwned_patch, "old_string": "", "new_string": canary(0, "pwn")
}] }),
),
- (
- "symlink-read",
- "file_read",
- json!({ "path": "link-to-bob/workspace/memory/conversations/threads.jsonl" }),
- ),
(
"shell",
"shell",
json!({ "command": format!("touch {}", shell_marker.display()) }),
),
];
+ // The link above only exists on Unix, so only Unix probes through it.
+ #[cfg(unix)]
+ probes.push((
+ "symlink-read",
+ "file_read",
+ json!({ "path": "link-to-bob/workspace/memory/conversations/threads.jsonl" }),
+ ));
let results: Vec<(&str, &str, Outcome)> = std::thread::scope(|s| {
let handles: Vec<_> = probes
.iter()
diff --git a/tests/saas_isolation/world.rs b/tests/saas_isolation/world.rs
index 525388c2da..ab33c40208 100644
--- a/tests/saas_isolation/world.rs
+++ b/tests/saas_isolation/world.rs
@@ -307,15 +307,19 @@ impl World {
if let Some(client) = params["client_id"].as_str() {
Pools::push(&mut self.pools.clients, actor, client, None);
}
- let sent: HashSet<String> = params
- .as_object()
- .map(|m| {
- m.values()
- .filter_map(Value::as_str)
- .map(str::to_owned)
- .collect()
- })
- .unwrap_or_default();
+ // Every string anywhere in the params, however deeply nested.
+ let mut sent: HashSet<String> = HashSet::new();
+ let mut pending = vec![params];
+ while let Some(value) = pending.pop() {
+ match value {
+ Value::String(s) => {
+ sent.insert(s.clone());
+ }
+ Value::Array(items) => pending.extend(items),
+ Value::Object(map) => pending.extend(map.values()),
+ _ => {}
+ }
+ }
let mut stack = vec![(body.clone(), thread)];
while let Some((value, thread)) = stack.pop() {
match value {
diff --git a/tests/saas_mode/node.rs b/tests/saas_mode/node.rs
index dc9b53b1dd..dec51d75b0 100644
--- a/tests/saas_mode/node.rs
+++ b/tests/saas_mode/node.rs
@@ -26,7 +26,23 @@ impl Node {
.lines()
.filter(|line| !line.contains("rpc_handler [rpc]"))
.collect();
- lines[lines.len().saturating_sub(80)..].join("\n")
+ // A failure trace is shared output: drop lines that may carry a
+ // credential and cap the rest.
+ lines[lines.len().saturating_sub(80)..]
+ .iter()
+ .map(|line| {
+ let lower = line.to_ascii_lowercase();
+ if ["bearer", "token", "authorization", "secret", "password", "canary"]
+ .iter()
+ .any(|k| lower.contains(k))
+ {
+ "[redacted log line]".to_string()
+ } else {
+ line.chars().take(300).collect()
+ }
+ })
+ .collect::<Vec<String>>()
+ .join("\n")
}
pub fn kill(&mut self) {
diff --git a/tests/saas_profile_isolation_e2e.rs b/tests/saas_profile_isolation_e2e.rs
index 5b841f859d..366e1e7ac7 100644
--- a/tests/saas_profile_isolation_e2e.rs
+++ b/tests/saas_profile_isolation_e2e.rs
@@ -71,8 +71,13 @@ fn act(w: &mut World, actor: usize, method: &str, params: Value) -> Value {
let (status, _, body) = call(&w.node, USERS[actor], method, params.clone());
let text = body.to_string();
let short: String = text.chars().take(160).collect();
+ // Parameter names only: the values are user content and credentials.
+ let keys: Vec<&str> = params
+ .as_object()
+ .map(|m| m.keys().map(String::as_str).collect())
+ .unwrap_or_default();
w.trace.push(format!(
- "#{} {} {method} {params} -> {status} {short}",
+ "#{} {} {method} {keys:?} -> {status} {short}",
w.step, USERS[actor]
));
let stat = w.stats.entry(method.to_string()).or_default();
@@ -262,6 +267,10 @@ fn settle(llm: &mock_llm::MockLlm, quiet: Duration, max: Duration) {
return;
}
}
+ panic!(
+ "backend traffic never settled within {max:?} ({} requests recorded)",
+ llm.recorded().len()
+ );
}
fn verify_victims(w: &mut World) {