Skip to content

Commit bb4fe20

Browse files
committed
Merge branch 'main' into rdmarsh2/swift/array-content-flow
2 parents 6039af0 + 40eab18 commit bb4fe20

File tree

20 files changed

+7318
-73
lines changed

20 files changed

+7318
-73
lines changed

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlow.qll

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,5 +429,22 @@ module MergePathGraph3<
429429
/**
430430
* Provides the query predicates needed to include a graph in a path-problem query.
431431
*/
432-
module PathGraph = Merged::PathGraph;
432+
module PathGraph implements PathGraphSig<PathNode> {
433+
/** Holds if `(a,b)` is an edge in the graph of data flow path explanations. */
434+
query predicate edges(PathNode a, PathNode b) { Merged::PathGraph::edges(a, b) }
435+
436+
/** Holds if `n` is a node in the graph of data flow path explanations. */
437+
query predicate nodes(PathNode n, string key, string val) {
438+
Merged::PathGraph::nodes(n, key, val)
439+
}
440+
441+
/**
442+
* Holds if `(arg, par, ret, out)` forms a subpath-tuple, that is, flow through
443+
* a subpath between `par` and `ret` with the connecting edges `arg -> par` and
444+
* `ret -> out` is summarized as the edge `arg -> out`.
445+
*/
446+
query predicate subpaths(PathNode arg, PathNode par, PathNode ret, PathNode out) {
447+
Merged::PathGraph::subpaths(arg, par, ret, out)
448+
}
449+
}
433450
}

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlow.qll

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,5 +429,22 @@ module MergePathGraph3<
429429
/**
430430
* Provides the query predicates needed to include a graph in a path-problem query.
431431
*/
432-
module PathGraph = Merged::PathGraph;
432+
module PathGraph implements PathGraphSig<PathNode> {
433+
/** Holds if `(a,b)` is an edge in the graph of data flow path explanations. */
434+
query predicate edges(PathNode a, PathNode b) { Merged::PathGraph::edges(a, b) }
435+
436+
/** Holds if `n` is a node in the graph of data flow path explanations. */
437+
query predicate nodes(PathNode n, string key, string val) {
438+
Merged::PathGraph::nodes(n, key, val)
439+
}
440+
441+
/**
442+
* Holds if `(arg, par, ret, out)` forms a subpath-tuple, that is, flow through
443+
* a subpath between `par` and `ret` with the connecting edges `arg -> par` and
444+
* `ret -> out` is summarized as the edge `arg -> out`.
445+
*/
446+
query predicate subpaths(PathNode arg, PathNode par, PathNode ret, PathNode out) {
447+
Merged::PathGraph::subpaths(arg, par, ret, out)
448+
}
449+
}
433450
}

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlow.qll

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,5 +429,22 @@ module MergePathGraph3<
429429
/**
430430
* Provides the query predicates needed to include a graph in a path-problem query.
431431
*/
432-
module PathGraph = Merged::PathGraph;
432+
module PathGraph implements PathGraphSig<PathNode> {
433+
/** Holds if `(a,b)` is an edge in the graph of data flow path explanations. */
434+
query predicate edges(PathNode a, PathNode b) { Merged::PathGraph::edges(a, b) }
435+
436+
/** Holds if `n` is a node in the graph of data flow path explanations. */
437+
query predicate nodes(PathNode n, string key, string val) {
438+
Merged::PathGraph::nodes(n, key, val)
439+
}
440+
441+
/**
442+
* Holds if `(arg, par, ret, out)` forms a subpath-tuple, that is, flow through
443+
* a subpath between `par` and `ret` with the connecting edges `arg -> par` and
444+
* `ret -> out` is summarized as the edge `arg -> out`.
445+
*/
446+
query predicate subpaths(PathNode arg, PathNode par, PathNode ret, PathNode out) {
447+
Merged::PathGraph::subpaths(arg, par, ret, out)
448+
}
449+
}
433450
}

docs/codeql/writing-codeql-queries/catch-the-fire-starter.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,16 @@ Exercise 1
168168
predicate isSouthern(Person p) { p.getLocation() = "south" }
169169
170170
class Southerner extends Person {
171-
/* the characteristic predicate */
172-
Southerner() { isSouthern(this) }
171+
/* the characteristic predicate */
172+
Southerner() { isSouthern(this) }
173173
}
174174
175175
class Child extends Person {
176-
/* the characteristic predicate */
177-
Child() { this.getAge() < 10 }
176+
/* the characteristic predicate */
177+
Child() { this.getAge() < 10 }
178178
179-
/* a member predicate */
180-
override predicate isAllowedIn(string region) { region = this.getLocation() }
179+
/* a member predicate */
180+
override predicate isAllowedIn(string region) { region = this.getLocation() }
181181
}
182182
183183
from Southerner s
@@ -194,16 +194,16 @@ Exercise 2
194194
predicate isSouthern(Person p) { p.getLocation() = "south" }
195195
196196
class Southerner extends Person {
197-
/* the characteristic predicate */
198-
Southerner() { isSouthern(this) }
197+
/* the characteristic predicate */
198+
Southerner() { isSouthern(this) }
199199
}
200200
201201
class Child extends Person {
202-
/* the characteristic predicate */
203-
Child() { this.getAge() < 10 }
202+
/* the characteristic predicate */
203+
Child() { this.getAge() < 10 }
204204
205-
/* a member predicate */
206-
override predicate isAllowedIn(string region) { region = this.getLocation() }
205+
/* a member predicate */
206+
override predicate isAllowedIn(string region) { region = this.getLocation() }
207207
}
208208
209209
predicate isBald(Person p) { not exists(string c | p.getHairColor() = c) }

docs/codeql/writing-codeql-queries/crown-the-rightful-heir.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ Exercise 1
183183
184184
from Person p
185185
where
186-
not p.isDeceased() and
187-
p = relativeOf("King Basil")
186+
not p.isDeceased() and
187+
p = relativeOf("King Basil")
188188
select p
189189
190190
Exercise 2
@@ -197,14 +197,14 @@ Exercise 2
197197
Person relativeOf(Person p) { parentOf*(result) = parentOf*(p) }
198198
199199
predicate hasCriminalRecord(Person p) {
200-
p = "Hester" or
201-
p = "Hugh" or
202-
p = "Charlie"
200+
p = "Hester" or
201+
p = "Hugh" or
202+
p = "Charlie"
203203
}
204204
205205
from Person p
206206
where
207-
not p.isDeceased() and
208-
p = relativeOf("King Basil") and
209-
not hasCriminalRecord(p)
207+
not p.isDeceased() and
208+
p = relativeOf("King Basil") and
209+
not hasCriminalRecord(p)
210210
select p

docs/codeql/writing-codeql-queries/find-the-thief.rst

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -307,14 +307,14 @@ Exercise 1
307307
308308
from Person t
309309
where
310-
/* 1 */ t.getHeight() > 150 and
311-
/* 2 */ not t.getHairColor() = "blond" and
312-
/* 3 */ exists (string c | t.getHairColor() = c) and
313-
/* 4 */ not t.getAge() < 30 and
314-
/* 5 */ t.getLocation() = "east" and
315-
/* 6 */ (t.getHairColor() = "black" or t.getHairColor() = "brown") and
316-
/* 7 */ not (t.getHeight() > 180 and t.getHeight() < 190) and
317-
/* 8 */ exists(Person p | p.getAge() > t.getAge())
310+
/* 1 */ t.getHeight() > 150 and
311+
/* 2 */ not t.getHairColor() = "blond" and
312+
/* 3 */ exists (string c | t.getHairColor() = c) and
313+
/* 4 */ not t.getAge() < 30 and
314+
/* 5 */ t.getLocation() = "east" and
315+
/* 6 */ (t.getHairColor() = "black" or t.getHairColor() = "brown") and
316+
/* 7 */ not (t.getHeight() > 180 and t.getHeight() < 190) and
317+
/* 8 */ exists(Person p | p.getAge() > t.getAge())
318318
select t
319319
320320
Exercise 2
@@ -326,16 +326,16 @@ Exercise 2
326326
327327
from Person t
328328
where
329-
/* 1 */ t.getHeight() > 150 and
330-
/* 2 */ not t.getHairColor() = "blond" and
331-
/* 3 */ exists (string c | t.getHairColor() = c) and
332-
/* 4 */ not t.getAge() < 30 and
333-
/* 5 */ t.getLocation() = "east" and
334-
/* 6 */ (t.getHairColor() = "black" or t.getHairColor() = "brown") and
335-
/* 7 */ not (t.getHeight() > 180 and t.getHeight() < 190) and
336-
/* 8 */ exists(Person p | p.getAge() > t.getAge()) and
337-
/* 9 */ not t = max(Person p | | p order by p.getHeight()) and
338-
/* 10 */ t.getHeight() < avg(float i | exists(Person p | p.getHeight() = i) | i) and
339-
/* 11 */ t = max(Person p | p.getLocation() = "east" | p order by p.getAge())
329+
/* 1 */ t.getHeight() > 150 and
330+
/* 2 */ not t.getHairColor() = "blond" and
331+
/* 3 */ exists (string c | t.getHairColor() = c) and
332+
/* 4 */ not t.getAge() < 30 and
333+
/* 5 */ t.getLocation() = "east" and
334+
/* 6 */ (t.getHairColor() = "black" or t.getHairColor() = "brown") and
335+
/* 7 */ not (t.getHeight() > 180 and t.getHeight() < 190) and
336+
/* 8 */ exists(Person p | p.getAge() > t.getAge()) and
337+
/* 9 */ not t = max(Person p | | p order by p.getHeight()) and
338+
/* 10 */ t.getHeight() < avg(float i | exists(Person p | p.getHeight() = i) | i) and
339+
/* 11 */ t = max(Person p | p.getLocation() = "east" | p order by p.getAge())
340340
select "The thief is " + t + "!"
341341

go/ql/lib/semmle/go/dataflow/internal/DataFlow.qll

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,5 +429,22 @@ module MergePathGraph3<
429429
/**
430430
* Provides the query predicates needed to include a graph in a path-problem query.
431431
*/
432-
module PathGraph = Merged::PathGraph;
432+
module PathGraph implements PathGraphSig<PathNode> {
433+
/** Holds if `(a,b)` is an edge in the graph of data flow path explanations. */
434+
query predicate edges(PathNode a, PathNode b) { Merged::PathGraph::edges(a, b) }
435+
436+
/** Holds if `n` is a node in the graph of data flow path explanations. */
437+
query predicate nodes(PathNode n, string key, string val) {
438+
Merged::PathGraph::nodes(n, key, val)
439+
}
440+
441+
/**
442+
* Holds if `(arg, par, ret, out)` forms a subpath-tuple, that is, flow through
443+
* a subpath between `par` and `ret` with the connecting edges `arg -> par` and
444+
* `ret -> out` is summarized as the edge `arg -> out`.
445+
*/
446+
query predicate subpaths(PathNode arg, PathNode par, PathNode ret, PathNode out) {
447+
Merged::PathGraph::subpaths(arg, par, ret, out)
448+
}
449+
}
433450
}

java/kotlin-extractor/src/main/kotlin/utils/Logger.kt

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,22 @@ class LogMessage(private val kind: String, private val message: String) {
4646
private fun escape(str: String): String {
4747
return str.replace("\\", "\\\\")
4848
.replace("\"", "\\\"")
49-
.replace("/", "\\/")
50-
.replace("\b", "\\b")
49+
.replace("\u0000", "\\u0000")
50+
.replace("\u0001", "\\u0001")
51+
.replace("\u0002", "\\u0002")
52+
.replace("\u0003", "\\u0003")
53+
.replace("\u0004", "\\u0004")
54+
.replace("\u0005", "\\u0005")
55+
.replace("\u0006", "\\u0006")
56+
.replace("\u0007", "\\u0007")
57+
.replace("\u0008", "\\b")
58+
.replace("\u0009", "\\t")
59+
.replace("\u000A", "\\n")
60+
.replace("\u000B", "\\u000B")
5161
.replace("\u000C", "\\f")
52-
.replace("\n", "\\n")
53-
.replace("\r", "\\r")
54-
.replace("\t", "\\t")
62+
.replace("\u000D", "\\r")
63+
.replace("\u000E", "\\u000E")
64+
.replace("\u000F", "\\u000F")
5565
}
5666

5767
fun toJsonLine(): String {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Added models for the Struts 2 framework.
5+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Improved the modeling of Struts 2 sources of untrusted data by tainting the whole object graph of the objects unmarshaled from an HTTP request.
5+

0 commit comments

Comments
 (0)