1
0
Fork 0
mirror of https://github.com/imjasonh/rustvulncheck synced 2026-07-06 19:02:25 +00:00
rustvulncheck/Cargo.toml
Claude 6740de1687
Add AST-based symbol extraction using syn, with regex fallback
Instead of regex-matching unified diff lines, the enrichment pipeline
now fetches the full before/after file contents from GitHub, parses
them with syn::parse_file, walks the AST to extract all fn items with
their fully-qualified paths (including impl block context), and diffs
the two symbol sets to classify Added/Modified/Deleted.

This eliminates entire classes of regex bugs:
- impl Trait for Type: syn's ItemImpl has separate trait_ and self_ty
  fields, so the implementing type is always correct
- where clauses: parsed into generics.where_clause, never in the type
- nested generics: syn handles all nesting correctly
- #[cfg(test)] modules: checked via attributes, not path heuristics
- Duplicate symbols: set-based diffing produces each symbol exactly once

Falls back to regex per-file when:
- AST parsing fails (syntax errors, macro-heavy files)
- File contents can't be fetched (missing metadata, API errors)
- File didn't exist at either ref (handled as all-Added or all-Deleted)

New files:
- src/ast_differ.rs: AST visitor + symbol set diffing (8 tests)

Changes:
- src/github.rs: Added parent_sha, owner, repo to PatchDiff;
  added fetch_file_contents() for raw file retrieval
- src/diff_analyzer.rs: extract_symbols() now tries AST first;
  regex path renamed to extract_symbols_regex()
- Cargo.toml: Added quote dependency for token stream hashing

https://claude.ai/code/session_01P1LKP6aqGt68rQAXrF6kSE
2026-03-25 15:49:20 +00:00

21 lines
452 B
TOML

[package]
name = "cargo-deep-audit"
version = "0.1.0"
edition = "2021"
[dependencies]
clap = { version = "4", features = ["derive", "env"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
toml = "0.8"
reqwest = { version = "0.12", features = ["blocking", "json"] }
regex = "1"
git2 = "0.19"
walkdir = "2"
anyhow = "1"
semver = "1"
syn = { version = "2", features = ["full", "visit"] }
quote = "1"
[dev-dependencies]
tempfile = "3"