corrections
CI / CI configuration security checks (push) Successful in 6s
CI / Python tests and compilation (push) Failing after 12s
CI / QMD unit tests (push) Skipped
CI / Capabilities and shell quality (push) Successful in 1m50s
CI / Build and inspect generated packages (push) Skipped
CI / Bash integration and installation guards (push) Skipped
CI / Installed client configuration smoke tests (push) Skipped
CI / PowerShell tests on Ubuntu (push) Failing after 7m24s
CI / CI configuration security checks (push) Successful in 6s
CI / Python tests and compilation (push) Failing after 12s
CI / QMD unit tests (push) Skipped
CI / Capabilities and shell quality (push) Successful in 1m50s
CI / Build and inspect generated packages (push) Skipped
CI / Bash integration and installation guards (push) Skipped
CI / Installed client configuration smoke tests (push) Skipped
CI / PowerShell tests on Ubuntu (push) Failing after 7m24s
This commit is contained in:
1 parent
b35e2254b3
commit
c3e22eb902
39 files changed
+246
-151
No files matched your search
@@ -113,6 +113,26 @@ class HookTests(unittest.TestCase):
|
||||
self.assertBlocked('rm -r build', 'shell')
|
||||
self.assertBlocked('rm -rf build', 'shell')
|
||||
|
||||
def test_allowed_shell_search_gets_the_search_reminder_in_the_same_process(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
home = Path(directory)
|
||||
(home / '.my-ai-configuration/qmd').mkdir(parents=True)
|
||||
(home / '.my-ai-configuration/qmd/qmd-search.mjs').write_text('')
|
||||
env = dict(os.environ, HOME=str(home), USERPROFILE=str(home))
|
||||
|
||||
def run(command, session='s1'):
|
||||
payload = json.dumps({'session_id': session, 'tool_name': 'Bash', 'tool_input': {'command': command}})
|
||||
return subprocess.run([sys.executable, str(SAFETY), '--hook'], input=payload, capture_output=True,
|
||||
encoding='utf-8', timeout=20, env=env)
|
||||
|
||||
result = run('rg Tile')
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
self.assertIn('additionalContext', result.stdout)
|
||||
self.assertEqual('', run('git status', 's2').stdout)
|
||||
blocked = run('rm -rf build && rg x', 's3')
|
||||
self.assertEqual(blocked.returncode, 2)
|
||||
self.assertEqual('', blocked.stdout)
|
||||
|
||||
def test_fails_open_on_unusable_input(self):
|
||||
for payload in ('', 'not json', '[]', '{"tool_input": "rm -rf /"}', '{"tool_input": {"command": 5}}'):
|
||||
with self.subTest(payload=payload):
|
||||
|
||||
Reference in new issue
Block a user