Skip to content

Commit ed380dc

Browse files
committed
Rust: Add some new taint metrics to rust/summary/summary-statistics.
1 parent 437771f commit ed380dc

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

rust/ql/src/queries/summary/Stats.qll

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,17 @@ int getTaintEdgesCount() {
104104
*/
105105
int getQuerySinksCount() { result = count(QuerySink s) }
106106

107+
/**
108+
* Holds if there are at least 10 data flow nodes in the same location
109+
* as `n`.
110+
*/
111+
private predicate isColocated10(DataFlow::Node n) {
112+
exists(Location l |
113+
l = n.getLocation() and
114+
strictcount(DataFlow::Node other | other.getLocation() = l) >= 10
115+
)
116+
}
117+
107118
class CrateElement extends Element {
108119
CrateElement() {
109120
this instanceof Crate or
@@ -131,7 +142,9 @@ predicate extractionStats(string key, int value) {
131142
key = "Extraction warnings" and
132143
value = count(ExtractionWarning w | not exists(w.getLocation()) or w.getLocation().fromSource())
133144
or
134-
key = "Files extracted - total" and value = count(ExtractedFile f | exists(f.getRelativePath()))
145+
key = "Files extracted - total" and value = count(File f)
146+
or
147+
key = "Files extracted - total user" and value = count(ExtractedFile f | exists(f.getRelativePath()))
135148
or
136149
key = "Files extracted - with errors" and
137150
value =
@@ -201,6 +214,8 @@ predicate taintStats(string key, int value) {
201214
or
202215
key = "Taint reach - per million nodes" and value = getTaintReach().floor()
203216
or
217+
key = "Taint nodes - highly colocated nodes" and value = count(DataFlow::Node n | isColocated10(n))
218+
or
204219
key = "Taint sinks - query sinks" and value = getQuerySinksCount()
205220
or
206221
key = "Taint sinks - cryptographic operations" and

0 commit comments

Comments
 (0)