fix(ci): accept QMD sandbox exclusion and satisfy ruff E731
CI / CI configuration security checks (push) Successful in 3s
CI / Capabilities and shell quality (push) Successful in 13s
CI / Python tests and compilation (push) Successful in 26s
CI / QMD unit tests (push) Successful in 5s
CI / Build and inspect generated packages (push) Successful in 18s
CI / PowerShell tests on Ubuntu (push) Failing after 51s
CI / Installed client configuration smoke tests (push) Canceled after 54s
CI / Bash integration and installation guards (push) Canceled after 55s
CI / CI configuration security checks (push) Successful in 3s
CI / Capabilities and shell quality (push) Successful in 13s
CI / Python tests and compilation (push) Successful in 26s
CI / QMD unit tests (push) Successful in 5s
CI / Build and inspect generated packages (push) Successful in 18s
CI / PowerShell tests on Ubuntu (push) Failing after 51s
CI / Installed client configuration smoke tests (push) Canceled after 54s
CI / Bash integration and installation guards (push) Canceled after 55s
- validate-config: allow sandbox.excludedCommands only with the exact QMD search command, keeping the sandbox fail-closed - shell package tests: expect the excludedCommands entry - tests: replace assigned lambdas with functions (ruff E731) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
09e8e832ed
commit
49636323f0
5 files changed
+14
-6
No files matched your search
@@ -12,7 +12,9 @@ from pathlib import Path
|
|||||||
|
|
||||||
CLAUDE_TOP_LEVEL = {"permissions", "sandbox", "env", "statusLine", "hooks"}
|
CLAUDE_TOP_LEVEL = {"permissions", "sandbox", "env", "statusLine", "hooks"}
|
||||||
CLAUDE_PERMISSION_KEYS = {"defaultMode", "allow", "deny"}
|
CLAUDE_PERMISSION_KEYS = {"defaultMode", "allow", "deny"}
|
||||||
CLAUDE_SANDBOX_KEYS = {"enabled", "allowUnsandboxedCommands", "failIfUnavailable", "network"}
|
CLAUDE_SANDBOX_KEYS = {"enabled", "allowUnsandboxedCommands", "failIfUnavailable", "excludedCommands", "network"}
|
||||||
|
# The only command allowed outside the sandbox: QMD search needs its localhost daemon and home-directory index.
|
||||||
|
CLAUDE_SANDBOX_EXCLUDED = ['node "$HOME/.my-ai-configuration/qmd/qmd-search.mjs" *']
|
||||||
CLAUDE_STATUS_LINE_KEYS = {"type", "command"}
|
CLAUDE_STATUS_LINE_KEYS = {"type", "command"}
|
||||||
CLAUDE_HOOK_KEYS = {"type", "command", "timeout"}
|
CLAUDE_HOOK_KEYS = {"type", "command", "timeout"}
|
||||||
CLAUDE_PERMISSION_MODES = {"acceptEdits", "auto", "bypassPermissions", "default", "dontAsk", "plan"}
|
CLAUDE_PERMISSION_MODES = {"acceptEdits", "auto", "bypassPermissions", "default", "dontAsk", "plan"}
|
||||||
@@ -42,6 +44,7 @@ def validate_claude(path: Path) -> None:
|
|||||||
fail(f"permissions.{key} must be an array of strings")
|
fail(f"permissions.{key} must be an array of strings")
|
||||||
sandbox = require_keys(settings.get("sandbox"), CLAUDE_SANDBOX_KEYS, "sandbox")
|
sandbox = require_keys(settings.get("sandbox"), CLAUDE_SANDBOX_KEYS, "sandbox")
|
||||||
if sandbox != {"enabled": False} and sandbox != {"enabled": True, "allowUnsandboxedCommands": False, "failIfUnavailable": True,
|
if sandbox != {"enabled": False} and sandbox != {"enabled": True, "allowUnsandboxedCommands": False, "failIfUnavailable": True,
|
||||||
|
"excludedCommands": CLAUDE_SANDBOX_EXCLUDED,
|
||||||
"network": {"allowedDomains": ["mcp.context7.com"]}}:
|
"network": {"allowedDomains": ["mcp.context7.com"]}}:
|
||||||
fail("sandbox must be disabled or enabled with fail-closed settings")
|
fail("sandbox must be disabled or enabled with fail-closed settings")
|
||||||
env = settings.get("env")
|
env = settings.get("env")
|
||||||
|
|||||||
@@ -114,7 +114,8 @@ class InstallOptionsTests(unittest.TestCase):
|
|||||||
managed = managed.replace('__IMPECCABLE_HOOK_SCRIPT__', 'invoke-impeccable-hook.sh')
|
managed = managed.replace('__IMPECCABLE_HOOK_SCRIPT__', 'invoke-impeccable-hook.sh')
|
||||||
merged = OPTIONS.merge_toml(OPTIONS.merge_toml('', managed), managed)
|
merged = OPTIONS.merge_toml(OPTIONS.merge_toml('', managed), managed)
|
||||||
hooks = tomllib.loads(merged)['hooks']
|
hooks = tomllib.loads(merged)['hooks']
|
||||||
impeccable = lambda groups: [group for group in groups if 'impeccable-hook' in group['hooks'][0]['command']]
|
def impeccable(groups):
|
||||||
|
return [group for group in groups if 'impeccable-hook' in group['hooks'][0]['command']]
|
||||||
self.assertEqual(1, len(impeccable(hooks['PostToolUse'])))
|
self.assertEqual(1, len(impeccable(hooks['PostToolUse'])))
|
||||||
self.assertEqual('Edit|Write|apply_patch', impeccable(hooks['PostToolUse'])[0]['matcher'])
|
self.assertEqual('Edit|Write|apply_patch', impeccable(hooks['PostToolUse'])[0]['matcher'])
|
||||||
self.assertEqual(1, len(impeccable(hooks['Stop'])))
|
self.assertEqual(1, len(impeccable(hooks['Stop'])))
|
||||||
@@ -131,7 +132,8 @@ class InstallOptionsTests(unittest.TestCase):
|
|||||||
with self.subTest(shell=name), tempfile.TemporaryDirectory() as directory:
|
with self.subTest(shell=name), tempfile.TemporaryDirectory() as directory:
|
||||||
home = Path(directory)
|
home = Path(directory)
|
||||||
env = dict(os.environ, HOME=str(home), USERPROFILE=str(home), CODEX_HOME=str(home / '.codex'))
|
env = dict(os.environ, HOME=str(home), USERPROFILE=str(home), CODEX_HOME=str(home / '.codex'))
|
||||||
run = lambda: subprocess.run([executable, *arguments, str(scripts / name)], input='{"event":1}',
|
def run():
|
||||||
|
return subprocess.run([executable, *arguments, str(scripts / name)], input='{"event":1}',
|
||||||
env=env, capture_output=True, text=True, timeout=60)
|
env=env, capture_output=True, text=True, timeout=60)
|
||||||
result = run()
|
result = run()
|
||||||
self.assertEqual((0, ''), (result.returncode, result.stdout), result.stderr)
|
self.assertEqual((0, ''), (result.returncode, result.stdout), result.stderr)
|
||||||
|
|||||||
@@ -147,7 +147,10 @@ class SetupTest(unittest.TestCase):
|
|||||||
def test_update_deletes_only_owned_models_no_longer_used(self):
|
def test_update_deletes_only_owned_models_no_longer_used(self):
|
||||||
models = self.home / '.cache/qmd/models'
|
models = self.home / '.cache/qmd/models'
|
||||||
current = qmd.model_files((ROOT / 'shared/qmd/qmd-lib.mjs').read_text(encoding='utf-8'))
|
current = qmd.model_files((ROOT / 'shared/qmd/qmd-lib.mjs').read_text(encoding='utf-8'))
|
||||||
create = lambda arguments: [(models / n).write_text('x') for n in current] if arguments[-1:] == ['pull'] else None
|
def create(arguments):
|
||||||
|
if arguments[-1:] == ['pull']:
|
||||||
|
for name in current:
|
||||||
|
(models / name).write_text('x')
|
||||||
runner = FakeRunner(on_call=create)
|
runner = FakeRunner(on_call=create)
|
||||||
self.setup(runner).enable(['claude'])
|
self.setup(runner).enable(['claude'])
|
||||||
for name in ('hf_Qwen_Qwen3-Embedding-0.6B-Q8_0.gguf', 'foreign.gguf'):
|
for name in ('hf_Qwen_Qwen3-Embedding-0.6B-Q8_0.gguf', 'foreign.gguf'):
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ foreach ($shell in @('powershell','bash')) {
|
|||||||
throw "Claude auto permission mode is missing in $package"
|
throw "Claude auto permission mode is missing in $package"
|
||||||
} elseif ($settings.env.CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS -ne '5' -or $settings.env.CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH -ne '1') {
|
} elseif ($settings.env.CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS -ne '5' -or $settings.env.CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH -ne '1') {
|
||||||
throw "Claude subagent limits are missing in $package"
|
throw "Claude subagent limits are missing in $package"
|
||||||
} elseif ($sandboxSupported -and ($settings.sandbox.enabled -ne $true -or $settings.sandbox.allowUnsandboxedCommands -ne $false -or $settings.sandbox.failIfUnavailable -ne $true -or (@($settings.sandbox.network.allowedDomains) -join ',') -ne 'mcp.context7.com' -or @($settings.sandbox.PSObject.Properties).Count -ne 4)) {
|
} elseif ($sandboxSupported -and ($settings.sandbox.enabled -ne $true -or $settings.sandbox.allowUnsandboxedCommands -ne $false -or $settings.sandbox.failIfUnavailable -ne $true -or (@($settings.sandbox.network.allowedDomains) -join ',') -ne 'mcp.context7.com' -or (@($settings.sandbox.excludedCommands) -join ',') -ne 'node "$HOME/.my-ai-configuration/qmd/qmd-search.mjs" *' -or @($settings.sandbox.PSObject.Properties).Count -ne 5)) {
|
||||||
throw "Claude strict sandbox is missing in $package"
|
throw "Claude strict sandbox is missing in $package"
|
||||||
} elseif (-not $sandboxSupported -and ($settings.sandbox.enabled -ne $false -or @($settings.sandbox.PSObject.Properties).Count -ne 1)) {
|
} elseif (-not $sandboxSupported -and ($settings.sandbox.enabled -ne $false -or @($settings.sandbox.PSObject.Properties).Count -ne 1)) {
|
||||||
throw "Claude sandbox must be disabled in $package"
|
throw "Claude sandbox must be disabled in $package"
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ for shell in powershell bash; do
|
|||||||
grep -q '"defaultMode"[[:space:]]*:[[:space:]]*"auto"' "$package/$file"
|
grep -q '"defaultMode"[[:space:]]*:[[:space:]]*"auto"' "$package/$file"
|
||||||
grep -q '"CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS"[[:space:]]*:[[:space:]]*"5"' "$package/$file"
|
grep -q '"CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS"[[:space:]]*:[[:space:]]*"5"' "$package/$file"
|
||||||
grep -q '"CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH"[[:space:]]*:[[:space:]]*"1"' "$package/$file"
|
grep -q '"CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH"[[:space:]]*:[[:space:]]*"1"' "$package/$file"
|
||||||
python3 -c 'import json,sys; settings=json.load(open(sys.argv[1], encoding="utf-8-sig")); expected={"enabled": True, "allowUnsandboxedCommands": False, "failIfUnavailable": True, "network": {"allowedDomains": ["mcp.context7.com"]}} if sys.argv[2] == "true" else {"enabled": False}; assert settings["sandbox"] == expected' "$package/$file" "$sandbox_supported"
|
python3 -c 'import json,sys; settings=json.load(open(sys.argv[1], encoding="utf-8-sig")); expected={"enabled": True, "allowUnsandboxedCommands": False, "failIfUnavailable": True, "excludedCommands": ["node \"$HOME/.my-ai-configuration/qmd/qmd-search.mjs\" *"], "network": {"allowedDomains": ["mcp.context7.com"]}} if sys.argv[2] == "true" else {"enabled": False}; assert settings["sandbox"] == expected' "$package/$file" "$sandbox_supported"
|
||||||
statusline_extension='sh'
|
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"
|
||||||
|
|||||||
Reference in new issue
Block a user