Skip to content

Commit f08d2ee

Browse files
committed
Merge branch 'main' into setliterals
2 parents 9d63efe + 8b6baa2 commit f08d2ee

File tree

216 files changed

+9184
-2914
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

216 files changed

+9184
-2914
lines changed

config/identical-files.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,5 +461,12 @@
461461
"ReDoS Polynomial Python/JS": [
462462
"javascript/ql/lib/semmle/javascript/security/performance/SuperlinearBackTracking.qll",
463463
"python/ql/lib/semmle/python/security/performance/SuperlinearBackTracking.qll"
464+
],
465+
"CodeQL Tutorial": [
466+
"cpp/ql/lib/tutorial.qll",
467+
"csharp/ql/lib/tutorial.qll",
468+
"java/ql/lib/tutorial.qll",
469+
"javascript/ql/lib/tutorial.qll",
470+
"python/ql/lib/tutorial.qll"
464471
]
465-
}
472+
}

cpp/ql/lib/semmle/code/cpp/Declaration.qll

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,8 @@ class Declaration extends Locatable, @declaration {
275275
* `getTemplateArgumentKind(0)`.
276276
*/
277277
final Locatable getTemplateArgumentKind(int index) {
278-
if exists(getTemplateArgumentValue(index))
279-
then result = getTemplateArgumentType(index)
280-
else none()
278+
exists(getTemplateArgumentValue(index)) and
279+
result = getTemplateArgumentType(index)
281280
}
282281

283282
/** Gets the number of template arguments for this declaration. */

cpp/ql/lib/semmle/code/cpp/XML.qll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class XMLParent extends @xmlparent {
108108
}
109109

110110
/** Gets the text value contained in this XML parent. */
111-
string getTextValue() { result = allCharactersString() }
111+
string getTextValue() { result = this.allCharactersString() }
112112

113113
/** Gets a printable representation of this XML parent. */
114114
string toString() { result = this.getName() }
@@ -119,7 +119,7 @@ class XMLFile extends XMLParent, File {
119119
XMLFile() { xmlEncoding(this, _) }
120120

121121
/** Gets a printable representation of this XML file. */
122-
override string toString() { result = getName() }
122+
override string toString() { result = this.getName() }
123123

124124
/** Gets the name of this XML file. */
125125
override string getName() { result = File.super.getAbsolutePath() }
@@ -129,14 +129,14 @@ class XMLFile extends XMLParent, File {
129129
*
130130
* Gets the path of this XML file.
131131
*/
132-
deprecated string getPath() { result = getAbsolutePath() }
132+
deprecated string getPath() { result = this.getAbsolutePath() }
133133

134134
/**
135135
* DEPRECATED: Use `getParentContainer().getAbsolutePath()` instead.
136136
*
137137
* Gets the path of the folder that contains this XML file.
138138
*/
139-
deprecated string getFolder() { result = getParentContainer().getAbsolutePath() }
139+
deprecated string getFolder() { result = this.getParentContainer().getAbsolutePath() }
140140

141141
/** Gets the encoding of this XML file. */
142142
string getEncoding() { xmlEncoding(this, result) }
@@ -200,7 +200,7 @@ class XMLDTD extends XMLLocatable, @xmldtd {
200200
*/
201201
class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
202202
/** Holds if this XML element has the given `name`. */
203-
predicate hasName(string name) { name = getName() }
203+
predicate hasName(string name) { name = this.getName() }
204204

205205
/** Gets the name of this XML element. */
206206
override string getName() { xmlElements(this, result, _, _, _) }
@@ -239,7 +239,7 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
239239
string getAttributeValue(string name) { result = this.getAttribute(name).getValue() }
240240

241241
/** Gets a printable representation of this XML element. */
242-
override string toString() { result = getName() }
242+
override string toString() { result = this.getName() }
243243
}
244244

245245
/**

cpp/ql/lib/semmle/code/cpp/controlflow/internal/ConstantExprs.qll

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,14 +344,13 @@ private int convertIntToType(int val, IntegralType t) {
344344
then if val = 0 then result = 0 else result = 1
345345
else
346346
if t.isUnsigned()
347-
then if val >= 0 and val.bitShiftRight(t.getSize() * 8) = 0 then result = val else none()
347+
then val >= 0 and val.bitShiftRight(t.getSize() * 8) = 0 and result = val
348348
else
349349
if val >= 0 and val.bitShiftRight(t.getSize() * 8 - 1) = 0
350350
then result = val
351-
else
352-
if (-(val + 1)).bitShiftRight(t.getSize() * 8 - 1) = 0
353-
then result = val
354-
else none()
351+
else (
352+
(-(val + 1)).bitShiftRight(t.getSize() * 8 - 1) = 0 and result = val
353+
)
355354
}
356355

357356
/**

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ class CallContextSpecificCall extends CallContextCall, TSpecificCall {
937937
}
938938

939939
override predicate relevantFor(DataFlowCallable callable) {
940-
recordDataFlowCallSite(getCall(), callable)
940+
recordDataFlowCallSite(this.getCall(), callable)
941941
}
942942

943943
override predicate matchesCall(DataFlowCall call) { call = this.getCall() }
@@ -1257,7 +1257,7 @@ abstract class AccessPathFront extends TAccessPathFront {
12571257

12581258
TypedContent getHead() { this = TFrontHead(result) }
12591259

1260-
predicate isClearedAt(Node n) { clearsContentCached(n, getHead().getContent()) }
1260+
predicate isClearedAt(Node n) { clearsContentCached(n, this.getHead().getContent()) }
12611261
}
12621262

12631263
class AccessPathFrontNil extends AccessPathFront, TFrontNil {

cpp/ql/lib/semmle/code/cpp/dataflow/internal/tainttracking1/TaintTrackingImpl.qll

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,26 @@ abstract class Configuration extends DataFlow::Configuration {
7575
predicate isSanitizer(DataFlow::Node node) { none() }
7676

7777
final override predicate isBarrier(DataFlow::Node node) {
78-
isSanitizer(node) or
78+
this.isSanitizer(node) or
7979
defaultTaintSanitizer(node)
8080
}
8181

8282
/** Holds if taint propagation into `node` is prohibited. */
8383
predicate isSanitizerIn(DataFlow::Node node) { none() }
8484

85-
final override predicate isBarrierIn(DataFlow::Node node) { isSanitizerIn(node) }
85+
final override predicate isBarrierIn(DataFlow::Node node) { this.isSanitizerIn(node) }
8686

8787
/** Holds if taint propagation out of `node` is prohibited. */
8888
predicate isSanitizerOut(DataFlow::Node node) { none() }
8989

90-
final override predicate isBarrierOut(DataFlow::Node node) { isSanitizerOut(node) }
90+
final override predicate isBarrierOut(DataFlow::Node node) { this.isSanitizerOut(node) }
9191

9292
/** Holds if taint propagation through nodes guarded by `guard` is prohibited. */
9393
predicate isSanitizerGuard(DataFlow::BarrierGuard guard) { none() }
9494

95-
final override predicate isBarrierGuard(DataFlow::BarrierGuard guard) { isSanitizerGuard(guard) }
95+
final override predicate isBarrierGuard(DataFlow::BarrierGuard guard) {
96+
this.isSanitizerGuard(guard)
97+
}
9698

9799
/**
98100
* Holds if the additional taint propagation step from `node1` to `node2`
@@ -101,7 +103,7 @@ abstract class Configuration extends DataFlow::Configuration {
101103
predicate isAdditionalTaintStep(DataFlow::Node node1, DataFlow::Node node2) { none() }
102104

103105
final override predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
104-
isAdditionalTaintStep(node1, node2) or
106+
this.isAdditionalTaintStep(node1, node2) or
105107
defaultAdditionalTaintStep(node1, node2)
106108
}
107109

cpp/ql/lib/semmle/code/cpp/dataflow/internal/tainttracking2/TaintTrackingImpl.qll

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,26 @@ abstract class Configuration extends DataFlow::Configuration {
7575
predicate isSanitizer(DataFlow::Node node) { none() }
7676

7777
final override predicate isBarrier(DataFlow::Node node) {
78-
isSanitizer(node) or
78+
this.isSanitizer(node) or
7979
defaultTaintSanitizer(node)
8080
}
8181

8282
/** Holds if taint propagation into `node` is prohibited. */
8383
predicate isSanitizerIn(DataFlow::Node node) { none() }
8484

85-
final override predicate isBarrierIn(DataFlow::Node node) { isSanitizerIn(node) }
85+
final override predicate isBarrierIn(DataFlow::Node node) { this.isSanitizerIn(node) }
8686

8787
/** Holds if taint propagation out of `node` is prohibited. */
8888
predicate isSanitizerOut(DataFlow::Node node) { none() }
8989

90-
final override predicate isBarrierOut(DataFlow::Node node) { isSanitizerOut(node) }
90+
final override predicate isBarrierOut(DataFlow::Node node) { this.isSanitizerOut(node) }
9191

9292
/** Holds if taint propagation through nodes guarded by `guard` is prohibited. */
9393
predicate isSanitizerGuard(DataFlow::BarrierGuard guard) { none() }
9494

95-
final override predicate isBarrierGuard(DataFlow::BarrierGuard guard) { isSanitizerGuard(guard) }
95+
final override predicate isBarrierGuard(DataFlow::BarrierGuard guard) {
96+
this.isSanitizerGuard(guard)
97+
}
9698

9799
/**
98100
* Holds if the additional taint propagation step from `node1` to `node2`
@@ -101,7 +103,7 @@ abstract class Configuration extends DataFlow::Configuration {
101103
predicate isAdditionalTaintStep(DataFlow::Node node1, DataFlow::Node node2) { none() }
102104

103105
final override predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
104-
isAdditionalTaintStep(node1, node2) or
106+
this.isAdditionalTaintStep(node1, node2) or
105107
defaultAdditionalTaintStep(node1, node2)
106108
}
107109

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ class CallContextSpecificCall extends CallContextCall, TSpecificCall {
937937
}
938938

939939
override predicate relevantFor(DataFlowCallable callable) {
940-
recordDataFlowCallSite(getCall(), callable)
940+
recordDataFlowCallSite(this.getCall(), callable)
941941
}
942942

943943
override predicate matchesCall(DataFlowCall call) { call = this.getCall() }
@@ -1257,7 +1257,7 @@ abstract class AccessPathFront extends TAccessPathFront {
12571257

12581258
TypedContent getHead() { this = TFrontHead(result) }
12591259

1260-
predicate isClearedAt(Node n) { clearsContentCached(n, getHead().getContent()) }
1260+
predicate isClearedAt(Node n) { clearsContentCached(n, this.getHead().getContent()) }
12611261
}
12621262

12631263
class AccessPathFrontNil extends AccessPathFront, TFrontNil {

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/tainttracking1/TaintTrackingImpl.qll

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,26 @@ abstract class Configuration extends DataFlow::Configuration {
7575
predicate isSanitizer(DataFlow::Node node) { none() }
7676

7777
final override predicate isBarrier(DataFlow::Node node) {
78-
isSanitizer(node) or
78+
this.isSanitizer(node) or
7979
defaultTaintSanitizer(node)
8080
}
8181

8282
/** Holds if taint propagation into `node` is prohibited. */
8383
predicate isSanitizerIn(DataFlow::Node node) { none() }
8484

85-
final override predicate isBarrierIn(DataFlow::Node node) { isSanitizerIn(node) }
85+
final override predicate isBarrierIn(DataFlow::Node node) { this.isSanitizerIn(node) }
8686

8787
/** Holds if taint propagation out of `node` is prohibited. */
8888
predicate isSanitizerOut(DataFlow::Node node) { none() }
8989

90-
final override predicate isBarrierOut(DataFlow::Node node) { isSanitizerOut(node) }
90+
final override predicate isBarrierOut(DataFlow::Node node) { this.isSanitizerOut(node) }
9191

9292
/** Holds if taint propagation through nodes guarded by `guard` is prohibited. */
9393
predicate isSanitizerGuard(DataFlow::BarrierGuard guard) { none() }
9494

95-
final override predicate isBarrierGuard(DataFlow::BarrierGuard guard) { isSanitizerGuard(guard) }
95+
final override predicate isBarrierGuard(DataFlow::BarrierGuard guard) {
96+
this.isSanitizerGuard(guard)
97+
}
9698

9799
/**
98100
* Holds if the additional taint propagation step from `node1` to `node2`
@@ -101,7 +103,7 @@ abstract class Configuration extends DataFlow::Configuration {
101103
predicate isAdditionalTaintStep(DataFlow::Node node1, DataFlow::Node node2) { none() }
102104

103105
final override predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
104-
isAdditionalTaintStep(node1, node2) or
106+
this.isAdditionalTaintStep(node1, node2) or
105107
defaultAdditionalTaintStep(node1, node2)
106108
}
107109

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/tainttracking2/TaintTrackingImpl.qll

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,26 @@ abstract class Configuration extends DataFlow::Configuration {
7575
predicate isSanitizer(DataFlow::Node node) { none() }
7676

7777
final override predicate isBarrier(DataFlow::Node node) {
78-
isSanitizer(node) or
78+
this.isSanitizer(node) or
7979
defaultTaintSanitizer(node)
8080
}
8181

8282
/** Holds if taint propagation into `node` is prohibited. */
8383
predicate isSanitizerIn(DataFlow::Node node) { none() }
8484

85-
final override predicate isBarrierIn(DataFlow::Node node) { isSanitizerIn(node) }
85+
final override predicate isBarrierIn(DataFlow::Node node) { this.isSanitizerIn(node) }
8686

8787
/** Holds if taint propagation out of `node` is prohibited. */
8888
predicate isSanitizerOut(DataFlow::Node node) { none() }
8989

90-
final override predicate isBarrierOut(DataFlow::Node node) { isSanitizerOut(node) }
90+
final override predicate isBarrierOut(DataFlow::Node node) { this.isSanitizerOut(node) }
9191

9292
/** Holds if taint propagation through nodes guarded by `guard` is prohibited. */
9393
predicate isSanitizerGuard(DataFlow::BarrierGuard guard) { none() }
9494

95-
final override predicate isBarrierGuard(DataFlow::BarrierGuard guard) { isSanitizerGuard(guard) }
95+
final override predicate isBarrierGuard(DataFlow::BarrierGuard guard) {
96+
this.isSanitizerGuard(guard)
97+
}
9698

9799
/**
98100
* Holds if the additional taint propagation step from `node1` to `node2`
@@ -101,7 +103,7 @@ abstract class Configuration extends DataFlow::Configuration {
101103
predicate isAdditionalTaintStep(DataFlow::Node node1, DataFlow::Node node2) { none() }
102104

103105
final override predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
104-
isAdditionalTaintStep(node1, node2) or
106+
this.isAdditionalTaintStep(node1, node2) or
105107
defaultAdditionalTaintStep(node1, node2)
106108
}
107109

0 commit comments

Comments
 (0)