mirror of
https://github.com/imjasonh/rustvulncheck
synced 2026-07-16 20:43:49 +00:00
fix: skip timestamp update when enrichment produces no actual data changes
Previously, re-enrichment and incomplete entry retries would increment change counters even when the resulting data was identical, causing update_timestamp() to fire and produce commits with only a timestamp diff. Now we compare old vs new symbols/SHAs before counting a change, so the timestamp (and thus the commit) is only produced when data actually differs. https://claude.ai/code/session_01CR3Wstpf1J7Pkbyx8xoCWm
This commit is contained in:
parent
adfad63547
commit
852502923c
2 changed files with 15 additions and 7 deletions
|
|
@ -10,7 +10,7 @@ use std::collections::HashMap;
|
|||
use crate::github::PatchDiff;
|
||||
|
||||
/// A vulnerable symbol extracted from a patch diff.
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
pub struct VulnerableSymbol {
|
||||
/// The file path in the repository
|
||||
pub file: String,
|
||||
|
|
|
|||
20
src/main.rs
20
src/main.rs
|
|
@ -262,7 +262,6 @@ fn run_enrich(args: EnrichArgs) -> Result<()> {
|
|||
|
||||
if !fetched {
|
||||
println!(" Could not fetch any diff, keeping existing entry unchanged");
|
||||
re_enriched_count += 1;
|
||||
println!();
|
||||
continue;
|
||||
}
|
||||
|
|
@ -280,11 +279,15 @@ fn run_enrich(args: EnrichArgs) -> Result<()> {
|
|||
println!(" - {} ({:?})", sym.function, sym.change_type);
|
||||
}
|
||||
|
||||
// Update the entry in-place
|
||||
// Only count as re-enriched if data actually changed
|
||||
let entry_mut = &mut vuln_db.entries[idx];
|
||||
entry_mut.commit_sha = new_sha;
|
||||
entry_mut.vulnerable_symbols = new_symbols;
|
||||
re_enriched_count += 1;
|
||||
let sha_changed = entry_mut.commit_sha != new_sha;
|
||||
let symbols_changed = entry_mut.vulnerable_symbols != new_symbols;
|
||||
if sha_changed || symbols_changed {
|
||||
entry_mut.commit_sha = new_sha;
|
||||
entry_mut.vulnerable_symbols = new_symbols;
|
||||
re_enriched_count += 1;
|
||||
}
|
||||
println!();
|
||||
}
|
||||
}
|
||||
|
|
@ -425,8 +428,13 @@ fn run_enrich(args: EnrichArgs) -> Result<()> {
|
|||
.iter_mut()
|
||||
.find(|e| e.advisory_id == adv.id)
|
||||
{
|
||||
let changed = existing.commit_sha != entry.commit_sha
|
||||
|| existing.vulnerable_symbols != entry.vulnerable_symbols;
|
||||
existing.commit_sha = entry.commit_sha;
|
||||
existing.vulnerable_symbols = entry.vulnerable_symbols;
|
||||
if changed {
|
||||
new_count += 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
println!(" Could not fetch any diff, keeping existing entry unchanged");
|
||||
|
|
@ -435,8 +443,8 @@ fn run_enrich(args: EnrichArgs) -> Result<()> {
|
|||
// New entry: always add to DB (even without symbols) so it's tracked.
|
||||
// It will be retried via the incomplete-entry path on future runs.
|
||||
vuln_db.entries.push(entry);
|
||||
new_count += 1;
|
||||
}
|
||||
new_count += 1;
|
||||
println!();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue