mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-06-23 08:31:26 +08:00
fix: cover remaining gateguard tokenizer bypasses
This commit is contained in:
@@ -1188,6 +1188,10 @@ function runTests() {
|
||||
expectDestructiveDeny('rm -r -f /tmp/junk', 'rm -r -f');
|
||||
})) passed++; else failed++;
|
||||
|
||||
if (test('denies rm --recursive --force (long flag form)', () => {
|
||||
expectDestructiveDeny('rm --recursive --force /tmp/junk', 'rm --recursive --force');
|
||||
})) passed++; else failed++;
|
||||
|
||||
if (test('denies git reset HEAD --hard (with intervening ref)', () => {
|
||||
expectDestructiveDeny('git reset HEAD --hard', 'git reset HEAD --hard');
|
||||
})) passed++; else failed++;
|
||||
@@ -1200,6 +1204,14 @@ function runTests() {
|
||||
expectDestructiveDeny('echo y | rm -rf /tmp/junk', 'echo y | rm -rf');
|
||||
})) passed++; else failed++;
|
||||
|
||||
if (test('denies destructive command inside command substitution', () => {
|
||||
expectDestructiveDeny('echo $(rm -rf /tmp/junk)', 'rm -rf inside $()');
|
||||
})) passed++; else failed++;
|
||||
|
||||
if (test('denies destructive command inside backticks', () => {
|
||||
expectDestructiveDeny('echo `git push -f origin main`', 'git push -f inside backticks');
|
||||
})) passed++; else failed++;
|
||||
|
||||
if (test('allows destructive phrase quoted inside a commit message', () => {
|
||||
expectAllow('git commit -m "fix: rm -rf race in worker"', 'rm -rf in -m');
|
||||
})) passed++; else failed++;
|
||||
@@ -1220,6 +1232,11 @@ function runTests() {
|
||||
'git push --force --force-if-includes');
|
||||
})) passed++; else failed++;
|
||||
|
||||
if (test('denies git push when bare --force is mixed with lease flags', () => {
|
||||
expectDestructiveDeny('git push --force-with-lease --force origin main',
|
||||
'git push --force-with-lease --force');
|
||||
})) passed++; else failed++;
|
||||
|
||||
if (test('denies git push with +refspec prefix (bare branch)', () => {
|
||||
expectDestructiveDeny('git push origin +main', 'git push origin +main');
|
||||
})) passed++; else failed++;
|
||||
@@ -1260,6 +1277,11 @@ function runTests() {
|
||||
'dollar-paren subshell');
|
||||
})) passed++; else failed++;
|
||||
|
||||
if (test('denies rm -rf inside double-quoted command substitution', () => {
|
||||
expectDestructiveDeny('echo "$(rm -rf /tmp/junk)"',
|
||||
'double-quoted dollar-paren subshell');
|
||||
})) passed++; else failed++;
|
||||
|
||||
// Cleanup only the temp directory created by this test file.
|
||||
try {
|
||||
if (fs.existsSync(stateDir)) {
|
||||
|
||||
Reference in New Issue
Block a user