Skip to content

Commit adeef30

Browse files
committed
Swift: Add some queries to help examine databases.
1 parent 643cfce commit adeef30

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @name Flow Sources
3+
* @description List all flow sources found in the database. Flow sources
4+
* indicate data that originates from an untrusted source, such
5+
* as as untrusted remote data.
6+
* @kind table
7+
* @id swift/summary/flow-sources
8+
*/
9+
10+
import swift
11+
import codeql.swift.dataflow.FlowSources
12+
13+
from RemoteFlowSource s
14+
select s, "Flow source: " + s.getSourceType()
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @name Sensitive Expressions
3+
* @description List all sensitive expressions found in the database.
4+
* Sensitive expressions are expressions that have been
5+
* identified as potentially containing data that should not be
6+
* leaked to an attacker.
7+
* @kind table
8+
* @id swift/summary/sensitive-expressions
9+
*/
10+
11+
import swift
12+
import codeql.swift.security.SensitiveExprs
13+
14+
from SensitiveExpr e
15+
select e, "Sensitive expression: " + e.getSensitiveType()
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* @name Summary statistics
3+
* @description A table of summary statistics about a database. Includes
4+
* values that measure its size, and the numbers of certain
5+
* features interesting to analysis that have been found.
6+
* @kind table
7+
* @id swift/summary/summary-statistics
8+
*/
9+
10+
import swift
11+
import codeql.swift.dataflow.FlowSources
12+
import codeql.swift.security.SensitiveExprs
13+
14+
predicate statistic(string what, int value) {
15+
what = "Files" and value = count(File f)
16+
or
17+
what = "Expressions" and value = count(Expr e)
18+
or
19+
what = "Remote flow sources" and value = count(RemoteFlowSource s)
20+
or
21+
what = "Sensitive expressions" and value = count(SensitiveExpr e)
22+
}
23+
24+
from string what, int value
25+
where statistic(what, value)
26+
select what, value

0 commit comments

Comments
 (0)