Skip to content

Commit c6a7be6

Browse files
committed
Rust: Add both totals to rust/summary/summary-statistics.
1 parent 75f0a7f commit c6a7be6

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

rust/ql/src/queries/summary/QuerySinks.ql

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,7 @@
1111

1212
import rust
1313
import codeql.rust.dataflow.DataFlow
14-
import codeql.rust.security.SqlInjectionExtensions
1514
import Stats
1615

17-
/**
18-
* Gets a kind of query for which `n` is a sink (if any).
19-
*/
20-
string getAQuerySinkKind(DataFlow::Node n) {
21-
(n instanceof SqlInjection::Sink and result = "SqlInjection")
22-
}
23-
2416
from DataFlow::Node n
2517
select n, "sink for " + strictconcat(getAQuerySinkKind(n), ", ")

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
*/
44

55
import rust
6+
private import codeql.rust.dataflow.DataFlow
67
private import codeql.rust.dataflow.internal.DataFlowImpl
78
private import codeql.rust.dataflow.internal.TaintTrackingImpl
89
private import codeql.rust.AstConsistency as AstConsistency
910
private import codeql.rust.controlflow.internal.CfgConsistency as CfgConsistency
1011
private import codeql.rust.dataflow.internal.DataFlowConsistency as DataFlowConsistency
12+
private import codeql.rust.security.SqlInjectionExtensions
1113

1214
/**
1315
* Gets a count of the total number of lines of code in the database.
@@ -41,3 +43,15 @@ int getTotalCfgInconsistencies() {
4143
int getTotalDataFlowInconsistencies() {
4244
result = sum(string type | | DataFlowConsistency::getInconsistencyCounts(type))
4345
}
46+
47+
/**
48+
* Gets a kind of query for which `n` is a sink (if any).
49+
*/
50+
string getAQuerySinkKind(DataFlow::Node n) {
51+
(n instanceof SqlInjection::Sink and result = "SqlInjection")
52+
}
53+
54+
/**
55+
* Gets a count of the total number of query sinks in the database.
56+
*/
57+
int getQuerySinksCount() { result = count(DataFlow::Node n | exists(getAQuerySinkKind(n)) | n) }

rust/ql/src/queries/summary/SummaryStats.ql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import rust
1010
import codeql.rust.Concepts
1111
import codeql.rust.security.SensitiveData
12+
import codeql.rust.security.WeakSensitiveDataHashingExtensions
1213
import codeql.rust.Diagnostics
1314
import Stats
1415

@@ -59,4 +60,9 @@ where
5960
key = "Taint sources - active" and value = count(ActiveThreatModelSource s)
6061
or
6162
key = "Sensitive data" and value = count(SensitiveData d)
63+
or
64+
key = "Taint sinks - query sinks" and value = getQuerySinksCount()
65+
or
66+
key = "Taint sinks - cryptographic operations" and
67+
value = count(Cryptography::CryptographicOperation o)
6268
select key, value order by key

rust/ql/test/query-tests/diagnostics/SummaryStats.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@
1515
| Macro calls - total | 9 |
1616
| Macro calls - unresolved | 1 |
1717
| Sensitive data | 0 |
18+
| Taint sinks - cryptographic operations | 0 |
19+
| Taint sinks - query sinks | 0 |
1820
| Taint sources - active | 0 |
1921
| Taint sources - total | 0 |

0 commit comments

Comments
 (0)