Skip to content

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

test: cover protected command literals with autonomy off

Steven Enamakelfa4b056c0b02
diff --git a/crates/openhuman-core/src/security/policy/policy_disabled_tests.rs b/crates/openhuman-core/src/security/policy/policy_disabled_tests.rs
index 9fe671f180..8f6fd89c72 100644
--- a/crates/openhuman-core/src/security/policy/policy_disabled_tests.rs
+++ b/crates/openhuman-core/src/security/policy/policy_disabled_tests.rs
@@ -52,6 +52,34 @@ fn disabled_policy_runs_ordinary_shell_syntax() {
}
}
+#[test]
+fn disabled_policy_blocks_literal_credential_paths_in_commands() {
+ let policy = disabled_policy();
+ for command in [
+ "cat ~/.ssh/id_rsa",
+ "cat $HOME/.aws/credentials",
+ "cat ${HOME}/.gnupg/private-keys-v1.d/key",
+ "cat %USERPROFILE%/.git-credentials",
+ "node -e 'require(\"fs\").readFileSync(\"~/.netrc\")'",
+ ] {
+ assert!(
+ policy.check_gated_command(command).is_err(),
+ "protected literal should be refused: {command}"
+ );
+ }
+}
+
+#[test]
+fn disabled_policy_allows_unrelated_literal_paths_in_commands() {
+ let policy = disabled_policy();
+ for command in ["cat ./notes.txt", "echo ~/.config/app/theme.json"] {
+ assert!(
+ policy.check_gated_command(command).is_ok(),
+ "ordinary literal should remain allowed: {command}"
+ );
+ }
+}
+
#[test]
fn disabled_policy_never_prompts_or_blocks_on_class() {
let policy = disabled_policy();