Files
MyAiConfiguration/shared/hooks/scripts/Validate-CommandSafety.ps1
T
Julian LechnerandClaude Opus 5.5 b35e2254b3 feat(extensions): add Roast Room, bring Codex to parity, fix audit findings
Roast Room is installed as a managed Git clone under
~/.my-ai-configuration/roast-room, shared by Claude and Codex. A personal
launcher skill runs it from any folder, starts its live room when needed,
and only runs when invoked by name (/roast-room, $roast-room).

Codex now gets what was Claude-only before: the Caveman skill with a
SessionStart hook that keeps it on, PreCompact and session-pointer hooks,
execpolicy deny rules mirroring Claude's permissions.deny, and Impeccable's
custom agents registered in ~/.codex/agents. The command-safety hook checks
both shell dialects for Codex on Windows, where PowerShell text arrives as
Bash, in both the PowerShell and Bash packages.

Audit fixes:
- command-safety blocks git checkout -- / restore / push --force /
  stash clear and find -delete, and treats heredoc bodies as text
- removing a clone clears read-only Git files, git errors no longer abort
  the extension sync, and a lock left by a dead process is replaced
- with-credential passes child flags such as -k or -d through unchanged
  and resolves commands from PATH
- uninstall strips only owned hooks from settings.json and config.toml and
  keeps the selection while another client is installed; update keeps
  CLAUDE_CODE_MAX_TOOL_USE_CONCURRENCY; Bash merges write the same bytes as
  PowerShell
- qmd no longer trusts a stale daemon.json after a lost start race and
  prunes collections of deleted repositories
- Bash scripts avoid GNU-only find -printf

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 09:02:47 +01:00

20 lines
1.2 KiB
PowerShell

# Without -Command this runs as a PreToolUse hook: it reads the event from stdin and exits 2 to block.
# With -Command it checks one command and also rejects absolute paths outside -Workspace.
# Pattern checks are a guard rail against accidents, not a security boundary.
# -Shell (bash, powershell, unknown) overrides the dialect taken from the hook's tool name.
param([string]$Command, [string]$Workspace = (Get-Location).Path, [ValidateSet('', 'bash', 'powershell', 'unknown')][string]$Shell = '')
. (Join-Path $PSScriptRoot 'Resolve-Python.ps1')
$python = Get-PythonCommand
$script = Join-Path $PSScriptRoot 'command-safety.py'
if ($PSBoundParameters.ContainsKey('Command')) {
if (-not $python) { Write-Error (Get-PythonMissingMessage); exit 1 }
# Pass the command on stdin: Windows PowerShell 5.1 does not escape embedded quotes in native arguments.
$Command | & $python.Path @($python.Arguments) $script --command - --workspace $Workspace
exit $LASTEXITCODE
}
# Registered hooks fail open without Python; doctor reports that case.
if (-not $python) { exit 0 }
$shellArguments = if ($Shell) { @('--shell', $Shell) } else { @() }
& $python.Path @($python.Arguments) $script --hook @shellArguments
exit $LASTEXITCODE