From ed380dc9bf97e6ce7e5a15844ad58931425edadf Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Wed, 12 Aug 2026 12:03:13 +0100 Subject: [PATCH 1/3] Rust: Add some new taint metrics to rust/summary/summary-statistics. --- rust/ql/src/queries/summary/Stats.qll | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/rust/ql/src/queries/summary/Stats.qll b/rust/ql/src/queries/summary/Stats.qll index 36eeb0df4ef4..1fedec62f934 100644 --- a/rust/ql/src/queries/summary/Stats.qll +++ b/rust/ql/src/queries/summary/Stats.qll @@ -104,6 +104,17 @@ int getTaintEdgesCount() { */ int getQuerySinksCount() { result = count(QuerySink s) } +/** + * Holds if there are at least 10 data flow nodes in the same location + * as `n`. + */ +private predicate isColocated10(DataFlow::Node n) { + exists(Location l | + l = n.getLocation() and + strictcount(DataFlow::Node other | other.getLocation() = l) >= 10 + ) +} + class CrateElement extends Element { CrateElement() { this instanceof Crate or @@ -131,7 +142,9 @@ predicate extractionStats(string key, int value) { key = "Extraction warnings" and value = count(ExtractionWarning w | not exists(w.getLocation()) or w.getLocation().fromSource()) or - key = "Files extracted - total" and value = count(ExtractedFile f | exists(f.getRelativePath())) + key = "Files extracted - total" and value = count(File f) + or + key = "Files extracted - total user" and value = count(ExtractedFile f | exists(f.getRelativePath())) or key = "Files extracted - with errors" and value = @@ -201,6 +214,8 @@ predicate taintStats(string key, int value) { or key = "Taint reach - per million nodes" and value = getTaintReach().floor() or + key = "Taint nodes - highly colocated nodes" and value = count(DataFlow::Node n | isColocated10(n)) + or key = "Taint sinks - query sinks" and value = getQuerySinksCount() or key = "Taint sinks - cryptographic operations" and From 74fa98011d346978c30ba38ca7e6b8bed817f64f Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Wed, 12 Aug 2026 16:43:50 +0100 Subject: [PATCH 2/3] Rust: Update the tests and exclude total files from rust/summary/reduced-summary-statistics. --- .../hello-workspace/summary.cargo.expected | 2 +- .../hello-workspace/summary.rust-project.expected | 2 +- rust/ql/src/queries/summary/Stats.qll | 9 +++++++-- rust/ql/src/queries/summary/SummaryStats.ql | 2 ++ .../query-tests/diagnostics/SummaryStatsReduced.expected | 2 +- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/rust/ql/integration-tests/hello-workspace/summary.cargo.expected b/rust/ql/integration-tests/hello-workspace/summary.cargo.expected index 11fba34f9019..85d2b9971712 100644 --- a/rust/ql/integration-tests/hello-workspace/summary.cargo.expected +++ b/rust/ql/integration-tests/hello-workspace/summary.cargo.expected @@ -1,6 +1,6 @@ | Extraction errors | 0 | | Extraction warnings | 0 | -| Files extracted - total | 4 | +| Files extracted - total user | 4 | | Files extracted - with errors | 0 | | Files extracted - without errors | 4 | | Files extracted - without errors % | 100 | diff --git a/rust/ql/integration-tests/hello-workspace/summary.rust-project.expected b/rust/ql/integration-tests/hello-workspace/summary.rust-project.expected index 11fba34f9019..85d2b9971712 100644 --- a/rust/ql/integration-tests/hello-workspace/summary.rust-project.expected +++ b/rust/ql/integration-tests/hello-workspace/summary.rust-project.expected @@ -1,6 +1,6 @@ | Extraction errors | 0 | | Extraction warnings | 0 | -| Files extracted - total | 4 | +| Files extracted - total user | 4 | | Files extracted - with errors | 0 | | Files extracted - without errors | 4 | | Files extracted - without errors % | 100 | diff --git a/rust/ql/src/queries/summary/Stats.qll b/rust/ql/src/queries/summary/Stats.qll index 1fedec62f934..0251efcb6bf6 100644 --- a/rust/ql/src/queries/summary/Stats.qll +++ b/rust/ql/src/queries/summary/Stats.qll @@ -142,8 +142,6 @@ predicate extractionStats(string key, int value) { key = "Extraction warnings" and value = count(ExtractionWarning w | not exists(w.getLocation()) or w.getLocation().fromSource()) or - key = "Files extracted - total" and value = count(File f) - or key = "Files extracted - total user" and value = count(ExtractedFile f | exists(f.getRelativePath())) or key = "Files extracted - with errors" and @@ -173,6 +171,13 @@ predicate extractionStats(string key, int value) { value = count(MacroCall mc | mc.fromSource() and not mc.hasMacroCallExpansion()) } +/** + * Gets further summary statistics about extraction. + */ +predicate extractionStatsExtra(string key, int value) { + key = "Files extracted - total" and value = count(File f) +} + /** * Gets summary statistics about inconsistencies. */ diff --git a/rust/ql/src/queries/summary/SummaryStats.ql b/rust/ql/src/queries/summary/SummaryStats.ql index 47a2c91a9eda..adfd302d0f8b 100644 --- a/rust/ql/src/queries/summary/SummaryStats.ql +++ b/rust/ql/src/queries/summary/SummaryStats.ql @@ -15,6 +15,8 @@ where or extractionStats(key, value) or + extractionStatsExtra(key, value) + or inconsistencyStats(key, value) or typeInferenceInconsistencyStats(key, value) diff --git a/rust/ql/test/query-tests/diagnostics/SummaryStatsReduced.expected b/rust/ql/test/query-tests/diagnostics/SummaryStatsReduced.expected index ed21d9772fce..7756215d1023 100644 --- a/rust/ql/test/query-tests/diagnostics/SummaryStatsReduced.expected +++ b/rust/ql/test/query-tests/diagnostics/SummaryStatsReduced.expected @@ -1,6 +1,6 @@ | Extraction errors | 0 | | Extraction warnings | 7 | -| Files extracted - total | 7 | +| Files extracted - total user | 7 | | Files extracted - with errors | 3 | | Files extracted - without errors | 4 | | Files extracted - without errors % | 57 | From df01db8ea01331a3cff151bbb6fa10e04f203382 Mon Sep 17 00:00:00 2001 From: Geoffrey White <40627776+geoffw0@users.noreply.github.com> Date: Wed, 12 Aug 2026 17:09:43 +0100 Subject: [PATCH 3/3] Rust: Autoformat. --- rust/ql/src/queries/summary/Stats.qll | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rust/ql/src/queries/summary/Stats.qll b/rust/ql/src/queries/summary/Stats.qll index 0251efcb6bf6..5e0169254486 100644 --- a/rust/ql/src/queries/summary/Stats.qll +++ b/rust/ql/src/queries/summary/Stats.qll @@ -142,7 +142,8 @@ predicate extractionStats(string key, int value) { key = "Extraction warnings" and value = count(ExtractionWarning w | not exists(w.getLocation()) or w.getLocation().fromSource()) or - key = "Files extracted - total user" and value = count(ExtractedFile f | exists(f.getRelativePath())) + key = "Files extracted - total user" and + value = count(ExtractedFile f | exists(f.getRelativePath())) or key = "Files extracted - with errors" and value = @@ -219,7 +220,8 @@ predicate taintStats(string key, int value) { or key = "Taint reach - per million nodes" and value = getTaintReach().floor() or - key = "Taint nodes - highly colocated nodes" and value = count(DataFlow::Node n | isColocated10(n)) + key = "Taint nodes - highly colocated nodes" and + value = count(DataFlow::Node n | isColocated10(n)) or key = "Taint sinks - query sinks" and value = getQuerySinksCount() or