Skip to content

Name invalid Security review reports instead of generic failure - #2301

Merged
JacobStephens2 merged 5 commits into
mainfrom
issue-2298
Nov 19, 2026
Merged

JacobStephens2 merged 5 commits into
mainfrom
issue-2298

Conversation

@JacobStephens2

@JacobStephens2 JacobStephens2 commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

Security review session
  write private report (pre-existing.json)
  end with final line
run_in
  load_report ── parse_report (per finding, document order)
  │                └─ InvalidReport: "private report is invalid:
  │                   unknown field `severity` at finding 1"
  │                   (field name + index only, never values)
  └─ progress::step(that reason) ──> Command log
Outcome::of
  InvalidReport ──> Incomplete(that reason) ──> hold / PR entry
  other errors  ──> generic "session failed, ended early or
                    omitted a valid final line" (unchanged)

Strict approach chosen: the parser still rejects severity/fix_size at a finding's top level (deny_unknown_fields structs remain the single schema source), and the Security review prompt now shows a complete example object with both fields inside proof_of_concept. Validation errors from OldFinding::reproduction now name the field too (empty `title`, non-positive `head_exit_code`, invalid `severity`/`fix_size`), as do type errors and misplaced-field errors even when proof_of_concept comes first in the object.

Evidence

Execution evidence

  • Before: cargo test --bin thirdshift security::review::tests::probe_top_level_severity_repro -- --nocapture (probe since removed, replaced by kept regression tests) on the unpatched tree:

    parse error: unknown field `severity`, expected one of `fingerprint`, `title`, `description`, `proof_of_concept` at line 1 column 63
    outcome hold: Security review incomplete: session failed, ended early or omitted a valid final line; see Session trace
    test ... FAILED (bug: outcome hides real cause)
    

    After: cargo test --bin thirdshift security::review::tests — 7 passed, including top_level_severity_names_the_offending_field_in_the_outcome asserting the hold is exactly Security review's private report is invalid: unknown field severity at finding 1, plus the three reviewer-supplied tests in the second commit (poc_first_top_level_severity_is_named_unknown, type_error_names_offending_field, empty_title_validation_names_title_field), each verified failing before its fix and passing after.

  • cargo test --bin thirdshift security:: — 51 passed. cargo test --bin thirdshift prompt:: — 18 passed. cargo test prompts_page — passed after UPDATE_PROMPTS=1 cargo test prompts_page regenerated prompts/*.md and site/prompts/index.html.

  • python3 scripts/affected-tests refs/remotes/origin/main — all selected checks passed (full cargo suite, doctests, integration tests, site tests), after npm ci --prefix site installed the site's declared dependencies.

Merge Danger

Door: two-way

Blast Radius: narrow

Only Security review report handling and its prompt change. Invalid reports now fail with a named, public-safe reason (field name and finding index, never field values — a test asserts the fingerprint does not leak) instead of the generic final-line message; valid reports, final-line handling, and recording are unchanged.

Unaddressed findings

Standards

  • J1 — Duplicated Code: hand-rolled JSON tokenizer (split_array_elements, src/security/review.rs). Declined. The reviewer suggested enumerating the parsed serde_json::Value array instead, but this crate does not enable serde_json's preserve_order feature, so Value objects iterate keys in sorted order: the same probe that names `severity` from the raw slice named `fix_size` when deserialized via Value (observed in this session before the raw-slice parser was kept). Document-order naming of the first offending field — the field agy actually misplaced first — therefore needs the raw element slices; the tokenizer is small, string/nesting-aware, and covered by the kept tests in src/security/review/tests.rs.
  • J2 — fragile string coupling (partly addressed). The reproduction() prefix-stripping coupling was removed in the second commit: OldFinding::reproduction now bails with short field-naming causes and load_report adds the finding index directly, so that magic prefix no longer exists. The remaining piece, extracting the field name from serde_json::Error's Display text in serde_field_name (src/security/review.rs), is declined: serde_json exposes no structured field-name accessor, and on any wording change the code degrades safely to the generic invalid field type at finding N rather than leaking report values.

Spec

None. Both Spec findings were run as written, failed as described, and were fixed with their tests kept.

Security

None. One introduced Security finding — serde_field_name and type_mismatch_field in src/security/review.rs reflecting arbitrary unvalidated JSON keys from a malformed private report into public InvalidReport outcomes (allowing private key-text disclosure and <!-- /thirdshift:security-review --> PR section injection) — was reproduced by a failing proof-of-concept test (cargo test --test security_review invalid_private_report_does_not_reflect_arbitrary_keys_or_inject_pr_markers -- --nocapture) before the fix and fixed in commit ea52b33a by restricting reflected field names to the closed schema allowlist (known_schema_field). Its regression tests (arbitrary_unknown_keys_and_type_mismatch_fallbacks_never_leak_key_names in src/security/review/tests.rs and invalid_private_report_does_not_reflect_arbitrary_keys_or_inject_pr_markers in tests/security_review.rs) were kept and pass after the fix.

Security review outcome

No unaddressed introduced findings.

Review coverage

Changed files the review intentionally did not read as generated output (reviewed via their source src/prompt.rs and the regeneration check UPDATE_PROMPTS=1 cargo test prompts_page): prompts/pull-request-security-review.md, prompts/security-review.md, prompts/spec-ticket-security-review.md, site/prompts/index.html. No other changed file was left unread. Full reports: .thirdshift-review-O8O81O/standards.md and .thirdshift-review-O8O81O/spec.md in the session record (Standards: 2 judgement calls; Spec: 2 findings, both addressed).

Closes #2298

Built with muse Muse Code 1.4.24 (1.4.24-R9131.1) · default model · default effort

@JacobStephens2
JacobStephens2 merged commit 3c6e094 into main Nov 19, 2026
25 checks passed
@JacobStephens2
JacobStephens2 deleted the issue-2298 branch November 19, 2026 13:17
@JacobStephens2 JacobStephens2 mentioned this pull request Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security review: a misplaced field in the private report fails as 'omitted a valid final line' (agy)

1 participant