test(config): enforce sandbox defaults
This commit is contained in:
1 parent
fb926e9877
commit
fe9ca9552f
2 files changed
+7
-2
No files matched your search
@@ -41,11 +41,14 @@ foreach ($shell in @('powershell','bash')) {
|
|||||||
$events = @([regex]::Matches($content, '(?m)^\[\[hooks\.([^.\]]+)\]\]\s*$') | ForEach-Object { $_.Groups[1].Value })
|
$events = @([regex]::Matches($content, '(?m)^\[\[hooks\.([^.\]]+)\]\]\s*$') | ForEach-Object { $_.Groups[1].Value })
|
||||||
if ($events.Count -ne 1 -or $events[0] -ne 'Stop' -or $content -match 'flashbang-if-input' -or $content -match '(?m)^async\s*=\s*true\s*$') { throw "Codex finish hook is incorrect in $package" }
|
if ($events.Count -ne 1 -or $events[0] -ne 'Stop' -or $content -match 'flashbang-if-input' -or $content -match '(?m)^async\s*=\s*true\s*$') { throw "Codex finish hook is incorrect in $package" }
|
||||||
if ($content -notmatch 'approvals_reviewer\s*=\s*"auto_review"') { throw "Codex auto review is missing in $package" }
|
if ($content -notmatch 'approvals_reviewer\s*=\s*"auto_review"') { throw "Codex auto review is missing in $package" }
|
||||||
|
if ($content -notmatch '(?m)^max_depth\s*=\s*1\s*$') { throw "Codex agent depth limit is missing in $package" }
|
||||||
if ($content -notmatch 'status_line\s*=\s*\["model", "reasoning", "approval-mode", "project-name", "git-branch", "context-window-size", "context-used", "used-tokens"\]') { throw "Codex status line is incorrect in $package" }
|
if ($content -notmatch 'status_line\s*=\s*\["model", "reasoning", "approval-mode", "project-name", "git-branch", "context-window-size", "context-used", "used-tokens"\]') { throw "Codex status line is incorrect in $package" }
|
||||||
} elseif ((($settings.hooks.PSObject.Properties.Name | Sort-Object) -join ',') -ne 'PreCompact,SessionStart,Stop' -or $content -match 'flashbang-if-input' -or $settings.hooks.Stop[0].hooks[0].async) {
|
} elseif ((($settings.hooks.PSObject.Properties.Name | Sort-Object) -join ',') -ne 'PreCompact,SessionStart,Stop' -or $content -match 'flashbang-if-input' -or $settings.hooks.Stop[0].hooks[0].async) {
|
||||||
throw "Claude finish hook is incorrect in $package"
|
throw "Claude finish hook is incorrect in $package"
|
||||||
} elseif ($content -notmatch '"defaultMode"\s*:\s*"auto"') {
|
} elseif ($content -notmatch '"defaultMode"\s*:\s*"auto"') {
|
||||||
throw "Claude auto permission mode is missing in $package"
|
throw "Claude auto permission mode is missing in $package"
|
||||||
|
} elseif (-not $settings.sandbox.enabled -or $settings.sandbox.allowUnsandboxedCommands -ne $false) {
|
||||||
|
throw "Claude strict sandbox is missing in $package"
|
||||||
} elseif (-not (Test-Path -LiteralPath (Join-Path $package "statusline/statusline.$(if ($shell -eq 'powershell') { 'ps1' } else { 'sh' })")) -or $settings.statusLine.command -notmatch "statusline\.$(if ($shell -eq 'powershell') { 'ps1' } else { 'sh' })") {
|
} elseif (-not (Test-Path -LiteralPath (Join-Path $package "statusline/statusline.$(if ($shell -eq 'powershell') { 'ps1' } else { 'sh' })")) -or $settings.statusLine.command -notmatch "statusline\.$(if ($shell -eq 'powershell') { 'ps1' } else { 'sh' })") {
|
||||||
throw "Claude status line is incorrect in $package"
|
throw "Claude status line is incorrect in $package"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ for shell in powershell bash; do
|
|||||||
[ "$client" != claude ] || file=settings.json
|
[ "$client" != claude ] || file=settings.json
|
||||||
test -f "$package/$file"
|
test -f "$package/$file"
|
||||||
if [ "$client" = codex ]; then
|
if [ "$client" = codex ]; then
|
||||||
while IFS=$'\t' read -r rule_file skill_name trigger; do
|
while IFS=$'\t' read -r rule_file _ trigger; do
|
||||||
[ "$rule_file" = rule_file ] && continue
|
[ "$rule_file" = rule_file ] && continue
|
||||||
[ -n "$rule_file" ] || continue
|
[ -n "$rule_file" ] || continue
|
||||||
rule_path=$rule_file
|
rule_path=$rule_file
|
||||||
@@ -56,13 +56,15 @@ for shell in powershell bash; do
|
|||||||
! grep -q 'flashbang-if-input' "$package/$file"
|
! grep -q 'flashbang-if-input' "$package/$file"
|
||||||
! grep -Eq '^async[[:space:]]*=[[:space:]]*true[[:space:]]*$' "$package/$file"
|
! grep -Eq '^async[[:space:]]*=[[:space:]]*true[[:space:]]*$' "$package/$file"
|
||||||
grep -q 'approvals_reviewer[[:space:]]*=[[:space:]]*"auto_review"' "$package/$file"
|
grep -q 'approvals_reviewer[[:space:]]*=[[:space:]]*"auto_review"' "$package/$file"
|
||||||
|
grep -Eq '^max_depth[[:space:]]*=[[:space:]]*1[[:space:]]*$' "$package/$file"
|
||||||
grep -Fq 'status_line = ["model", "reasoning", "approval-mode", "project-name", "git-branch", "context-window-size", "context-used", "used-tokens"]' "$package/$file"
|
grep -Fq 'status_line = ["model", "reasoning", "approval-mode", "project-name", "git-branch", "context-window-size", "context-used", "used-tokens"]' "$package/$file"
|
||||||
else
|
else
|
||||||
python3 -c 'import json,sys; settings=json.load(open(sys.argv[1], encoding="utf-8-sig")); assert set(settings["hooks"]) == {"PreCompact", "SessionStart", "Stop"}' "$package/$file"
|
python3 -c 'import json,sys; settings=json.load(open(sys.argv[1], encoding="utf-8-sig")); assert set(settings["hooks"]) == {"PreCompact", "SessionStart", "Stop"}' "$package/$file"
|
||||||
! grep -q 'flashbang-if-input' "$package/$file"
|
! grep -q 'flashbang-if-input' "$package/$file"
|
||||||
! grep -q '"async"[[:space:]]*:[[:space:]]*true' "$package/$file"
|
! grep -q '"async"[[:space:]]*:[[:space:]]*true' "$package/$file"
|
||||||
grep -q '"defaultMode"[[:space:]]*:[[:space:]]*"auto"' "$package/$file"
|
grep -q '"defaultMode"[[:space:]]*:[[:space:]]*"auto"' "$package/$file"
|
||||||
statusline_extension=sh
|
python3 -c 'import json,sys; settings=json.load(open(sys.argv[1], encoding="utf-8-sig")); assert settings["sandbox"] == {"enabled": True, "allowUnsandboxedCommands": False}' "$package/$file"
|
||||||
|
statusline_extension='sh'
|
||||||
[ "$shell" != powershell ] || statusline_extension=ps1
|
[ "$shell" != powershell ] || statusline_extension=ps1
|
||||||
test -f "$package/statusline/statusline.$statusline_extension"
|
test -f "$package/statusline/statusline.$statusline_extension"
|
||||||
grep -q "statusline.$statusline_extension" "$package/$file"
|
grep -q "statusline.$statusline_extension" "$package/$file"
|
||||||
|
|||||||
Reference in new issue
Block a user