Skip to content

Commit 5af1b36

Browse files
committed
Support data extensions
1 parent 6b9cab2 commit 5af1b36

File tree

13 files changed

+232
-1
lines changed

13 files changed

+232
-1
lines changed

config/identical-files.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,11 @@
537537
"ruby/ql/lib/codeql/ruby/frameworks/data/internal/ApiGraphModels.qll",
538538
"python/ql/lib/semmle/python/frameworks/data/internal/ApiGraphModels.qll"
539539
],
540+
"ApiGraphModelsExtensions": [
541+
"javascript/ql/lib/semmle/javascript/frameworks/data/internal/ApiGraphModelsExtensions.qll",
542+
"ruby/ql/lib/codeql/ruby/frameworks/data/internal/ApiGraphModelsExtensions.qll",
543+
"python/ql/lib/semmle/python/frameworks/data/internal/ApiGraphModelsExtensions.qll"
544+
],
540545
"TaintedFormatStringQuery Ruby/JS": [
541546
"javascript/ql/lib/semmle/javascript/security/dataflow/TaintedFormatStringQuery.qll",
542547
"ruby/ql/lib/codeql/ruby/security/TaintedFormatStringQuery.qll"

javascript/ql/lib/qlpack.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ library: true
77
upgrades: upgrades
88
dependencies:
99
codeql/regex: ${workspace}
10+
dataExtensions:
11+
- semmle/javascript/frameworks/**/model.yml

javascript/ql/lib/semmle/javascript/frameworks/data/internal/ApiGraphModels.qll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ private module API = Specific::API;
7272
private module DataFlow = Specific::DataFlow;
7373

7474
private import Specific::AccessPathSyntax
75+
private import ApiGraphModelsExtensions as Extensions
7576

7677
/** Module containing hooks for providing input data to be interpreted as a model. */
7778
module ModelInput {
@@ -236,6 +237,8 @@ predicate sourceModel(string type, string path, string kind) {
236237
row.splitAt(";", 1) = path and
237238
row.splitAt(";", 2) = kind
238239
)
240+
or
241+
Extensions::sourceModel(type, path, kind)
239242
}
240243

241244
/** Holds if a sink model exists for the given parameters. */
@@ -246,6 +249,8 @@ private predicate sinkModel(string type, string path, string kind) {
246249
row.splitAt(";", 1) = path and
247250
row.splitAt(";", 2) = kind
248251
)
252+
or
253+
Extensions::sinkModel(type, path, kind)
249254
}
250255

251256
/** Holds if a summary model `row` exists for the given parameters. */
@@ -258,6 +263,8 @@ private predicate summaryModel(string type, string path, string input, string ou
258263
row.splitAt(";", 3) = output and
259264
row.splitAt(";", 4) = kind
260265
)
266+
or
267+
Extensions::summaryModel(type, path, input, output, kind)
261268
}
262269

263270
/** Holds if a type model exists for the given parameters. */
@@ -268,6 +275,8 @@ private predicate typeModel(string type1, string type2, string path) {
268275
row.splitAt(";", 1) = type2 and
269276
row.splitAt(";", 2) = path
270277
)
278+
or
279+
Extensions::typeModel(type1, type2, path)
271280
}
272281

273282
/** Holds if a type variable model exists for the given parameters. */
@@ -277,6 +286,8 @@ private predicate typeVariableModel(string name, string path) {
277286
row.splitAt(";", 0) = name and
278287
row.splitAt(";", 1) = path
279288
)
289+
or
290+
Extensions::typeVariableModel(name, path)
280291
}
281292

282293
/**
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Defines extensible predicates for contributing library models from data extensions.
3+
*/
4+
5+
/**
6+
* Holds if the value at `(type, path)` should be seen as a flow
7+
* source of the given `kind`.
8+
*
9+
* The kind `remote` represents a general remote flow source.
10+
*/
11+
extensible predicate sourceModel(string type, string path, string kind);
12+
13+
/**
14+
* Holds if the value at `(type, path)` should be seen as a sink
15+
* of the given `kind`.
16+
*/
17+
extensible predicate sinkModel(string type, string path, string kind);
18+
19+
/**
20+
* Holds if calls to `(type, path)`, the value referred to by `input`
21+
* can flow to the value referred to by `output`.
22+
*
23+
* `kind` should be either `value` or `taint`, for value-preserving or taint-preserving steps,
24+
* respectively.
25+
*/
26+
extensible predicate summaryModel(string type, string path, string input, string output, string kind);
27+
28+
/**
29+
* Holds if `(type2, path)` should be seen as an instance of `type1`.
30+
*/
31+
extensible predicate typeModel(string type1, string type2, string path);
32+
33+
/**
34+
* Holds if `path` can be substituted for a token `TypeVar[name]`.
35+
*/
36+
extensible predicate typeVariableModel(string name, string path);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
extensions:
2+
# Contribute empty data sets to avoid errors about an undefined extensionals
3+
- addsTo:
4+
pack: codeql/javascript-all
5+
extensible: sourceModel
6+
data: []
7+
8+
- addsTo:
9+
pack: codeql/javascript-all
10+
extensible: sinkModel
11+
data: []
12+
13+
- addsTo:
14+
pack: codeql/javascript-all
15+
extensible: summaryModel
16+
data: []
17+
18+
- addsTo:
19+
pack: codeql/javascript-all
20+
extensible: typeModel
21+
data: []
22+
23+
- addsTo:
24+
pack: codeql/javascript-all
25+
extensible: typeVariableModel
26+
data: []

python/ql/lib/qlpack.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ extractor: python
66
library: true
77
upgrades: upgrades
88
dependencies:
9-
codeql/regex: ${workspace}
9+
codeql/regex: ${workspace}
10+
dataExtensions:
11+
- semmle/python/frameworks/**/model.yml

python/ql/lib/semmle/python/frameworks/data/internal/ApiGraphModels.qll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ private module API = Specific::API;
7272
private module DataFlow = Specific::DataFlow;
7373

7474
private import Specific::AccessPathSyntax
75+
private import ApiGraphModelsExtensions as Extensions
7576

7677
/** Module containing hooks for providing input data to be interpreted as a model. */
7778
module ModelInput {
@@ -236,6 +237,8 @@ predicate sourceModel(string type, string path, string kind) {
236237
row.splitAt(";", 1) = path and
237238
row.splitAt(";", 2) = kind
238239
)
240+
or
241+
Extensions::sourceModel(type, path, kind)
239242
}
240243

241244
/** Holds if a sink model exists for the given parameters. */
@@ -246,6 +249,8 @@ private predicate sinkModel(string type, string path, string kind) {
246249
row.splitAt(";", 1) = path and
247250
row.splitAt(";", 2) = kind
248251
)
252+
or
253+
Extensions::sinkModel(type, path, kind)
249254
}
250255

251256
/** Holds if a summary model `row` exists for the given parameters. */
@@ -258,6 +263,8 @@ private predicate summaryModel(string type, string path, string input, string ou
258263
row.splitAt(";", 3) = output and
259264
row.splitAt(";", 4) = kind
260265
)
266+
or
267+
Extensions::summaryModel(type, path, input, output, kind)
261268
}
262269

263270
/** Holds if a type model exists for the given parameters. */
@@ -268,6 +275,8 @@ private predicate typeModel(string type1, string type2, string path) {
268275
row.splitAt(";", 1) = type2 and
269276
row.splitAt(";", 2) = path
270277
)
278+
or
279+
Extensions::typeModel(type1, type2, path)
271280
}
272281

273282
/** Holds if a type variable model exists for the given parameters. */
@@ -277,6 +286,8 @@ private predicate typeVariableModel(string name, string path) {
277286
row.splitAt(";", 0) = name and
278287
row.splitAt(";", 1) = path
279288
)
289+
or
290+
Extensions::typeVariableModel(name, path)
280291
}
281292

282293
/**
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Defines extensible predicates for contributing library models from data extensions.
3+
*/
4+
5+
/**
6+
* Holds if the value at `(type, path)` should be seen as a flow
7+
* source of the given `kind`.
8+
*
9+
* The kind `remote` represents a general remote flow source.
10+
*/
11+
extensible predicate sourceModel(string type, string path, string kind);
12+
13+
/**
14+
* Holds if the value at `(type, path)` should be seen as a sink
15+
* of the given `kind`.
16+
*/
17+
extensible predicate sinkModel(string type, string path, string kind);
18+
19+
/**
20+
* Holds if calls to `(type, path)`, the value referred to by `input`
21+
* can flow to the value referred to by `output`.
22+
*
23+
* `kind` should be either `value` or `taint`, for value-preserving or taint-preserving steps,
24+
* respectively.
25+
*/
26+
extensible predicate summaryModel(string type, string path, string input, string output, string kind);
27+
28+
/**
29+
* Holds if `(type2, path)` should be seen as an instance of `type1`.
30+
*/
31+
extensible predicate typeModel(string type1, string type2, string path);
32+
33+
/**
34+
* Holds if `path` can be substituted for a token `TypeVar[name]`.
35+
*/
36+
extensible predicate typeVariableModel(string name, string path);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
extensions:
2+
# Contribute empty data sets to avoid errors about an undefined extensionals
3+
- addsTo:
4+
pack: codeql/python-all
5+
extensible: sourceModel
6+
data: []
7+
8+
- addsTo:
9+
pack: codeql/python-all
10+
extensible: sinkModel
11+
data: []
12+
13+
- addsTo:
14+
pack: codeql/python-all
15+
extensible: summaryModel
16+
data: []
17+
18+
- addsTo:
19+
pack: codeql/python-all
20+
extensible: typeModel
21+
data: []
22+
23+
- addsTo:
24+
pack: codeql/python-all
25+
extensible: typeVariableModel
26+
data: []

ruby/ql/lib/codeql/ruby/frameworks/data/internal/ApiGraphModels.qll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ private module API = Specific::API;
7272
private module DataFlow = Specific::DataFlow;
7373

7474
private import Specific::AccessPathSyntax
75+
private import ApiGraphModelsExtensions as Extensions
7576

7677
/** Module containing hooks for providing input data to be interpreted as a model. */
7778
module ModelInput {
@@ -236,6 +237,8 @@ predicate sourceModel(string type, string path, string kind) {
236237
row.splitAt(";", 1) = path and
237238
row.splitAt(";", 2) = kind
238239
)
240+
or
241+
Extensions::sourceModel(type, path, kind)
239242
}
240243

241244
/** Holds if a sink model exists for the given parameters. */
@@ -246,6 +249,8 @@ private predicate sinkModel(string type, string path, string kind) {
246249
row.splitAt(";", 1) = path and
247250
row.splitAt(";", 2) = kind
248251
)
252+
or
253+
Extensions::sinkModel(type, path, kind)
249254
}
250255

251256
/** Holds if a summary model `row` exists for the given parameters. */
@@ -258,6 +263,8 @@ private predicate summaryModel(string type, string path, string input, string ou
258263
row.splitAt(";", 3) = output and
259264
row.splitAt(";", 4) = kind
260265
)
266+
or
267+
Extensions::summaryModel(type, path, input, output, kind)
261268
}
262269

263270
/** Holds if a type model exists for the given parameters. */
@@ -268,6 +275,8 @@ private predicate typeModel(string type1, string type2, string path) {
268275
row.splitAt(";", 1) = type2 and
269276
row.splitAt(";", 2) = path
270277
)
278+
or
279+
Extensions::typeModel(type1, type2, path)
271280
}
272281

273282
/** Holds if a type variable model exists for the given parameters. */
@@ -277,6 +286,8 @@ private predicate typeVariableModel(string name, string path) {
277286
row.splitAt(";", 0) = name and
278287
row.splitAt(";", 1) = path
279288
)
289+
or
290+
Extensions::typeVariableModel(name, path)
280291
}
281292

282293
/**

0 commit comments

Comments
 (0)