Skip to content

Commit a9bc23f

Browse files
committed
Java: Add threat model configuration related extensible predicates and some initial tuples.
1 parent 2b74144 commit a9bc23f

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
extensions:
2+
3+
- addsTo:
4+
pack: codeql/java-all
5+
extensible: supportedThreatModels
6+
data:
7+
- ["default"] # The "default" threat model is always included.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
extensions:
2+
3+
- addsTo:
4+
pack: codeql/java-all
5+
extensible: threatModelGrouping
6+
data:
7+
# Default threat model
8+
- ["remote", "default"]
9+
- ["uri-path", "default"]
10+
11+
# Android threat models
12+
- ["android-widget", "android"]
13+
- ["android-external-storage-dir", "android"]
14+
- ["contentprovider", "android"]
15+
- ["android-external-storage-dir", "android"]
16+
17+
# Remote threat models
18+
- ["request", "remote"]
19+
- ["response", "remote"]
20+
21+
# Local threat models
22+
- ["database", "local"]
23+
- ["cli", "local"]
24+
- ["environment", "local"]
25+
- ["file", "local"]

java/ql/lib/qlpack.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ dataExtensions:
1515
- ext/*.model.yml
1616
- ext/generated/*.model.yml
1717
- ext/experimental/*.model.yml
18+
- ext/threatmodels/*.model.yml
1819
warnOnImplicitThis: true
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* INTERNAL use only. This is an experimental API subject to change without notice.
3+
*
4+
* This module provides extensible predicates for configuring which kinds of MaD models
5+
* are applicable to generic queries.
6+
*/
7+
8+
private import ExternalFlowExtensions
9+
10+
/**
11+
* Holds if the specified kind of source model is supported for the current query.
12+
*/
13+
extensible private predicate supportedThreatModels(string kind);
14+
15+
/**
16+
* Holds if the specified kind of source model is containted within the specified group.
17+
*/
18+
extensible private predicate threatModelGrouping(string kind, string group);
19+
20+
/**
21+
* Gets the threat models that are direct descendants of the specified kind/group.
22+
*/
23+
private string getChildThreatModel(string group) { threatModelGrouping(result, group) }
24+
25+
/**
26+
* Holds if the source model kind `kind` is relevant for generic queries
27+
* under the current threat model configuration.
28+
*/
29+
predicate sourceModelKindConfig(string kind) {
30+
exists(string group | supportedThreatModels(group) and kind = getChildThreatModel*(group))
31+
}

0 commit comments

Comments
 (0)