feat(psf): complete high-integrity loop for advanced features
This commit is contained in:
33
projects/org-skill-safety-harness/tests/simulate_harness.py
Normal file
33
projects/org-skill-safety-harness/tests/simulate_harness.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import re
|
||||
|
||||
def simulate_harness_walk(form, whitelist):
|
||||
if isinstance(form, str):
|
||||
return True
|
||||
if isinstance(form, list):
|
||||
fn = form[0]
|
||||
if fn not in whitelist:
|
||||
return False
|
||||
return all(simulate_harness_walk(arg, whitelist) for arg in form[1:])
|
||||
return True
|
||||
|
||||
if __name__ == "__main__":
|
||||
whitelist = ["message", "insert", "plist-get", "list", "quote"]
|
||||
|
||||
print("--- Test 1: Safe Call ---")
|
||||
safe_form = ["message", "Hello World"]
|
||||
res1 = simulate_harness_walk(safe_form, whitelist)
|
||||
print(f"Result: {res1}")
|
||||
|
||||
print("\n--- Test 2: Unsafe Call (Direct) ---")
|
||||
unsafe_form = ["shell-command", "rm -rf /"]
|
||||
res2 = simulate_harness_walk(unsafe_form, whitelist)
|
||||
print(f"Result: {res2}")
|
||||
|
||||
print("\n--- Test 3: Nested Malicious Call ---")
|
||||
# (message (shell-command "evil"))
|
||||
nested_form = ["message", ["shell-command", "evil"]]
|
||||
res3 = simulate_harness_walk(nested_form, whitelist)
|
||||
print(f"Result: {res3}")
|
||||
|
||||
status = "PASS" if res1 and not res2 and not res3 else "FAIL"
|
||||
print(f"\nFinal Status: {status}")
|
||||
Reference in New Issue
Block a user