Skip to content

Commit f0c5a80

Browse files
committed
apply the explicit this patch to new code
1 parent 0ff36cd commit f0c5a80

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

javascript/ql/lib/semmle/javascript/frameworks/CryptoLibraries.qll

+12-12
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ private module NodeJSCrypto {
164164
exists(DataFlow::SourceNode mod |
165165
mod = DataFlow::moduleImport("crypto") and
166166
this = mod.getAMemberCall("create" + ["Hash", "Hmac", "Sign", "Cipher"]) and
167-
algorithm.matchesName(getArgument(0).getStringValue())
167+
algorithm.matchesName(this.getArgument(0).getStringValue())
168168
)
169169
}
170170

@@ -190,15 +190,15 @@ private module NodeJSCrypto {
190190
}
191191

192192
override CryptographicAlgorithm getAlgorithm() {
193-
result.matchesName(getArgument(0).getStringValue())
193+
result.matchesName(this.getArgument(0).getStringValue())
194194
}
195195

196196
override int getSize() {
197197
symmetric = true and
198-
result = getOptionArgument(1, "length").getIntValue()
198+
result = this.getOptionArgument(1, "length").getIntValue()
199199
or
200200
symmetric = false and
201-
result = getOptionArgument(1, "modulusLength").getIntValue()
201+
result = this.getOptionArgument(1, "modulusLength").getIntValue()
202202
}
203203

204204
override predicate isSymmetricKey() { symmetric = true }
@@ -212,7 +212,7 @@ private module NodeJSCrypto {
212212

213213
override CryptographicAlgorithm getAlgorithm() { none() }
214214

215-
override int getSize() { result = getArgument(0).getIntValue() }
215+
override int getSize() { result = this.getArgument(0).getIntValue() }
216216

217217
override predicate isSymmetricKey() { none() }
218218
}
@@ -224,7 +224,7 @@ private module NodeJSCrypto {
224224
this = instantiation.getAMethodCall(any(string m | m = "update" or m = "write")).asExpr()
225225
}
226226

227-
override Expr getInput() { result = getArgument(0) }
227+
override Expr getInput() { result = this.getArgument(0) }
228228

229229
override CryptographicAlgorithm getAlgorithm() { result = instantiation.getAlgorithm() }
230230
}
@@ -365,9 +365,9 @@ private module CryptoJS {
365365
override CryptographicAlgorithm getAlgorithm() { result.matchesName(algorithm) }
366366

367367
override int getSize() {
368-
result = getOptionArgument(optionArg, "keySize").getIntValue() * 32 // size is in words
368+
result = this.getOptionArgument(optionArg, "keySize").getIntValue() * 32 // size is in words
369369
or
370-
result = getArgument(optionArg).getIntValue() * 32 // size is in words
370+
result = this.getArgument(optionArg).getIntValue() * 32 // size is in words
371371
}
372372

373373
override predicate isSymmetricKey() { any() }
@@ -496,19 +496,19 @@ private module Forge {
496496
// `require('forge').cipher.createCipher("3DES-CBC").update("secret", "key");`
497497
(createName = "createCipher" or createName = "createDecipher") and
498498
this = mod.getAPropertyRead("cipher").getAMemberCall(createName) and
499-
getArgument(0).asExpr().mayHaveStringValue(cipherName) and
499+
this.getArgument(0).asExpr().mayHaveStringValue(cipherName) and
500500
cipherName = cipherPrefix + "-" + cipherSuffix and
501501
cipherSuffix = ["CBC", "CFB", "CTR", "ECB", "GCM", "OFB"] and
502502
algorithmName = cipherPrefix and
503-
key = getArgument(1)
503+
key = this.getArgument(1)
504504
)
505505
or
506506
// `require("forge").rc2.createEncryptionCipher("key").update("secret");`
507507
exists(string createName |
508508
createName = "createEncryptionCipher" or createName = "createDecryptionCipher"
509509
|
510510
this = mod.getAPropertyRead(algorithmName).getAMemberCall(createName) and
511-
key = getArgument(0)
511+
key = this.getArgument(0)
512512
)
513513
)
514514
}
@@ -583,7 +583,7 @@ private module Forge {
583583
result = this.getArgument(1).getIntValue()
584584
or
585585
exists(DataFlow::CallNode call | call.getCalleeName() = ["getBytes", "getBytesSync"] |
586-
getArgument(1).getALocalSource() = call and
586+
this.getArgument(1).getALocalSource() = call and
587587
result = call.getArgument(0).getIntValue() * 8 // bytes to bits
588588
)
589589
}

javascript/ql/lib/semmle/javascript/security/dataflow/PrototypePollutingAssignmentQuery.qll

+3-3
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ private class IsArrayCheck extends TaintTracking::LabeledSanitizerGuardNode, Dat
233233
IsArrayCheck() { this = DataFlow::globalVarRef("Array").getAMemberCall("isArray") }
234234

235235
override predicate sanitizes(boolean outcome, Expr e, DataFlow::FlowLabel label) {
236-
e = getArgument(0).asExpr() and
236+
e = this.getArgument(0).asExpr() and
237237
outcome = true and
238238
label instanceof ObjectPrototype
239239
}
@@ -260,7 +260,7 @@ private class IncludesCheck extends TaintTracking::LabeledSanitizerGuardNode, In
260260
IncludesCheck() { this.getContainedNode().mayHaveStringValue("__proto__") }
261261

262262
override predicate sanitizes(boolean outcome, Expr e) {
263-
e = getContainerNode().asExpr() and
264-
outcome = getPolarity().booleanNot()
263+
e = this.getContainerNode().asExpr() and
264+
outcome = this.getPolarity().booleanNot()
265265
}
266266
}

javascript/ql/src/experimental/Security/CWE-918/SSRF.qll

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ class Configuration extends TaintTracking::Configuration {
1717
private predicate hasSanitizingSubstring(DataFlow::Node nd) {
1818
nd.getStringValue().regexpMatch(".*[?#].*")
1919
or
20-
hasSanitizingSubstring(StringConcatenation::getAnOperand(nd))
20+
this.hasSanitizingSubstring(StringConcatenation::getAnOperand(nd))
2121
or
22-
hasSanitizingSubstring(nd.getAPredecessor())
22+
this.hasSanitizingSubstring(nd.getAPredecessor())
2323
}
2424

2525
private predicate strictSanitizingPrefixEdge(DataFlow::Node source, DataFlow::Node sink) {
2626
exists(DataFlow::Node operator, int n |
2727
StringConcatenation::taintStep(source, sink, operator, n) and
28-
hasSanitizingSubstring(StringConcatenation::getOperand(operator, [0 .. n - 1]))
28+
this.hasSanitizingSubstring(StringConcatenation::getOperand(operator, [0 .. n - 1]))
2929
)
3030
}
3131

3232
override predicate isSanitizerEdge(DataFlow::Node source, DataFlow::Node sink) {
33-
strictSanitizingPrefixEdge(source, sink)
33+
this.strictSanitizingPrefixEdge(source, sink)
3434
}
3535

3636
override predicate isSanitizerGuard(TaintTracking::SanitizerGuardNode nd) {
@@ -126,7 +126,7 @@ class IntegerCheck extends TaintTracking::SanitizerGuardNode, DataFlow::CallNode
126126

127127
override predicate sanitizes(boolean outcome, Expr e) {
128128
outcome = true and
129-
e = getArgument(0).asExpr()
129+
e = this.getArgument(0).asExpr()
130130
}
131131
}
132132

@@ -149,6 +149,6 @@ class ValidatorCheck extends TaintTracking::SanitizerGuardNode, DataFlow::CallNo
149149

150150
override predicate sanitizes(boolean outcome, Expr e) {
151151
outcome = true and
152-
e = getArgument(0).asExpr()
152+
e = this.getArgument(0).asExpr()
153153
}
154154
}

0 commit comments

Comments
 (0)