Closes #150 (hash attestation): adds an opt-in second layer of defense for plan injection. After v2.36.1 wrapped task_plan.md content in BEGIN/END delimiters, the model still parsed the bytes. v2.37.0 adds /plan-attest, a slash command that locks the current task_plan.md content with a SHA-256 stored at .planning/<active-plan>/.attestation (parallel-plan mode) or ./.plan-attestation (legacy mode). UserPromptSubmit and PreToolUse hooks recompute the hash on every fire and emit "[PLAN TAMPERED — injection blocked]" instead of plan content on mismatch. When attestation is set, the injected context also carries a Plan-SHA256: line for audit. New helper: scripts/attest-plan.sh and .ps1 with --show / --clear modes, propagated to all six IDE mirrors that ship scripts. Closes #151 (parity-locked version bumper): names the regression class behind v2.34.1, v2.36.0, v2.36.2, v2.36.3 (one of N parity-locked files forgotten on bump). Fixes it surgically without overshooting into "regenerate all SKILL.md from canonical" (per-IDE frontmatter and per- language prose are intentionally divergent). New scripts/bump-version.py atomically bumps the parity set in one shot. New tests/test_skill_md_version_parity.py fails the build the moment any parity-locked file diverges from the canonical version. .continue, .gemini, .pi, .kiro stay on their separate schemes and are surfaced in every bump-version run so the omission is explicit. Other changes: - tests/test_canonical_script_sync.py: removed leftover duplicate CanonicalScriptSyncTests class block (lines 99 to 137); SHARED_SCRIPTS extended to ten entries for attest-plan.{sh,ps1}. - scripts/sync-ide-folders.py: SCRIPTS manifest extended to cover attest-plan helpers; existing eight scripts unchanged. - canonical SKILL.md Security Boundary section: documents the two layers of defense and the /plan-attest workflow. - 14 SKILL.md variants + plugin.json + marketplace.json + CITATION.cff bumped to 2.37.0 via scripts/bump-version.py (.continue / .gemini / .pi / .kiro left on their own schemes per release scope rule). Tests: 78 pass, 2 pre-existing Windows exec-bit failures unchanged.
119 lines
3.9 KiB
PowerShell
119 lines
3.9 KiB
PowerShell
#requires -Version 5.0
|
|
<#
|
|
.SYNOPSIS
|
|
Lock the current task_plan.md content with a SHA-256 attestation.
|
|
|
|
.DESCRIPTION
|
|
Use after you finalise (or intentionally edit) a plan. The hooks then refuse
|
|
to inject plan content into the model context if the file diverges from the
|
|
attested hash, surfacing a "[PLAN TAMPERED]" warning instead.
|
|
|
|
Plan resolution:
|
|
1. $env:PLAN_ID -> ./.planning/$PLAN_ID/
|
|
2. ./.planning/.active_plan
|
|
3. Newest ./.planning/<dir>/ by LastWriteTime
|
|
4. Legacy ./task_plan.md at project root
|
|
|
|
.PARAMETER Show
|
|
Print the stored hash for the active plan.
|
|
|
|
.PARAMETER Clear
|
|
Remove the attestation (re-open the plan).
|
|
#>
|
|
[CmdletBinding(DefaultParameterSetName = "Attest")]
|
|
param(
|
|
[Parameter(ParameterSetName = "Show")]
|
|
[switch] $Show,
|
|
|
|
[Parameter(ParameterSetName = "Clear")]
|
|
[switch] $Clear
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
function Resolve-PlanFile {
|
|
$planRoot = Join-Path (Get-Location) ".planning"
|
|
|
|
if ($env:PLAN_ID) {
|
|
$candidate = Join-Path $planRoot $env:PLAN_ID
|
|
$planFile = Join-Path $candidate "task_plan.md"
|
|
if (Test-Path -LiteralPath $planFile) { return (Resolve-Path -LiteralPath $planFile).Path }
|
|
}
|
|
|
|
$activePointer = Join-Path $planRoot ".active_plan"
|
|
if (Test-Path -LiteralPath $activePointer) {
|
|
$planId = (Get-Content -LiteralPath $activePointer -Raw).Trim()
|
|
if ($planId) {
|
|
$candidate = Join-Path $planRoot $planId
|
|
$planFile = Join-Path $candidate "task_plan.md"
|
|
if (Test-Path -LiteralPath $planFile) { return (Resolve-Path -LiteralPath $planFile).Path }
|
|
}
|
|
}
|
|
|
|
if (Test-Path -LiteralPath $planRoot) {
|
|
$newest = Get-ChildItem -LiteralPath $planRoot -Directory -ErrorAction SilentlyContinue |
|
|
Where-Object { -not $_.Name.StartsWith(".") } |
|
|
Where-Object { Test-Path -LiteralPath (Join-Path $_.FullName "task_plan.md") } |
|
|
Sort-Object LastWriteTime -Descending |
|
|
Select-Object -First 1
|
|
if ($newest) {
|
|
return (Resolve-Path -LiteralPath (Join-Path $newest.FullName "task_plan.md")).Path
|
|
}
|
|
}
|
|
|
|
$legacy = Join-Path (Get-Location) "task_plan.md"
|
|
if (Test-Path -LiteralPath $legacy) {
|
|
return (Resolve-Path -LiteralPath $legacy).Path
|
|
}
|
|
|
|
return $null
|
|
}
|
|
|
|
function Get-AttestationPath {
|
|
param([string] $PlanFile)
|
|
$planDir = Split-Path -Parent $PlanFile
|
|
$cwd = (Get-Location).Path
|
|
if ($planDir -eq $cwd) {
|
|
return (Join-Path $cwd ".plan-attestation")
|
|
}
|
|
return (Join-Path $planDir ".attestation")
|
|
}
|
|
|
|
$planFile = Resolve-PlanFile
|
|
if (-not $planFile) {
|
|
Write-Error "[plan-attest] No task_plan.md found. Create a plan first."
|
|
exit 1
|
|
}
|
|
|
|
$attestationFile = Get-AttestationPath -PlanFile $planFile
|
|
|
|
if ($Show) {
|
|
if (Test-Path -LiteralPath $attestationFile) {
|
|
Write-Output "Plan: $planFile"
|
|
Write-Output "Attestation: $attestationFile"
|
|
Write-Output ("SHA-256: " + (Get-Content -LiteralPath $attestationFile -Raw).Trim())
|
|
} else {
|
|
Write-Output "[plan-attest] No attestation set for $planFile."
|
|
exit 1
|
|
}
|
|
exit 0
|
|
}
|
|
|
|
if ($Clear) {
|
|
if (Test-Path -LiteralPath $attestationFile) {
|
|
Remove-Item -LiteralPath $attestationFile -Force
|
|
Write-Output "[plan-attest] Cleared attestation for $planFile."
|
|
} else {
|
|
Write-Output "[plan-attest] No attestation to clear."
|
|
}
|
|
exit 0
|
|
}
|
|
|
|
$hashVal = (Get-FileHash -LiteralPath $planFile -Algorithm SHA256).Hash.ToLowerInvariant()
|
|
Set-Content -LiteralPath $attestationFile -Value $hashVal -NoNewline -Encoding ascii
|
|
$short = $hashVal.Substring(0, 12)
|
|
Write-Output "[plan-attest] Locked $planFile"
|
|
Write-Output "[plan-attest] SHA-256: $short... (stored in $attestationFile)"
|
|
Write-Output "[plan-attest] Hooks will block injection if the file is modified without re-running this command."
|
|
exit 0
|