scar-cli 0.29.1__tar.gz → 0.30.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- scar_cli-0.30.0/.release-please-manifest.json +3 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/CHANGELOG.md +12 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/PKG-INFO +1 -1
- {scar_cli-0.29.1 → scar_cli-0.30.0}/plugin/plugin.json +1 -1
- {scar_cli-0.29.1 → scar_cli-0.30.0}/plugin/skills/scar-authoring/SKILL.md +10 -4
- {scar_cli-0.29.1 → scar_cli-0.30.0}/pyproject.toml +1 -1
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/lint.py +52 -16
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/mcp.py +2 -2
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/presence.py +29 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/record.py +11 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/skills/scar-authoring/SKILL.md +10 -4
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/presence_fakes.py +13 -1
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_lint.py +91 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_lint_downgrade.py +102 -6
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_mcp.py +8 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_presence.py +20 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_promote_batch.py +8 -5
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_record.py +29 -1
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_skill.py +17 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_verify.py +20 -7
- {scar_cli-0.29.1 → scar_cli-0.30.0}/uv.lock +1 -1
- scar_cli-0.29.1/.release-please-manifest.json +0 -3
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.claude-plugin/marketplace.json +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.github/workflows/ci.yml +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.github/workflows/docs.yml +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.github/workflows/pr-validation.yml +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.github/workflows/release.yml +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.github/workflows/scar-review-queue.yml +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.gitignore +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.pre-commit-config.yaml +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.pre-commit-hooks.yaml +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0001-git-grep-ere-pitfalls.landmine.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0002-agent-direct-hook-install.deadend.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0003-installer-binds-to-active-venv-scar.landmine.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0004-promote-roundtrip-drops-expires-evidence.landmine.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0005-history-rewrite-orphans-commit-evidence.landmine.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0006-yaml-pattern-anchor-over-escaping.landmine.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0007-release-please-config-change-skips-open-pr.landmine.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0008-rich-output-nontty-must-bypass-rich.landmine.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0009-anchor-survival-harness-measures-symbol-not-path-anchors.deadend.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0010-git-returncode-128-vs-empty-tracked-set.landmine.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0011-lint-compile-check-lets-redos-anchors-hang-hotpath.landmine.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0012-firing-log-readers-need-blanket-guards.landmine.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0013-docusaurus-future-v4-requires-faster-dep.landmine.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0014-inject-flag-dest-collides-with-subcommand-dispatch.landmine.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0015-zero-checkruns-means-approval-gate-not-workflow-bug.deadend.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0016-hook-ownership-must-be-kind-scoped.landmine.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0017-codex-pretool-context-can-replay-apply-patch.landmine.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0018-cli-subparsers-register-through-_add-wrapper.landmine.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0019-token-in-scar-body-cannot-prove-hook-delivery.deadend.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0020-one-directional-health-check-leaves-flattering-direction-unwatched.landmine.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0021-posttool-fix-in-hooks-does-not-reach-codex-or-cascade.landmine.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0022-codex-hook-delivery-needs-user-file-and-trust.landmine.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0023-cascade-block-exit-collides-with-argparse.fence.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0024-host-detection-must-not-read-the-process-home.deadend.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0025-one-plugin-hook-manifest-two-hosts-two-root-variables.landmine.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0026-path-anchor-breadth-drives-the-review-due-threshold.landmine.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0027-slug-and-display-cleaning-are-different-jobs.landmine.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0028-violation-evidence-must-not-persist-raw-edits.fence.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0029-compliance-pools-by-repo-and-id.landmine.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/0030-presence-signer-input-canonical-subset.landmine.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/README.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/candidates/.gitkeep +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/.scars/template.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/AGENTS.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/CONTRIBUTING.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/IDEA.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/LICENSE +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/README.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/ROADMAP.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/SCAR-FORMAT.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/SPEC.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/STRESS-TEST.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/action.yml +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/codecov.yml +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/experiments/anchor-survival/PROTOCOL.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/experiments/anchor-survival/RESULTS.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/experiments/anchor-survival/long_replay.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/experiments/anchor-survival/replay.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/experiments/anchor-survival/replay_shipped.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/experiments/anchor-survival/test_replay_shipped.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/experiments/auto-authorship/FINDINGS.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/experiments/auto-authorship/PROTOCOL.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/experiments/fence-honor/.gitignore +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/experiments/fence-honor/PROTOCOL.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/experiments/fence-honor/RESULTS.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/experiments/fence-honor/fixture/.scars/0001-vendor-retry-window.fence.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/experiments/fence-honor/fixture/.scars/0002-evicting-session-store.deadend.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/experiments/fence-honor/fixture/.scars/0003-export-column-order.landmine.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/experiments/fence-honor/fixture/README.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/experiments/fence-honor/fixture/payments/retry.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/experiments/fence-honor/fixture/reports/export.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/experiments/fence-honor/fixture/services/sessions.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/experiments/fence-honor/grade.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/experiments/harvest/PROTOCOL.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/experiments/harvest/harvest.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/hook/scar-hooks.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/plugin/hooks/run.sh +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/plugin/skills/scar-authoring/assets/template.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/release-please-config.json +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/__init__.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/agent.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/cascade.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/cli.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/clock.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/codex.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/config.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/draftcheck.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/evidence.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/firing_log.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/gc.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/harvest.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/hooks.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/hosts.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/installer.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/match.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/model.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/orphan.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/output.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/reanchor.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/renames.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/render.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/review.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/signedpromote.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/skills/scar-authoring/assets/template.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/store.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/symbols.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/verify.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/src/scar/violation_evidence.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/conformance_fetch.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/conformance_support.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/conftest.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/fixtures/conformance/promote.json +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/fixtures/conformance/regenerate.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_action_yml.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_anchor_kind.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_block_capability.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_cascade.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_cli.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_clock.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_codex.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_compliance_stats.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_conformance_round_trip.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_context_size.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_docs.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_draftcheck.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_evidence.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_firing_log.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_gc.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_git_hook.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_harvest.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_hooks.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_hosts.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_installer.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_json_contract.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_lifecycle.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_match.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_matched_by.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_model.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_orphan.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_output.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_plugin.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_precommit_hooks.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_presence_adapters.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_presence_signer.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_promote_signed.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_reanchor.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_renames.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_render.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_review.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_review_queue.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_store.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_sweep.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_symbols.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_verdict_observability.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/tests/test_violation_evidence.py +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/website/.gitignore +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/website/docs/agents.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/website/docs/concepts.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/website/docs/index.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/website/docs/methodology.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/website/docs/quickstart.md +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/website/docusaurus.config.ts +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/website/package-lock.json +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/website/package.json +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/website/scripts/sync-changelog.mjs +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/website/sidebars.ts +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/website/src/css/custom.css +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/website/static/img/favicon.svg +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/website/static/img/social-card.png +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/website/static/llms.txt +0 -0
- {scar_cli-0.29.1 → scar_cli-0.30.0}/website/tsconfig.json +0 -0
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.30.0](https://github.com/Daily-Nerd/Scar/compare/v0.29.1...v0.30.0) (2026-11-20)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **lint:** report a promotion act that no longer matches its record ([#410](https://github.com/Daily-Nerd/Scar/issues/410)) ([d8dc89a](https://github.com/Daily-Nerd/Scar/commit/d8dc89a55de3c0a066f11f88f2d791976c893c93)), closes [#409](https://github.com/Daily-Nerd/Scar/issues/409)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **lint:** say only what the over-escape check proves and offer both respellings ([#408](https://github.com/Daily-Nerd/Scar/issues/408)) ([3d01d66](https://github.com/Daily-Nerd/Scar/commit/3d01d66d353232699ed50aacf98897872ad5472c)), closes [#407](https://github.com/Daily-Nerd/Scar/issues/407)
|
|
14
|
+
|
|
3
15
|
## [0.29.1](https://github.com/Daily-Nerd/Scar/compare/v0.29.0...v0.29.1) (2026-11-19)
|
|
4
16
|
|
|
5
17
|
|
|
@@ -92,9 +92,14 @@ must use a `pattern:` regex, know that the value reaches the matcher
|
|
|
92
92
|
**verbatim** — this reader is not a YAML parser and nothing un-escapes. Write
|
|
93
93
|
the regex exactly as it must execute: `\b` stays `\b`, `\(` stays `\(`.
|
|
94
94
|
Doubling backslashes "for YAML" yields a literal backslash and a dead anchor.
|
|
95
|
-
`scar lint` rejects it as an error
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
`scar lint` rejects it as an error. The value matches a literal backslash
|
|
96
|
+
followed by the next character, which lint cannot tell from a slip, so the
|
|
97
|
+
message prints two respellings. The halved form (`\\w` becomes `\w`) is for
|
|
98
|
+
when you meant the escape. The class form, with each doubled pair written as
|
|
99
|
+
`[\\]`, is for when the target text really holds a backslash, such as regex
|
|
100
|
+
source inside a raw string. To guard `r"[\w-]*(?:api|key)"` write
|
|
101
|
+
`\[[\\]w-\]\*\(\?:api`, not `\[\w-\]\*\(\?:api`, which does not match it.
|
|
102
|
+
Lint accepts the class form.
|
|
98
103
|
|
|
99
104
|
The pattern is also matched against all tracked content **including the scar's
|
|
100
105
|
own body**, so a broken pattern keeps itself alive by self-reference. Run
|
|
@@ -132,7 +137,8 @@ the fired→violated compliance metric).
|
|
|
132
137
|
un-escapes. Write it exactly as it must execute — `\b` stays `\b`, `\(`
|
|
133
138
|
stays `\(`. Doubling backslashes "for YAML" is the over-escape trap that
|
|
134
139
|
kills pattern anchors, and it kills violation regexes the same way. The
|
|
135
|
-
same lint error and the same `[\\]`
|
|
140
|
+
same lint error and the same two respellings (halved or `[\\]`) apply
|
|
141
|
+
(see Anti-Over-Escape).
|
|
136
142
|
- **Prove both cases.** Before finishing, run a synthetic
|
|
137
143
|
`scar check --diff` twice: once with a diff that MUST fire the violation,
|
|
138
144
|
once with an innocent diff that must NOT. A tripwire verified only on the
|
|
@@ -8,9 +8,10 @@ from __future__ import annotations
|
|
|
8
8
|
import re
|
|
9
9
|
from dataclasses import dataclass
|
|
10
10
|
|
|
11
|
-
from . import clock, symbols
|
|
11
|
+
from . import clock, presence, symbols
|
|
12
12
|
from .config import Config, signing_problem
|
|
13
13
|
from .model import SEVERITIES, STATUSES, TYPES, ParseError, Scar, is_valid_url, parse_scar_text
|
|
14
|
+
from .record import record_hash
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
# A valid regex can still be a ReDoS weapon. re.compile accepts it (the syntax
|
|
@@ -128,8 +129,10 @@ def _is_redos_prone(pattern: str) -> bool:
|
|
|
128
129
|
|
|
129
130
|
# #404: the reader takes regex fields verbatim (no YAML unescaping), so a
|
|
130
131
|
# doubled backslash before a regex escape or metacharacter is a literal
|
|
131
|
-
# backslash followed by that character. It compiles
|
|
132
|
-
#
|
|
132
|
+
# backslash followed by that character. It compiles and is not ReDoS-prone.
|
|
133
|
+
# Usually the author meant the escape, but a target that really holds a
|
|
134
|
+
# backslash (regex source in a raw string) is matched by the doubled form, so
|
|
135
|
+
# the check only claims what the spelling proves.
|
|
133
136
|
_OVERESCAPE_NEXT = frozenset("()[]{}.*+?|^$bBsSwWdD")
|
|
134
137
|
|
|
135
138
|
|
|
@@ -180,18 +183,29 @@ def _overescape_runs(pattern: str) -> list[tuple[int, int]]:
|
|
|
180
183
|
return runs
|
|
181
184
|
|
|
182
185
|
|
|
183
|
-
def
|
|
184
|
-
"""
|
|
186
|
+
def _overescape_respellings(pattern: str) -> tuple[str, str] | None:
|
|
187
|
+
"""(halved, class form) for an over-escaped *pattern*, or None when clean.
|
|
188
|
+
|
|
189
|
+
Both rewrite only the flagged runs. The halved form is for an author who
|
|
190
|
+
meant the escape. The class form puts each doubled pair in `[\\\\]`, for
|
|
191
|
+
an author who meant a real backslash: it matches the same text as the
|
|
192
|
+
original, and the class is the spelling the rule accepts.
|
|
193
|
+
"""
|
|
185
194
|
runs = _overescape_runs(pattern)
|
|
186
195
|
if not runs:
|
|
187
196
|
return None
|
|
188
|
-
|
|
197
|
+
halved, classed, last = [], [], 0
|
|
189
198
|
for start, length in runs:
|
|
190
|
-
|
|
191
|
-
|
|
199
|
+
gap = pattern[last:start]
|
|
200
|
+
halved.append(gap)
|
|
201
|
+
classed.append(gap)
|
|
202
|
+
halved.append("\\" * (length // 2))
|
|
203
|
+
classed.append("[\\\\]" * (length // 2))
|
|
192
204
|
last = start + length
|
|
193
|
-
|
|
194
|
-
|
|
205
|
+
tail = pattern[last:]
|
|
206
|
+
halved.append(tail)
|
|
207
|
+
classed.append(tail)
|
|
208
|
+
return "".join(halved), "".join(classed)
|
|
195
209
|
|
|
196
210
|
|
|
197
211
|
def _regex_field_findings(label: str, value: str) -> tuple[list[Finding], re.Pattern | None]:
|
|
@@ -204,14 +218,16 @@ def _regex_field_findings(label: str, value: str) -> tuple[list[Finding], re.Pat
|
|
|
204
218
|
findings = []
|
|
205
219
|
# Reported even when the regex does not compile: `NewConformance\\(` fails
|
|
206
220
|
# with "missing )", which hides the real cause. Name both.
|
|
207
|
-
|
|
208
|
-
if
|
|
221
|
+
respelled = _overescape_respellings(value)
|
|
222
|
+
if respelled is not None:
|
|
223
|
+
halved, classed = respelled
|
|
209
224
|
findings.append(Finding(
|
|
210
225
|
"error", f"over-escaped {label} /{value}/: a doubled backslash "
|
|
211
|
-
"before a regex escape or metacharacter
|
|
212
|
-
"
|
|
213
|
-
|
|
214
|
-
"
|
|
226
|
+
"before a regex escape or metacharacter matches a literal "
|
|
227
|
+
"backslash followed by that character, not the regex escape (the "
|
|
228
|
+
"value is read verbatim, nothing un-escapes it). If you meant "
|
|
229
|
+
f"the escape, write /{halved}/. If the text really contains a "
|
|
230
|
+
f"backslash, write /{classed}/"))
|
|
215
231
|
try:
|
|
216
232
|
rx = re.compile(value)
|
|
217
233
|
except re.error as exc:
|
|
@@ -298,6 +314,9 @@ def downgrade_findings(scars: list[tuple[str, Scar]], cfg: Config,
|
|
|
298
314
|
- an act with no org in the config (the org was deleted);
|
|
299
315
|
- an org, and a scar at or after signed_from with no act (the act was
|
|
300
316
|
dropped, or the scar was promoted around signing).
|
|
317
|
+
- an act whose inputs_hash is not the hash of the scar's current record
|
|
318
|
+
(#409): the record was changed after signing. Only a mismatch is
|
|
319
|
+
reported; a match proves nothing about the signature.
|
|
301
320
|
It reads no signature: whether an act is genuine is the checker's job."""
|
|
302
321
|
out: list[tuple[str, Finding]] = []
|
|
303
322
|
if cfg.org is None:
|
|
@@ -310,6 +329,23 @@ def downgrade_findings(scars: list[tuple[str, Scar]], cfg: Config,
|
|
|
310
329
|
problem = signing_problem(cfg, next_id)
|
|
311
330
|
if problem:
|
|
312
331
|
out.append((CONFIG_REL, Finding("error", problem)))
|
|
332
|
+
# With no org (returned above) the act is already an error for that cause,
|
|
333
|
+
# so staleness is only judged once an org exists: one cause, one error.
|
|
334
|
+
for rel, scar in scars:
|
|
335
|
+
if not scar.promotion_act or scar.id is None:
|
|
336
|
+
continue
|
|
337
|
+
try:
|
|
338
|
+
signed = presence.act_inputs_hash(scar.promotion_act)
|
|
339
|
+
except presence.MalformedAct as exc:
|
|
340
|
+
out.append((rel, Finding(
|
|
341
|
+
"error", f"scar {scar.id} carries a promotion_act that cannot be read "
|
|
342
|
+
f"({exc.reason}); it cannot be compared with the record")))
|
|
343
|
+
continue
|
|
344
|
+
if signed != record_hash(scar):
|
|
345
|
+
out.append((rel, Finding(
|
|
346
|
+
"error", f"scar {scar.id} changed since it was signed: its promotion_act "
|
|
347
|
+
"was made for a different record (id, type, title, severity, promoted_from, "
|
|
348
|
+
"anchors or body), so it needs a new signature")))
|
|
313
349
|
if cfg.signed_from is not None:
|
|
314
350
|
for rel, scar in scars:
|
|
315
351
|
if (scar.status != "candidate" and scar.id is not None
|
|
@@ -187,8 +187,8 @@ TOOLS = [
|
|
|
187
187
|
"Write a candidate scar to .scars/candidates/ for human promotion. "
|
|
188
188
|
"Use for negative knowledge: deadend (tried+failed), fence (looks "
|
|
189
189
|
"wrong but intentional), or landmine (touching A breaks B). Prefer a "
|
|
190
|
-
"path: anchor
|
|
191
|
-
"
|
|
190
|
+
"path: anchor; pattern: regexes are read verbatim, and a doubled "
|
|
191
|
+
"backslash in one means a literal backslash. Writes only to candidates/ and lints before writing; a "
|
|
192
192
|
"human promotes. See the scar-authoring skill (scar agent skill)."
|
|
193
193
|
),
|
|
194
194
|
"inputSchema": {
|
|
@@ -48,6 +48,10 @@ class PresenceError(Exception):
|
|
|
48
48
|
self.reason = reason
|
|
49
49
|
|
|
50
50
|
|
|
51
|
+
class MalformedAct(PresenceError):
|
|
52
|
+
"""A stored act whose payload cannot be read. `reason` says which part."""
|
|
53
|
+
|
|
54
|
+
|
|
51
55
|
class Unavailable(PresenceError):
|
|
52
56
|
"""No usable answer: the program is missing, crashed, timed out, or said
|
|
53
57
|
something that is not its documented output. Nothing is assumed."""
|
|
@@ -61,6 +65,31 @@ class Cancelled(PresenceError):
|
|
|
61
65
|
"""The person declined the touch (signer exit 1)."""
|
|
62
66
|
|
|
63
67
|
|
|
68
|
+
def act_inputs_hash(jws: str) -> str:
|
|
69
|
+
"""The `inputs_hash` in a stored act's payload. Decodes only: the
|
|
70
|
+
signature is not looked at, so a result proves nothing about the act being
|
|
71
|
+
genuine (that is the checker's job). Raises MalformedAct when the act is not
|
|
72
|
+
three segments, the payload is not base64url JSON object, or it carries no
|
|
73
|
+
non-empty string `inputs_hash`."""
|
|
74
|
+
parts = jws.split(".") if isinstance(jws, str) else []
|
|
75
|
+
if len(parts) != 3:
|
|
76
|
+
raise MalformedAct("not a compact JWS of three segments")
|
|
77
|
+
segment = parts[1]
|
|
78
|
+
try:
|
|
79
|
+
raw = base64.b64decode(
|
|
80
|
+
segment.replace("-", "+").replace("_", "/") + "=" * (-len(segment) % 4),
|
|
81
|
+
validate=True)
|
|
82
|
+
payload = json.loads(raw.decode("utf-8"))
|
|
83
|
+
except (ValueError, UnicodeDecodeError):
|
|
84
|
+
raise MalformedAct("payload is not base64url-encoded JSON") from None
|
|
85
|
+
if not isinstance(payload, dict):
|
|
86
|
+
raise MalformedAct("payload is not a JSON object")
|
|
87
|
+
value = payload.get("inputs_hash")
|
|
88
|
+
if not isinstance(value, str) or not value:
|
|
89
|
+
raise MalformedAct("payload has no inputs_hash")
|
|
90
|
+
return value
|
|
91
|
+
|
|
92
|
+
|
|
64
93
|
def _canonical(payload: dict) -> str:
|
|
65
94
|
# The signer reads its stdin through the canonical subset: no whitespace,
|
|
66
95
|
# no numbers, no booleans. Sorted keys, compact, ASCII.
|
|
@@ -11,6 +11,8 @@ size check here; the signer refuses an oversize record before any confirmation.
|
|
|
11
11
|
"""
|
|
12
12
|
from __future__ import annotations
|
|
13
13
|
|
|
14
|
+
import base64
|
|
15
|
+
import hashlib
|
|
14
16
|
import subprocess
|
|
15
17
|
from pathlib import Path
|
|
16
18
|
|
|
@@ -58,3 +60,12 @@ def promoted_record(scar: Scar) -> bytes:
|
|
|
58
60
|
body = scar.body.replace("\r\n", "\n").replace("\r", "\n").rstrip()
|
|
59
61
|
lines += ["---", body]
|
|
60
62
|
return ("\n".join(lines) + "\n").encode("utf-8")
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def record_hash(scar: Scar) -> str:
|
|
66
|
+
"""The hash string an act stores as `inputs_hash` for this scar's record:
|
|
67
|
+
"u" plus unpadded base64url of 0x12 0x20 (sha256 multihash prefix) and the
|
|
68
|
+
sha256 of promoted_record(). Computed from the file every time, never
|
|
69
|
+
stored, so an act can be compared against the record it sits on."""
|
|
70
|
+
digest = hashlib.sha256(promoted_record(scar)).digest()
|
|
71
|
+
return "u" + base64.urlsafe_b64encode(b"\x12\x20" + digest).decode("ascii").rstrip("=")
|
|
@@ -92,9 +92,14 @@ must use a `pattern:` regex, know that the value reaches the matcher
|
|
|
92
92
|
**verbatim** — this reader is not a YAML parser and nothing un-escapes. Write
|
|
93
93
|
the regex exactly as it must execute: `\b` stays `\b`, `\(` stays `\(`.
|
|
94
94
|
Doubling backslashes "for YAML" yields a literal backslash and a dead anchor.
|
|
95
|
-
`scar lint` rejects it as an error
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
`scar lint` rejects it as an error. The value matches a literal backslash
|
|
96
|
+
followed by the next character, which lint cannot tell from a slip, so the
|
|
97
|
+
message prints two respellings. The halved form (`\\w` becomes `\w`) is for
|
|
98
|
+
when you meant the escape. The class form, with each doubled pair written as
|
|
99
|
+
`[\\]`, is for when the target text really holds a backslash, such as regex
|
|
100
|
+
source inside a raw string. To guard `r"[\w-]*(?:api|key)"` write
|
|
101
|
+
`\[[\\]w-\]\*\(\?:api`, not `\[\w-\]\*\(\?:api`, which does not match it.
|
|
102
|
+
Lint accepts the class form.
|
|
98
103
|
|
|
99
104
|
The pattern is also matched against all tracked content **including the scar's
|
|
100
105
|
own body**, so a broken pattern keeps itself alive by self-reference. Run
|
|
@@ -132,7 +137,8 @@ the fired→violated compliance metric).
|
|
|
132
137
|
un-escapes. Write it exactly as it must execute — `\b` stays `\b`, `\(`
|
|
133
138
|
stays `\(`. Doubling backslashes "for YAML" is the over-escape trap that
|
|
134
139
|
kills pattern anchors, and it kills violation regexes the same way. The
|
|
135
|
-
same lint error and the same `[\\]`
|
|
140
|
+
same lint error and the same two respellings (halved or `[\\]`) apply
|
|
141
|
+
(see Anti-Over-Escape).
|
|
136
142
|
- **Prove both cases.** Before finishing, run a synthetic
|
|
137
143
|
`scar check --diff` twice: once with a diff that MUST fire the violation,
|
|
138
144
|
once with an innocent diff that must NOT. A tripwire verified only on the
|
|
@@ -12,7 +12,7 @@ import sys
|
|
|
12
12
|
from pathlib import Path
|
|
13
13
|
|
|
14
14
|
_SCRIPT = """#!{python}
|
|
15
|
-
import json, sys, time
|
|
15
|
+
import base64, hashlib, json, sys, time
|
|
16
16
|
from pathlib import Path
|
|
17
17
|
here = Path(__file__).parent
|
|
18
18
|
name = Path(__file__).name
|
|
@@ -29,6 +29,18 @@ with open(here / (name + ".calls.jsonl"), "a") as fh:
|
|
|
29
29
|
replies = cfg.get(cmd) or cfg.get("*") or [{{"out": "{{\\"error\\":\\"unsupported_command\\"}}", "code": 2}}]
|
|
30
30
|
r = replies[min(n, len(replies) - 1)]
|
|
31
31
|
time.sleep(r.get("sleep", 0))
|
|
32
|
+
if r.get("act_from_decision"):
|
|
33
|
+
# Like the real signer, bind the act to the record it was handed: inputs_hash
|
|
34
|
+
# is "u" + b64url(0x12 0x20 + sha256(decision bytes)), worked out here with
|
|
35
|
+
# hashlib alone so a test proves the bytes promote sends are the bytes Scar
|
|
36
|
+
# hashes later.
|
|
37
|
+
record = base64.b64decode(json.loads(stdin)["attachments"]["decision_b64"])
|
|
38
|
+
digest = b"\\x12\\x20" + hashlib.sha256(record).digest()
|
|
39
|
+
claims = {{"inputs_hash": "u" + base64.urlsafe_b64encode(digest).decode().rstrip("=")}}
|
|
40
|
+
seg = lambda b: base64.urlsafe_b64encode(b).decode().rstrip("=")
|
|
41
|
+
body = json.loads(r["out"])
|
|
42
|
+
body["jws"] = seg(b'{{"alg":"fake"}}') + "." + seg(json.dumps(claims).encode()) + "." + seg(b"sig")
|
|
43
|
+
r = {{**r, "out": json.dumps(body, sort_keys=True)}}
|
|
32
44
|
sys.stdout.write(r["out"] + "\\n")
|
|
33
45
|
sys.exit(r.get("code", 0))
|
|
34
46
|
"""
|
|
@@ -623,3 +623,94 @@ def test_leading_bracket_in_class_does_not_close_it_early():
|
|
|
623
623
|
# backslash after it is still inside the class and is the clean hatch.
|
|
624
624
|
assert _overescaped(lint_text(_with("violation", r"x[]\\(]"))) == []
|
|
625
625
|
assert _overescaped(lint_text(_with("violation", r"x[^]\\(]"))) == []
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
# --- truthful over-escape message (#407) ---
|
|
629
|
+
#
|
|
630
|
+
# The rule only reads spelling, so it can claim just that the value matches a
|
|
631
|
+
# literal backslash plus the next character. A target that really holds a
|
|
632
|
+
# backslash before a metacharacter (regex source in a raw string) is matched
|
|
633
|
+
# by the as-written value, so the message must offer both respellings.
|
|
634
|
+
|
|
635
|
+
RAW_STRING_VALUE = r"\[\\w-\]\*\(\?:"
|
|
636
|
+
RAW_STRING_HALVED = r"\[\w-\]\*\(\?:"
|
|
637
|
+
RAW_STRING_CLASS = r"\[[\\]w-\]\*\(\?:"
|
|
638
|
+
RAW_STRING_SAMPLE = 'PAT = re.compile(r"[\\w-]*(?:api|key)")'
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
def _overescape_message(field_text):
|
|
642
|
+
found = _overescaped(lint_text(field_text))
|
|
643
|
+
assert len(found) == 1
|
|
644
|
+
return found[0].message
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
def test_message_claims_only_what_the_check_proves():
|
|
648
|
+
msg = _overescape_message(_with("violation", RAW_STRING_VALUE))
|
|
649
|
+
assert "can never match" not in msg
|
|
650
|
+
assert "literal backslash" in msg
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
def test_message_offers_halved_form_for_the_escape_meaning():
|
|
654
|
+
msg = _overescape_message(_with("violation", OVER_VIOLATION))
|
|
655
|
+
assert r"func \(\w+ Snapshot\) MarshalJSON" in msg
|
|
656
|
+
|
|
657
|
+
|
|
658
|
+
def test_message_offers_both_respellings_for_raw_string_case():
|
|
659
|
+
msg = _overescape_message(_with("violation", RAW_STRING_VALUE))
|
|
660
|
+
assert RAW_STRING_HALVED in msg
|
|
661
|
+
assert RAW_STRING_CLASS in msg
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
def test_class_form_passes_lint_and_matches_what_the_original_matches():
|
|
665
|
+
import re
|
|
666
|
+
|
|
667
|
+
assert _overescaped(lint_text(_with("violation", RAW_STRING_CLASS))) == []
|
|
668
|
+
assert len(re.findall(RAW_STRING_VALUE, RAW_STRING_SAMPLE)) == 1
|
|
669
|
+
assert len(re.findall(RAW_STRING_CLASS, RAW_STRING_SAMPLE)) == 1
|
|
670
|
+
assert re.findall(RAW_STRING_HALVED, RAW_STRING_SAMPLE) == []
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
def test_pattern_anchor_gets_the_same_message_through_the_shared_path():
|
|
674
|
+
msg = _overescape_message(_anchored(RAW_STRING_VALUE))
|
|
675
|
+
assert "can never match" not in msg
|
|
676
|
+
assert RAW_STRING_HALVED in msg and RAW_STRING_CLASS in msg
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
def test_every_flagged_value_has_a_class_form_that_is_clean_and_equivalent():
|
|
680
|
+
import re
|
|
681
|
+
|
|
682
|
+
from scar.lint import _overescape_respellings
|
|
683
|
+
|
|
684
|
+
# (value, sample the as-written value really matches)
|
|
685
|
+
cases = [
|
|
686
|
+
(RAW_STRING_VALUE, RAW_STRING_SAMPLE),
|
|
687
|
+
("a" + "\\" * 4 + "(b)", "a" + "\\" * 2 + "b"),
|
|
688
|
+
("x\\\\.y\\\\.z", "x\\ay\\bz"),
|
|
689
|
+
("a\\\\(b\\\\)", "a\\b\\"),
|
|
690
|
+
]
|
|
691
|
+
for value, sample in cases:
|
|
692
|
+
halved, class_form = _overescape_respellings(value)
|
|
693
|
+
assert re.compile(class_form), value
|
|
694
|
+
assert _overescaped(lint_text(_with("violation", class_form))) == [], value
|
|
695
|
+
assert _overescape_respellings(class_form) is None, value
|
|
696
|
+
if "\\" * 4 not in value:
|
|
697
|
+
# halving four leaves a live pair, which is flagged again by design
|
|
698
|
+
assert _overescape_respellings(halved) is None, value
|
|
699
|
+
original = [m.group() for m in re.finditer(value, sample)]
|
|
700
|
+
assert original, value
|
|
701
|
+
assert [m.group() for m in re.finditer(class_form, sample)] == original, value
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
def test_longer_run_class_form_uses_one_class_per_pair():
|
|
705
|
+
from scar.lint import _overescape_respellings
|
|
706
|
+
|
|
707
|
+
halved, class_form = _overescape_respellings("a" + "\\" * 4 + "(b")
|
|
708
|
+
assert halved == "a" + "\\" * 2 + "(b"
|
|
709
|
+
assert class_form == "a[\\\\][\\\\](b"
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+
def test_clean_values_have_no_respellings():
|
|
713
|
+
from scar.lint import _overescape_respellings
|
|
714
|
+
|
|
715
|
+
for ok in (r"[\\]b", r"x[^a\\]+\\", r"\\n", r"a\\", r"\\\("):
|
|
716
|
+
assert _overescape_respellings(ok) is None, ok
|
|
@@ -5,13 +5,16 @@ The attack is not forging an act (the checker catches that); it is deleting the
|
|
|
5
5
|
org from the config so promote stops asking for one, or dropping an act from a
|
|
6
6
|
scar. Both are structural facts a lint can see.
|
|
7
7
|
"""
|
|
8
|
+
import base64
|
|
8
9
|
import json
|
|
9
10
|
import subprocess
|
|
10
11
|
|
|
11
12
|
import pytest
|
|
12
13
|
|
|
13
|
-
from scar import config
|
|
14
|
+
from scar import config, renames
|
|
14
15
|
from scar.cli import main
|
|
16
|
+
from scar.model import parse_scar_text
|
|
17
|
+
from scar.record import record_hash
|
|
15
18
|
from scar.store import ScarStore, init_scars
|
|
16
19
|
|
|
17
20
|
ORG = "uEiARDVf_JDy-0rOjSM1lEH6YMSEdD2RQiuviL-AsSVLq4A"
|
|
@@ -25,14 +28,29 @@ def repo(tmp_path, monkeypatch):
|
|
|
25
28
|
return tmp_path
|
|
26
29
|
|
|
27
30
|
|
|
28
|
-
def
|
|
31
|
+
def make_act(inputs_hash):
|
|
32
|
+
"""A compact JWS shape with a real payload and a junk signature. Scar only
|
|
33
|
+
decodes the payload here; whether the signature is genuine is the checker's job."""
|
|
34
|
+
payload = base64.urlsafe_b64encode(
|
|
35
|
+
json.dumps({"inputs_hash": inputs_hash}).encode()).rstrip(b"=").decode()
|
|
36
|
+
return f"h.{payload}.s"
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def scar(repo, n, act=True, status="active", name=None, act_value=None):
|
|
29
40
|
lines = [f"id: {n}", "type: fence", f"title: Scar {n}", "severity: low", "confidence: 0.5",
|
|
30
41
|
"created: 2026-11-01", 'authors: ["claude-code"]', "promoted_by: kibukx"]
|
|
31
|
-
|
|
32
|
-
lines += [f"promotion_act: a.b.{n}", f"promotion_receipt: uEiR{n}"]
|
|
33
|
-
lines += ["anchors:", " - path: src/x.py", f"status: {status}"]
|
|
42
|
+
tail = ["anchors:", " - path: src/x.py", f"status: {status}"]
|
|
34
43
|
p = repo / ".scars" / (name or f"{n:04d}-s{n}.fence.md")
|
|
35
|
-
|
|
44
|
+
|
|
45
|
+
def write(extra):
|
|
46
|
+
p.write_text("---\n" + "\n".join(lines + extra + tail) + "\n---\n\nBody.\n")
|
|
47
|
+
|
|
48
|
+
write([])
|
|
49
|
+
if act:
|
|
50
|
+
# The act signs the record, so it carries the hash of this very file.
|
|
51
|
+
act_text = act_value if act_value is not None else make_act(
|
|
52
|
+
record_hash(parse_scar_text(p.read_text())))
|
|
53
|
+
write([f"promotion_act: {act_text}", f"promotion_receipt: uEiR{n}"])
|
|
36
54
|
return p
|
|
37
55
|
|
|
38
56
|
|
|
@@ -179,3 +197,81 @@ def test_promote_refuses_an_org_without_signed_from_before_any_touch(repo, capsy
|
|
|
179
197
|
assert signer.calls() == [] and checker.calls() == []
|
|
180
198
|
assert cand.read_bytes() == before
|
|
181
199
|
assert ScarStore.discover(repo).next_id() == 1
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
# ---- a stale act (#409): the act no longer matches the record it sits on ----
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def signed_repo(repo):
|
|
206
|
+
p = scar(repo, 1)
|
|
207
|
+
cfg(repo, org=ORG, signed_from=1)
|
|
208
|
+
return p
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def test_an_act_that_matches_its_record_is_clean_and_says_nothing(repo, capsys):
|
|
212
|
+
signed_repo(repo)
|
|
213
|
+
rc, out = lint(capsys)
|
|
214
|
+
assert rc == 0
|
|
215
|
+
assert "signature" not in out and "matches" not in out
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def test_an_anchor_rewrite_makes_the_act_stale(repo, capsys):
|
|
219
|
+
p = signed_repo(repo)
|
|
220
|
+
assert renames.apply_anchor_rewrite(p, "path", {"src/x.py": "src/y.py"})
|
|
221
|
+
rc, out = lint(capsys)
|
|
222
|
+
assert rc == 1
|
|
223
|
+
assert "0001-s1.fence.md" in out and "scar 1" in out and "new signature" in out
|
|
224
|
+
assert "promoted_from" in out
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
@pytest.mark.parametrize("old,new", [("Body.", "Body, edited."),
|
|
228
|
+
("title: Scar 1", "title: Scar one"),
|
|
229
|
+
("severity: low", "severity: high")])
|
|
230
|
+
def test_editing_a_signed_field_makes_the_act_stale(repo, capsys, old, new):
|
|
231
|
+
p = signed_repo(repo)
|
|
232
|
+
p.write_text(p.read_text().replace(old, new))
|
|
233
|
+
rc, out = lint(capsys)
|
|
234
|
+
assert rc == 1
|
|
235
|
+
assert "scar 1" in out and "new signature" in out
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def test_transition_and_evidence_notes_do_not_stale_the_act(repo, capsys):
|
|
239
|
+
p = signed_repo(repo)
|
|
240
|
+
store = ScarStore.discover(repo)
|
|
241
|
+
store.append_evidence_note(1, "note: seen again")
|
|
242
|
+
store.transition(1, "challenged", "looked odd", "2026-11-02")
|
|
243
|
+
assert "challenged" in p.read_text()
|
|
244
|
+
rc, out = lint(capsys)
|
|
245
|
+
assert rc == 0, out
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
@pytest.mark.parametrize("act_value", [
|
|
249
|
+
"only.two", # not three segments
|
|
250
|
+
"a.b.c.d", # too many segments
|
|
251
|
+
"h.!!not-base64!!.s", # payload is not base64
|
|
252
|
+
"h." + base64.urlsafe_b64encode(b"not json").decode().rstrip("=") + ".s",
|
|
253
|
+
"h." + base64.urlsafe_b64encode(b"[1]").decode().rstrip("=") + ".s", # not an object
|
|
254
|
+
"h." + base64.urlsafe_b64encode(b"{}").decode().rstrip("=") + ".s", # no inputs_hash
|
|
255
|
+
"h." + base64.urlsafe_b64encode(b'{"inputs_hash": 5}').decode().rstrip("=") + ".s",
|
|
256
|
+
])
|
|
257
|
+
def test_an_act_that_cannot_be_read_is_an_error(repo, capsys, act_value):
|
|
258
|
+
scar(repo, 1, act_value=act_value)
|
|
259
|
+
cfg(repo, org=ORG, signed_from=1)
|
|
260
|
+
rc, out = lint(capsys)
|
|
261
|
+
assert rc == 1
|
|
262
|
+
assert "scar 1" in out and "cannot be read" in out
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
def test_a_scar_with_no_act_gets_no_stale_finding(repo, capsys):
|
|
266
|
+
scar(repo, 1, act=False)
|
|
267
|
+
cfg(repo, org=ORG, signed_from=2)
|
|
268
|
+
rc, out = lint(capsys)
|
|
269
|
+
assert rc == 0 and "new signature" not in out
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
def test_signing_off_reports_one_error_for_a_stale_act_not_two(repo, capsys):
|
|
273
|
+
p = scar(repo, 1)
|
|
274
|
+
p.write_text(p.read_text().replace("Body.", "Edited."))
|
|
275
|
+
rc, out = lint(capsys) # no org: the act has no org to answer to
|
|
276
|
+
assert rc == 1
|
|
277
|
+
assert "no org" in out and "new signature" not in out
|
|
@@ -250,3 +250,11 @@ def test_scar_draft_refuses_role_word_authors(tmp_path, monkeypatch):
|
|
|
250
250
|
init_scars(tmp_path)
|
|
251
251
|
with pytest.raises(ValueError, match="authors"):
|
|
252
252
|
_handle("tools/call", _draft_args(tmp_path, authors=["agent"]))
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
def test_scar_draft_description_does_not_blame_yaml_for_backslashes():
|
|
256
|
+
# Values are read verbatim, so nothing "over-escapes in YAML" (#407).
|
|
257
|
+
desc = next(t for t in TOOLS if t["name"] == "scar_draft")["description"]
|
|
258
|
+
assert "YAML" not in desc
|
|
259
|
+
assert "path:" in desc
|
|
260
|
+
assert "literal backslash" in desc
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"""presence.py owns the fixed paths and the words (consumer, action, method).
|
|
2
2
|
Slice 3 of the presence proof (#392)."""
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
3
5
|
from scar import presence
|
|
4
6
|
|
|
5
7
|
|
|
@@ -25,3 +27,21 @@ def test_the_validity_window_is_a_decimal_string_constant():
|
|
|
25
27
|
assert presence.EXPIRES_IN_S == "3600"
|
|
26
28
|
assert isinstance(presence.EXPIRES_IN_S, str)
|
|
27
29
|
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _jws(payload_bytes):
|
|
33
|
+
import base64
|
|
34
|
+
return "h." + base64.urlsafe_b64encode(payload_bytes).decode().rstrip("=") + ".s"
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def test_act_inputs_hash_reads_the_payload_without_verifying_anything():
|
|
38
|
+
assert presence.act_inputs_hash(_jws(b'{"inputs_hash": "uEiabc", "x": 1}')) == "uEiabc"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@pytest.mark.parametrize("bad", [
|
|
42
|
+
"", "a.b", "a.b.c.d", "h.!!.s", _jws(b"nope"), _jws(b"[]"), _jws(b"{}"),
|
|
43
|
+
_jws(b'{"inputs_hash": 5}'), _jws(b'{"inputs_hash": ""}'), _jws(b"\xff\xfe"),
|
|
44
|
+
])
|
|
45
|
+
def test_act_inputs_hash_raises_on_anything_malformed(bad):
|
|
46
|
+
with pytest.raises(presence.MalformedAct):
|
|
47
|
+
presence.act_inputs_hash(bad)
|