Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions scripts/hooks/gateguard-fact-force.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ function isDestructiveBash(command) {
const stripped = stripQuotedStrings(segment);
if (DESTRUCTIVE_SQL_DD.test(stripped)) return true;
if (extra && extra.test(stripped)) return true;
if (isDestructiveFindExec(segment)) return true;
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
const tokens = tokenize(segment);
if (isDestructiveRm(tokens)) return true;
if (isDestructiveGit(tokens)) return true;
Expand Down
15 changes: 15 additions & 0 deletions tests/hooks/gateguard-fact-force.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1613,6 +1613,21 @@ function runTests() {
'find -exec git reset --hard');
})) passed++; else failed++;

if (test('denies find -exec rm {} \\; preceded by && (bypass via compound command)', () => {
expectDestructiveDeny('echo x && find . -exec rm {} \\;',
'compound command bypass: find -exec rm');
})) passed++; else failed++;

if (test('denies find -exec rm -rf {} \\; preceded by ; (bypass via semicolon)', () => {
expectDestructiveDeny('true; find . -name "*.log" -exec rm -rf {} \\;',
'semicolon bypass: find -exec rm -rf');
})) passed++; else failed++;

if (test('denies find -exec rm {} \\; in pipeline (bypass via pipe)', () => {
expectDestructiveDeny('echo start | find . -exec rm {} \\;',
'pipe bypass: find -exec rm');
})) passed++; else failed++;

if (test('allows find -exec echo {} \\; (non-destructive, routine gate)', () => {
clearState();
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
const input = { tool_name: 'Bash', tool_input: { command: 'find . -name "*.tmp" -exec echo {} \\;' } };
Expand Down