Skip to content

feat(cyber): add evidence-gated code review - #3089

Draft
drk-ram wants to merge 1 commit into
xerj-org:mainfrom
drk-ram:feat/cyber-code-review-2771
Draft

drk-ram wants to merge 1 commit into
xerj-org:mainfrom
drk-ram:feat/cyber-code-review-2771

Conversation

@drk-ram

@drk-ram drk-ram commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

What this changes, and why

Add xerj_common::cyber_code_review for deterministic, evidence-gated taint-to-sink review. Built-in Rust, Python, TypeScript/JavaScript, Go, and SQL recipes can be extended with custom rules. Candidates are ranked by exact CWE/rule structure and token similarity, sanitizer or guard paths abstain, and every emitted finding requires an exact file/line location plus at least one pinned corpus vulnerability or fix citation. Unevidenced candidates are explicit abstentions rather than guesses. Reports seal validated RFC 8785 JSON with report_sha256.

Refs #2771, #2767, #2769

Audit: reviewed no-evidence behavior, source/sink and line invariants, deterministic ranking ties, sanitizer suppression, corpus pin checks, tamper detection, and seeded benchmark false-positive accounting. No network, repository mutation, persistence, or authorization behavior is introduced.

Evidence

cargo fmt -p xerj-common --check
PASS.
cargo clippy -p xerj-common --all-targets -- -D warnings -A clippy::chunks_exact_to_as_chunks
PASS.
cargo build --release -j 32 -p xerj-common
PASS: release profile completed in 31.30s.
cargo test -p xerj-common --lib cyber_code_review
PASS: 4 passed; 0 failed; 0 ignored; 389 filtered out; precision=1.0, recall=1.0, F1=1.0, false positives=0 in the seeded fixture.

Checks

  • cargo fmt --all (CI runs rustfmt --check and clippy -D warnings)
  • Scoped release build of the crates touched: cargo build --release -j 32 -p xerj-common
  • cargo test -p xerj-common passes (cargo check is not sufficient — targeted cyber_code_review coverage shown above)
  • ES-YAML conformance suite at 0 failed (cargo run --release -p es-yaml-runner -- --dir tests/es-compat-yaml/yaml) — N/A: no ES query/index behavior changed.
  • New ES-compatible behaviour has a matching YAML case under engine/tests/es-compat-yaml/yaml/ — N/A: no ES-compatible behavior added.
  • Docs updated if user-visible behaviour changed
  • For non-trivial changes: the applicable audit in docs/CONTRIBUTION_REVIEW.md
  • For non-trivial changes: operational audit — N/A: docs/cyber-code-review.md documents a library API, not an operational or runnable recipe; no artifact is extracted, installed, published, or served.

Not run: Full crate/workspace test suites and ES-YAML conformance were not run; the requested scoped module validation and release build are listed above. No recipe-runner or external corpus-fetch wiring is included.

Provenance

  • Written by: @drk-ram
  • Verified (commands run, output observed): exact fmt, clippy, release-build, and four-test module commands above; JCS tamper, no-evidence abstention, custom recipe, sanitizer, and seeded benchmark cases.
  • Assumed (not tested, and what would falsify it): callers resolve corpus files at the immutable pin and verify pinned source bytes; a mutable or mismatched resolver would falsify provenance. Recipe-runner integration remains outside this PR.

@cla-bot cla-bot Bot added the cla-signed label Nov 10, 2026
@drk-ram
drk-ram marked this pull request as draft November 15, 2026 19:59
@xerj-team

Copy link
Copy Markdown
Collaborator

Thank you @drk-ram, this is careful work and it is tied to a roadmap issue. Holding it for now: it adds a large new cyber-pack subsystem to xerj-common, and whether and in what order those pieces land is a product decision the maintainer will make, not a review-only call. CI also cannot run at the moment. Nothing is needed from you right now. We will come back here once that decision is made.

@drk-ram
drk-ram force-pushed the feat/cyber-code-review-2771 branch 4 times, most recently from 4d6ecbf to 55f6059 Compare November 21, 2026 20:47
@xerj-team

Copy link
Copy Markdown
Collaborator

Draft review: what blocks moving this out of draft.

Blocker: CodeReviewFinding and PriorVulnCitation duplicate #2968's CyberFinding (with scenario: CodeReview and location: SourceSpan) and its CorpusEvidenceRef. They are also weaker: PriorVulnCitation.fetched_at is only checked to be non-empty, while the shared schema requires YYYY-MM-DD or RFC 3339.

To un-draft: rebase on #2968 after it lands. Then emit CyberFinding values sealed by CyberFindingReport::finalize, and keep only the rules, ranking and abstention logic here.

Also, please describe evaluate_seeded_benchmark in the docs and CHANGELOG as a unit fixture. Precision, recall and F1 of 1.0 on four hand-built cases is not a benchmark result.

Local merge with main at 34a14c0d8: fmt clean, clippy -D warnings clean, cyber_code_review tests 4/4 passed. The module makes no network calls and executes no code.

Refs xerj-org#2771, xerj-org#2767, xerj-org#2769

Signed-off-by: Raghuvar Karthik Durga <177662415+drk-ram@users.noreply.github.com>
@drk-ram
drk-ram force-pushed the feat/cyber-code-review-2771 branch from 55f6059 to ec5976f Compare November 24, 2026 20:01

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants