Repository navigation
Conversation
…igh + medium batches Process docs/ocr-20261114 review (1,577 findings) validate-first: every claim checked against real code before fixing; false/stale claims dropped with evidence; spec-contract drift resolved doc-only where the implementation was already correct. Security - critical 1450: eval injection in .specify prerequisite scripts - 21 high findings fixed (sanitization, TOCTOU/bounded reads, secret scans, path guards, Unicode case-folding, exec identity re-verification) - ~25 medium findings fixed in batches 1-3 Bug high - 44 code/test/script fixes; 15 spec-drift resolutions (approved option D) Bug medium (this batch) - review decode: content caps no longer latch sticky Capacity (867/876/878) - trace embedding: RFC 3986 encoding, budget-omission, idempotent re-embed (658/659/660); profile control-id whitespace rejection (665) - mapping: baseline hash-evidence refusal + finding dedup (483/484), inventory digest domain separation (493, example pin chain refreshed), ineligible-part ID integrity (496), dead code removal (498), render-before-write + fail-closed identity (502/503) - linkage: absence capture rechecks leaf at read time (477), 32-bit limit clamp (476); lifecycle symlink check fails closed on EACCES/EIO (475) - assessment results: buffered findings commit-once on success (249), canonical UUID identity comparison (250), no silent subject/evidence error swallowing (251), symmetric upstream-removal finding (252), scaffold reuses hashed parse — deletes 3 unverified re-reads (261) - applicability: CLI analyze verifies input fingerprints before emission (242) - workflow: non-UTF-8 refusal (1217), case-folded allowlist (1218), fake-adapter strictness + timeout classification + lock-free delay (1222/1224/1225) - authoring plan admission error routing (315/316); batch symlink-aware naming (329/330) - UI drivers: one-shot fault handlers, drain-until-quiet observers, route guards, read-only assertions, null-page diagnostics; CSS hover/disabled affordances (21-39 cluster) - scripts: UTF-8 reads + shared evidence guard + duplicate-source rejection in roadmap ledger (92/93/95); TOML non-finite rejection (97); SPDX expression + content-complete serialNumber in SBOM (88/89); SSP owner attribution fix + dedup + UUID resolution assert, regenerated invalid stale artifact (102/103); bench pipeline matches production 7c/7d (129) - spec contracts transcribed to shipped behavior (doc-only): 122/123/124/ 126/138/140/143/148/151/153/159/164/67 Verification: cargo test 4,686 passed / 0 failed; cargo clippy --all-targets 0 warnings; python suites OK; node --check + bash -n clean on touched files. Known follow-ups (not in this PR): - dependency-graph pin refresh for release.yml is owner-gated (fail-closed CommittedStoreTests error until reviewed refresh) - gate scripts (109/111/112/114) are a mutually hash-pinned anti-tamper web; fixes require reviewed re-pin - PRD055 ledger hash drift pre-existing - security medium batch 4 + bug medium remainder await decisions/triage
|
Important Review skippedToo many files! This PR contains 140 files, which is 40 over the limit of 100. To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch. Upgrade to a paid plan to raise the limit. This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry.
|
| if getattr(self, "_capability", "") and self.process.poll() is None: | ||
| try: | ||
| self.request("POST", self.api_path("/session/shutdown"), {}) | ||
| except Exception: |
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟡 Changes recommended
Critical issues remain, including a flawed TOCTOU mitigation that doesn’t bind the hash to a stable inode and a unix-only file_identity call that breaks non-unix builds, so the change needs fixes before it can be approved.
4 open issues
What changed in this PR
Validate-first remediation of OCR review findings across FORGE (security + correctness), aligning tests/snapshots/examples and contract/spec docs with shipped behavior.
Changes:
- Harden trust boundaries (path validation, sanitization, bounded reads, TOCTOU/confinement checks, fail-closed fallbacks).
- Fix correctness/determinism issues (idempotency, deduplication, digest/fingerprint domain separation, stricter invariants).
- Expand/refresh tests, snapshots, examples, CI/scripts, and spec-contract documentation to match implemented behavior.
| File | Description |
|---|---|
| ui/workspace.css | Tweaks button hover styling so disabled/aria-disabled controls do not appear interactive. |
| ui/tests/workspace-staged-source-browser.cjs | Hardens route/observation handling and strengthens read-only API request assertions in staged source browser tests. |
| ui/tests/workspace-source-browser.cjs | Improves observation draining and route error containment for more stable source browser tests. |
| ui/tests/workspace-bundle-browser.cjs | Prevents unhandled rejections and improves route/error capture in bundle browser tests. |
| ui/tests/workspace-alert-browser.cjs | Stabilizes alert test waiting conditions to avoid stale-render text mismatches. |
| ui/tests/workspace_failure.cjs | Normalizes null/undefined handling in failure-path browser observation tests. |
| tests/workflow_contract_test.rs | Adds a regression test around workflow plan idempotency (duplicate Create within one run). |
| tests/suggest_prepare_cli_test.rs | Updates CLI test expectations to match the revised redaction hashing behavior. |
| tests/snapshots/golden_file_tests__golden_catalog_tests__complex_catalog.snap | Refreshes the complex catalog golden snapshot to match updated metadata/wording. |
| tests/snapshots/applicability_cli_test__applicability_report_cross_platform.snap | Refreshes the applicability report snapshot to match updated digest/metadata outputs. |
| tests/risk_authoring_cli_test.rs | Updates tests to the current assessment plan builder API/signature. |
| tests/poam_foundation_test.rs | Updates tests to the current assessment plan builder API/signature. |
| tests/mapping_cli_test.rs | Adds/updates mapping CLI tests enforcing baseline integrity requirements (e.g., hash evidence). |
| tests/integration_cross_feature.rs | Avoids child-process pipe deadlocks by draining stdout/stderr while polling in integration tests. |
| tests/golden_file_tests.rs | Adds a gated/normalized golden update helper and tightens golden regeneration behavior. |
| tests/golden_edge_case_tests.rs | Tightens edge-case normalization and adds guards for stable ID extraction in golden tests. |
| tests/fixtures/edge-cases/ec-parameter-like-content/expected-catalog.json | Updates expected fixture output to match revised parameter constraint rendering. |
| tests/assessment_epochs_cli_test.rs | Updates tests to the current assessment plan builder API/signature. |
| src/workspace/source_validation.rs | Records observed mapping inputs during workspace validation to keep input tracking accurate. |
| src/workspace/session.rs | Refines security-event budgeting/slot reservation behavior and strengthens related tests. |
| src/workspace/services.rs | Strengthens workspace path admission/containment rules and related path handling logic. |
| src/workspace/provenance.rs | Fixes provenance reference ID handling to use the correct opaque identifiers. |
| src/workspace/lifecycle.rs | Adjusts lifecycle inventory behavior to treat containment failures as row-level unavailability. |
| src/workspace/bundle_effects.rs | Ensures index slots are reserved consistently and updates behavior around file-count ceilings. |
| src/workspace/actions.rs | Makes applicability report comparison/validation fail closed when parsing fails. |
| src/workflow/plan.rs | Improves in-run duplicate Create handling and tightens protocol error behavior. |
| src/workflow/mod.rs | Refuses lossy non-UTF-8 paths when generating repo-relative links and adds coverage. |
| src/workflow/config.rs | Hardens config parsing/redaction behavior (e.g., avoid echoing user-controlled fields; case-insensitive allowlists). |
| src/workflow/change_set.rs | Hardens provenance/path validation and expands secret-scanning coverage over excerpts and inputs. |
| src/workflow/adapter.rs | Enforces compile-time redaction of protocol error payloads and tightens adapter error handling. |
| src/validate/report.rs | Ensures report generation fails closed rather than implying validity on serialization fallback paths. |
| src/trace/walker.rs | Prevents element ID collisions for uuid-less containers and adds regression tests. |
| src/trace/mod.rs | Fails closed on unknown staleness and rejects FIFO inputs without blocking, with expanded tests. |
| src/suggest/shared.rs | Centralizes bidi/control-character detection and applies stricter single-line sanitization with tests. |
| src/suggest/run_record.rs | Adds validation-boundary secret scanning for persisted run record fields and expands tests. |
| src/suggest/request.rs | Adds validation-boundary secret scanning for persisted request fields and expands tests. |
| src/suggest/redact.rs | Adjusts redaction hashing to reduce oracle risk and updates expectations/tests accordingly. |
| src/suggest/promotion.rs | Strengthens alias/collision detection using consistent Unicode lowercasing semantics across artifacts. |
| src/suggest/prepare.rs | Updates suggest prepare logic/tests to match the revised redaction hash behavior. |
| src/suggest/confinement.rs | Hardens confinement execution checks (identity/fingerprint/TOCTOU mitigations) and expands sandbox/deny rules with tests. |
| src/sanitize.rs | Expands sanitization to strip broader Unicode control ranges (including C1) and updates tests. |
| src/round_trip/comparator.rs | Fixes soft-wrap normalization edge cases (e.g., first-line headings) and adds coverage. |
| src/review/queue_v3_codec_tests.rs | Updates review codec tests to enforce non-latching behavior on invalid capacity-related inputs. |
| src/review/operational_v3_codec_tests.rs | Adjusts operational codec tests for reclassified invalid/capacity overage handling. |
| src/review/edit_finalize.rs | Fixes an empty-slice pointer equality pitfall and adds a regression test. |
| src/review/edit_codec_tests.rs | Adds regression coverage ensuring oversized rationale/inputs do not latch state incorrectly. |
| src/review/decode_v4_operational.rs | Reclassifies certain capacity conversions/overflows as Invalid (non-latching) in v4 operational decoding. |
| src/review/decode_v3.rs | Reclassifies derived graph/seat cap issues as Invalid (non-latching) in v3 decoding. |
| src/review/decode_v3_operational.rs | Reclassifies certain capacity conversions/overflows as Invalid (non-latching) in v3 operational decoding. |
| src/reuse/report.rs | Validates before rendering, rejects duplicate inputs, and ensures rendering does not emit parse-invalid documents (with tests). |
| src/reuse/corpus.rs | Hardens corpus validation (path distinctness via Unicode lowercasing, supersedes cycle rejection) with tests. |
| src/policy/render.rs | Fixes link destination parsing for balanced-paren/angle-bracket destinations and adds tests. |
| src/policy/manifest.rs | Broadens sensitive-parameter detection and normalizes path keys/dot-components with tests. |
| src/poam/workflow.rs | Refuses percent-encoded traversal/control sequences in evidence hrefs and adds tests. |
| src/poam/report.rs | Escapes additional fields in text output to reduce terminal injection risk and updates tests. |
| src/poam/manifest.rs | Expands Windows device-name rejection rules (e.g., CONIN$/CONOUT$) and adds tests. |
| src/poam/assessment_epochs.rs | Updates POA&M assessment epoch handling/tests to the current assessment plan builder API. |
| src/pipeline.rs | Threads timestamp override through assessment plan generation call sites. |
| src/parse/clauses.rs | Normalizes ragged GFM table rows to header width and adds regression tests. |
| src/parameter/mod.rs | Prevents duplicate parameter IDs across runs by re-registering extracted IDs and updates tests. |
| src/parameter/matchers.rs | Fixes matcher semantics (e.g., “within” handling) and edge-case numeric parsing with tests. |
| src/oscal/profile.rs | Improves determinism/validation (canonical ordering; stricter control ID parsing) with tests. |
| src/oscal/implemented_requirements.rs | Emits trace links only when link construction succeeds to avoid producing invalid references. |
| src/oscal/catalog.rs | Ensures generated group IDs are NCName-safe (e.g., not leading with digits) and adjusts tests. |
| src/oscal/back_matter.rs | Avoids logging raw URLs that may contain secrets/control characters. |
| src/migration/successor.rs | Avoids FIFO open blocking and tightens validation around approval evidence/control characters with tests. |
| src/mcp/stdio_tests.rs | Fixes test setup clock sharing to improve stability/reproducibility. |
| src/mcp/recorded_v2.rs | Binds precharged work to emitted bytes via a hash check to prevent mismatches. |
| src/mapping/mod.rs | Hardens mapping generation to render-before-write, fail closed on unverifiable identity platforms, and improves identity validation with tests. |
| src/mapping/manifest.rs | Clarifies fingerprint digest coverage semantics in documentation comments. |
| src/mapping/inventory.rs | Expands digest domain separation and rejects ambiguous/duplicate part IDs, updating tests accordingly. |
| src/mapping/baseline.rs | Requires raw-sha256 evidence properties, deduplicates identical findings, and expands tests. |
| src/linkage/fresh.rs | Rechecks absence at read time and clamps u64→usize safely for portability, with tests. |
| src/lifecycle/record.rs | Tightens legacy-evidence window rules and makes artifact path-shape validation portable, with tests. |
| src/lifecycle/mod.rs | Centralizes artifact path-shape validation and fails closed on metadata errors, expanding tests. |
| src/json_strict.rs | Improves duplicate-key error reporting by stripping serde positional suffixes and updates tests. |
| src/framework/manifest.rs | Exports shared JSON path validation and uses Unicode lowercasing for path keys. |
| src/export/xml_serializer.rs | Bounds nesting depth, skips empty optional descriptions, refuses empty required markup, and adds tests. |
| src/evidence_capture.rs | Strengthens prefix folding/alias handling using Unicode lowercasing and adjusts tests. |
| src/diff/formatter.rs | Escapes quotes/backslashes/control chars for safe one-line output and adds tests. |
| src/diff/extractor.rs | Improves diff extraction to include control enhancements and adds coverage. |
| src/config.rs | Reads config through a capped reader to reduce TOCTOU size races and updates tests. |
| src/cli/validate.rs | Bounds round-trip output reads similarly to input reads and adds tests. |
| src/cli/trace.rs | Sanitizes source excerpts to reduce terminal injection risk and adds tests. |
| src/citation.rs | Tightens bibliographic regex parsing (e.g., exclude sentence-final punctuation) and adds tests. |
| src/batch/output_naming.rs | Treats dangling symlinks/unknown metadata errors as taken to prevent overwrites, with tests. |
| src/batch/formatter.rs | Sanitizes bidi/zero-width formatting characters in terminal output and adds tests. |
| src/authoring/plan_admitted.rs | Ensures domain failures cross the correct stage checkpoint fence (fail-closed behavior). |
| src/authoring/manifest.rs | Uses Unicode lowercasing for path-key distinctness on case-insensitive filesystems. |
| src/authoring/handoff.rs | Introduces typed approval policy handling to avoid silent default governance bypass and adds tests. |
| src/assessment_results/mod.rs | Avoids re-reading scaffolded artifacts unverified and returns parsed values alongside manifest data. |
| src/assessment_results/context_captured.rs | Updates context-captured assessment results/test expectations to the current assessment plan builder API. |
| src/applicability/mod.rs | Verifies input fingerprints immediately before emitting applicability reports and gating decisions. |
| src/applicability/manifest.rs | Reuses shared JSON path validation and hardens framework artifact path rules with tests. |
| specs/043-diff-report/contracts/diff.rs | Updates diff report contract documentation to match shipped extractor and type behavior. |
| specs/041-assessment-plan-controls/contracts/assessment_plan.rs | Updates assessment plan controls contracts to reflect shipped include-controls and timestamp override behavior. |
| specs/040-batch-conversion/contracts/batch.rs | Expands batch conversion contract docs around collision rules and on-disk checks to match implementation. |
| specs/034-prd-parameter-extraction/contracts/parameter_types.rs | Clarifies parameter extraction contract semantics (e.g., “within” interpretation) to match shipped behavior. |
| specs/029-export-subcommand/contracts/export.rs | Clarifies export subcommand contract limitations and data-loss avoidance strategy in documentation. |
| specs/023-error-handling/contracts/input_validation.rs | Clarifies input validation contract behavior and documents implemented hostile-doc protections. |
| specs/021-prd-golden-file-tests/contracts/golden_file_api.rs | Documents the shipped golden-file API behavior (including recursive control ID collection). |
| specs/020-prd-validation-error-reporting/contracts/validation_api.rs | Replaces placeholder signatures with references aligned to the shipped validation API. |
| specs/019-schema-validation/contracts/validate-api.rs | Expands schema validation contract documentation and ValidationResult fields to match implementation. |
| specs/014-component-definition-structure/contracts/component_definition.rs | Updates component definition contract docs to reflect current types and skip-empty serialization behavior. |
| specs/013-catalog-pipeline/contracts/pipeline.rs | Refreshes pipeline contract documentation to reflect shipped API and stage outputs. |
| specs/012-back-matter/contracts/back_matter.rs | Removes redeclared types and points contracts to canonical model usage. |
| specs/011-oscal-metadata/contracts/oscal-metadata.rs | Updates OSCAL metadata contract docs for shipped serialization/validation constraints. |
| specs/008-citation-extraction/contracts/citation_extraction.rs | Documents shipped citation extraction semantics including per-occurrence citation ID seeding. |
| specs/003-structural-extraction-headings/contracts/extract_sections.rs | Updates heading extraction contract documentation to reflect frontmatter-aware parsing and line tracking. |
| scripts/workspace_client.py | Hardens client error decoding, operation_id validation, and shutdown cleanup behavior. |
| scripts/tests/test_registry_self_path.py | Adds regression tests for registry self-path validation behavior. |
| scripts/test_generate_sbom.py | Adds/updates SBOM generation tests (SPDX expressions, serial binding, lock-row freshness enforcement). |
| scripts/test_dependency_inventory.py | Expands dependency inventory tests to reject proposal-style rationales and non-finite TOML numbers. |
| scripts/registry_self_path.py | Adds a standalone validator utility for safe registry self paths to prevent authority injection. |
| scripts/generate_sbom.py | Hardens SBOM generation by binding serial inputs/digests, validating lock rows, and supporting SPDX expressions. |
| scripts/fetch-oscal-catalogs.sh | Restricts downloads to HTTPS and validates registry self paths before fetching. |
| scripts/dependency_inventory.py | Tightens exception/rationale validation to ensure proposals are not treated as approvals. |
| scripts/dependency_common.py | Refuses non-finite TOML numbers to align with finite-number JSON contract expectations. |
| scripts/check_roadmap_ledger.py | Hardens evidence path validation/encoding handling and detects duplicate requirement IDs. |
| schemas/forge.suggest-request-1.schema.json | Tightens schema constraints (e.g., bidi restrictions) and clarifies invariants in comments. |
| schemas/forge.review-dispositions-4.schema.json | Aligns schema enum values by removing an invalid/unsupported disposition. |
| examples/authoring/project.json | Refreshes example pins/digests to match regenerated artifacts and updated digest domains. |
| examples/authoring/pack.json | Refreshes example pins/digests to match regenerated artifacts and updated digest domains. |
| examples/authoring/gap-report.json | Updates example manifest digest to match regenerated output. |
| examples/authoring/applicability.json | Updates example fingerprint_digest to match expanded digest domain separation. |
| ci/integration-test.sh | Replaces brittle grep parsing with JSON-walking logic for more robust integration checks. |
| benches/pipeline_benchmark.rs | Aligns benchmark enrichment steps with the production pipeline stages. |
| .specify/scripts/bash/update-agent-context.sh | Fixes unsafe eval usage and improves escaping/portability and failure handling in bash utilities. |
| .specify/scripts/bash/setup-plan.sh | Removes unsafe eval patterns and preserves correct exit status propagation in setup scripting. |
| .specify/scripts/bash/create-new-feature.sh | Validates numeric arguments and improves branch scanning for multi-digit feature prefixes. |
| .specify/scripts/bash/configure-worktree.sh | Hardens argument interactions and jq failure behavior, refusing unsafe rewrites and improving escaping. |
| .specify/scripts/bash/common.sh | Fails closed on ambiguous spec directory matches and preserves resolver/jq exit-status semantics. |
| .specify/scripts/bash/check-prerequisites.sh | Removes unsafe eval patterns and preserves correct exit status propagation in prerequisite checks. |
| .github/workflows/release.yml | Pins/sets the Rust toolchain explicitly for dtolnay/rust-toolchain steps in the release workflow. |
| .gemini/commands/speckit.taskstoissues.toml | Clarifies shell-injection defenses and untrusted-argument handling guidance for speckit commands. |
| .gemini/commands/speckit.tasks.toml | Clarifies shell-injection defenses and untrusted-argument handling guidance for speckit commands. |
| .gemini/commands/speckit.specify.toml | Tightens command guidance for safer branch listing and argument handling. |
| .gemini/commands/speckit.security.toml | Clarifies shell-injection defenses and untrusted-argument handling guidance for security-focused speckit commands. |
| .gemini/commands/speckit.prd.toml | Tightens command guidance for safer branch listing and argument handling in PRD workflows. |
| .gemini/commands/speckit.plan.toml | Clarifies shell-injection defenses and untrusted-argument handling guidance for planning workflows. |
| .gemini/commands/speckit.implement.toml | Clarifies shell-injection defenses and untrusted-argument handling guidance for implementation workflows. |
| .gemini/commands/speckit.constitution.toml | Corrects constitution/template path guidance and clarifies dependent artifact scan locations. |
| .gemini/commands/speckit.clarify.toml | Clarifies shell-injection defenses and untrusted-argument handling guidance for clarify workflows. |
| .gemini/commands/speckit.checklist.toml | Clarifies shell-injection defenses and checklist file creation semantics to avoid overwrites. |
| .gemini/commands/speckit.architecture.toml | Clarifies shell-injection defenses and untrusted-argument handling guidance for architecture workflows. |
| .gemini/commands/speckit.analyze.toml | Adds explicit untrusted-content boundary guidance and ensures severity sorting guidance before applying caps. |
Review effort: Balanced
| // Re-verify identity immediately before spawn: a replacement between the | ||
| // hash check and exec must not slip past the fingerprint (hash-then-exec | ||
| // TOCTOU). Copying signed platform binaries breaks macOS code signatures, | ||
| // so the executable stays in place and its inode identity is pinned. | ||
| let identity = file_identity(&resolved)?; | ||
| if file_identity(&resolved)? != identity | ||
| || crate::hashing::sha256_hex(&crate::io::read_bounded( | ||
| &resolved, | ||
| crate::suggest::prepare::MAX_ADAPTER_BYTES, | ||
| )?) != expected_sha | ||
| { | ||
| return Err(shared::error( | ||
| "the adapter executable changed since it was fingerprinted; re-run prepare and consent again", | ||
| )); | ||
| } |
| /// Spawn the confined child in its own process group with piped output. | ||
| #[cfg(unix)] | ||
| /// Device/inode identity of the executable; a path replacement changes it. | ||
| #[cfg(unix)] | ||
| fn file_identity(path: &Path) -> Result<(u64, u64), ForgeError> { | ||
| use std::os::unix::fs::MetadataExt; | ||
| let metadata = std::fs::metadata(path)?; | ||
| Ok((metadata.dev(), metadata.ino())) | ||
| } |
| { | ||
| let path = registration.path.as_str(); | ||
| if paths.iter().any(|old| *old != path && old.eq_ignore_ascii_case(path)) { | ||
| if paths.iter().any(|old| *old != path && old.to_lowercase() == path.to_lowercase()) { |
| input[type=password] { width: 100%; } | ||
| button { background: var(--accent); color: white; border: 1px solid var(--accent); padding: 9px 18px; cursor: pointer; font-weight: 650; } | ||
| button:hover { background: #103f36; } | ||
| button:not([aria-disabled=true]):hover { background: #103f36; } |


Summary
Validate-first remediation of the automated code review (
docs/ocr-20261114, 1,577 findings). Every claim was checked against real code before fixing; false/stale claims were dropped with evidence; spec-contract drift was resolved doc-only where the implementation was already correct.Scope shipped
.specifyprerequisite scripts), 21 high, ~25 mediumDropped as false/stale (evidence in session notes): vendored OSCAL schema forks (no-fork rule), claims against already-correct code, historical evidence receipts with zero consumers.
Verification
cargo test: 4,686 passed, 0 failed (pre-commit hook re-ran--lockedgates at commit)cargo clippy --locked --all-targets -- -D warnings: 0test_dependency_inventory,test_generate_sbomfixtures,tests/test_registry_self_path): OKbash -n/node --checkclean on all touched scripts/driversexamples/component-based/output/ssp.jsonpassesforge validate(previous committed artifact had 61 validation errors)Known follow-ups (not in this PR)
release.ymlsecurity edit invalidated the dependency-graph pin;CommittedStoreTestsfails closed until a revieweddependency_graph.py refresh.hyper/quick-xml/serde_jsonpending owner approval (fail-closed by design).Raw review artifacts (
docs/ocr-20261114/, 61 MB) are intentionally not committed.