Skip to content

Commit 3d025ea

Browse files
authored
Merge pull request #10903 from geoffw0/review
Swift: Add some summary queries.
2 parents 01a67ad + b59f01f commit 3d025ea

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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 problem
7+
* @problem.severity info
8+
* @id swift/summary/flow-sources
9+
* @tags summary
10+
*/
11+
12+
import swift
13+
import codeql.swift.dataflow.FlowSources
14+
15+
from RemoteFlowSource s
16+
select s, "Flow source: " + s.getSourceType()
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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 problem
8+
* @problem.severity info
9+
* @id swift/summary/sensitive-expressions
10+
* @tags summary
11+
*/
12+
13+
import swift
14+
import codeql.swift.security.SensitiveExprs
15+
16+
from SensitiveExpr e
17+
select e, "Sensitive expression: " + e.getSensitiveType()
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* @name Summary statistics
3+
* @description A table of summary statistics about a database.
4+
* @kind table
5+
* @id swift/summary/summary-statistics
6+
* @tags summary
7+
*/
8+
9+
import swift
10+
import codeql.swift.dataflow.FlowSources
11+
import codeql.swift.security.SensitiveExprs
12+
13+
predicate statistic(string what, int value) {
14+
what = "Files" and value = count(File f)
15+
or
16+
what = "Expressions" and value = count(Expr e | not e.getFile() instanceof UnknownFile)
17+
or
18+
what = "Remote flow sources" and value = count(RemoteFlowSource s)
19+
or
20+
what = "Sensitive expressions" and value = count(SensitiveExpr e)
21+
}
22+
23+
from string what, int value
24+
where statistic(what, value)
25+
select what, value

0 commit comments

Comments
 (0)