Skip to content

Commit f2e2c02

Browse files
committed
Rename predicates to avoid clashes
1 parent 1718ef8 commit f2e2c02

File tree

15 files changed

+62
-60
lines changed

15 files changed

+62
-60
lines changed

go/ql/lib/semmle/go/security/AllocationSizeOverflow.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ module AllocationSizeOverflow {
4848
* Holds if `nd` is at a position where overflow might occur, and its result is used to compute
4949
* allocation size `allocsz`.
5050
*/
51-
predicate isSink(DataFlow::Node nd, DataFlow::Node allocsz) {
51+
predicate isSinkWithAllocationSize(DataFlow::Node nd, DataFlow::Node allocsz) {
5252
nd.(Sink).getAllocationSize() = allocsz
5353
}
5454

55-
override predicate isSink(DataFlow::Node nd) { isSink(nd, _) }
55+
override predicate isSink(DataFlow::Node nd) { isSinkWithAllocationSize(nd, _) }
5656

5757
override predicate isAdditionalTaintStep(DataFlow::Node pred, DataFlow::Node succ) {
5858
additionalStep(pred, succ)

go/ql/lib/semmle/go/security/IncorrectIntegerConversionLib.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class ConversionWithoutBoundsCheckConfig extends TaintTracking::Configuration {
109109
* not also in a right-shift expression. We allow this case because it is
110110
* a common pattern to serialise `byte(v)`, `byte(v >> 8)`, and so on.
111111
*/
112-
predicate isSink(DataFlow::TypeCastNode sink, int bitSize) {
112+
predicate isSinkWithBitSize(DataFlow::TypeCastNode sink, int bitSize) {
113113
sink.asExpr() instanceof ConversionExpr and
114114
exists(IntegerType integerType | sink.getResultType().getUnderlyingType() = integerType |
115115
bitSize = integerType.getSize()
@@ -125,7 +125,7 @@ class ConversionWithoutBoundsCheckConfig extends TaintTracking::Configuration {
125125
)
126126
}
127127

128-
override predicate isSink(DataFlow::Node sink) { this.isSink(sink, sinkBitSize) }
128+
override predicate isSink(DataFlow::Node sink) { this.isSinkWithBitSize(sink, sinkBitSize) }
129129

130130
override predicate isSanitizer(DataFlow::Node node) {
131131
// To catch flows that only happen on 32-bit architectures we
@@ -140,7 +140,7 @@ class ConversionWithoutBoundsCheckConfig extends TaintTracking::Configuration {
140140

141141
override predicate isSanitizerOut(DataFlow::Node node) {
142142
exists(int bitSize | isIncorrectIntegerConversion(sourceBitSize, bitSize) |
143-
this.isSink(node, bitSize)
143+
this.isSinkWithBitSize(node, bitSize)
144144
)
145145
}
146146
}

go/ql/lib/semmle/go/security/InsecureRandomness.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ module InsecureRandomness {
2525

2626
override predicate isSource(DataFlow::Node source) { source instanceof Source }
2727

28-
override predicate isSink(DataFlow::Node sink) { this.isSink(sink, _) }
28+
override predicate isSink(DataFlow::Node sink) { this.isSinkWithKind(sink, _) }
2929

3030
/** Holds if `sink` is a sink for this configuration with kind `kind`. */
31-
predicate isSink(Sink sink, string kind) { kind = sink.getKind() }
31+
predicate isSinkWithKind(Sink sink, string kind) { kind = sink.getKind() }
3232

3333
override predicate isSanitizer(DataFlow::Node node) { node instanceof Sanitizer }
3434
}

go/ql/src/Security/CWE-020/IncompleteHostnameRegexp.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ predicate regexpGuardsError(RegexpPattern regexp) {
8383
class Config extends DataFlow::Configuration {
8484
Config() { this = "IncompleteHostNameRegexp::Config" }
8585

86-
predicate isSource(DataFlow::Node source, string hostPart) {
86+
predicate isSourceString(DataFlow::Node source, string hostPart) {
8787
exists(Expr e |
8888
e = source.asExpr() and
8989
isIncompleteHostNameRegexpPattern(e.getStringValue(), hostPart)
@@ -95,7 +95,7 @@ class Config extends DataFlow::Configuration {
9595
)
9696
}
9797

98-
override predicate isSource(DataFlow::Node source) { isSource(source, _) }
98+
override predicate isSource(DataFlow::Node source) { isSourceString(source, _) }
9999

100100
override predicate isSink(DataFlow::Node sink) {
101101
sink instanceof RegexpPattern and
@@ -107,7 +107,7 @@ class Config extends DataFlow::Configuration {
107107
}
108108

109109
from Config c, DataFlow::PathNode source, DataFlow::PathNode sink, string hostPart
110-
where c.hasFlowPath(source, sink) and c.isSource(source.getNode(), hostPart)
110+
where c.hasFlowPath(source, sink) and c.isSourceString(source.getNode(), hostPart)
111111
select source, source, sink,
112112
"This regular expression has an unescaped dot before '" + hostPart + "', " +
113113
"so it might match more hosts than expected when $@.", sink, "the regular expression is used"

go/ql/src/Security/CWE-020/MissingRegexpAnchor.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,19 @@ predicate isInterestingUnanchoredRegexpString(string re, string msg) {
6363
class Config extends DataFlow::Configuration {
6464
Config() { this = "MissingRegexpAnchor::Config" }
6565

66-
predicate isSource(DataFlow::Node source, string msg) {
66+
predicate isSourceString(DataFlow::Node source, string msg) {
6767
exists(Expr e | e = source.asExpr() |
6868
isInterestingUnanchoredRegexpString(e.getStringValue(), msg)
6969
or
7070
isInterestingSemiAnchoredRegexpString(e.getStringValue(), msg)
7171
)
7272
}
7373

74-
override predicate isSource(DataFlow::Node source) { isSource(source, _) }
74+
override predicate isSource(DataFlow::Node source) { isSourceString(source, _) }
7575

7676
override predicate isSink(DataFlow::Node sink) { sink instanceof RegexpPattern }
7777
}
7878

7979
from Config c, DataFlow::PathNode source, string msg
80-
where c.hasFlowPath(source, _) and c.isSource(source.getNode(), msg)
80+
where c.hasFlowPath(source, _) and c.isSourceString(source.getNode(), msg)
8181
select source.getNode(), msg

go/ql/src/Security/CWE-020/SuspiciousCharacterInRegexp.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ predicate containsEscapedCharacter(DataFlow::Node source, string character) {
3232
class Config extends DataFlow::Configuration {
3333
Config() { this = "SuspiciousRegexpEscape" }
3434

35-
predicate isSource(DataFlow::Node source, string report) {
35+
predicate isSourceString(DataFlow::Node source, string report) {
3636
containsEscapedCharacter(source, "a") and
3737
report =
3838
"the bell character \\a; did you mean \\\\a, the Vim alphabetic character class (use [[:alpha:]] instead) or \\\\A, the beginning of text?"
@@ -41,12 +41,12 @@ class Config extends DataFlow::Configuration {
4141
report = "a literal backspace \\b; did you mean \\\\b, a word boundary?"
4242
}
4343

44-
override predicate isSource(DataFlow::Node source) { isSource(source, _) }
44+
override predicate isSource(DataFlow::Node source) { isSourceString(source, _) }
4545

4646
override predicate isSink(DataFlow::Node sink) { sink instanceof RegexpPattern }
4747
}
4848

4949
from Config c, DataFlow::PathNode source, DataFlow::PathNode sink, string report
50-
where c.hasFlowPath(source, sink) and c.isSource(source.getNode(), report)
50+
where c.hasFlowPath(source, sink) and c.isSourceString(source.getNode(), report)
5151
select source, source, sink, "This string literal that is $@ contains " + report, sink,
5252
"used as a regular expression"

go/ql/src/Security/CWE-190/AllocationSizeOverflow.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ from
2020
DataFlow::Node allocsz
2121
where
2222
cfg.hasFlowPath(source, sink) and
23-
cfg.isSink(sink.getNode(), allocsz)
23+
cfg.isSinkWithAllocationSize(sink.getNode(), allocsz)
2424
select sink, source, sink,
2525
"This operation, which is used in an $@, involves a $@ and might overflow.", allocsz,
2626
"allocation", source, "potentially large value"

go/ql/src/Security/CWE-322/InsecureHostKeyCallback.ql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ class HostKeyCallbackAssignmentConfig extends DataFlow::Configuration {
6666
/**
6767
* Holds if `sink` is a value written by `write` to a field `ClientConfig.HostKeyCallback`.
6868
*/
69-
predicate isSink(DataFlow::Node sink, Write write) {
69+
predicate writeIsSink(DataFlow::Node sink, Write write) {
7070
exists(Field f |
7171
f.hasQualifiedName(CryptoSsh::packagePath(), "ClientConfig", "HostKeyCallback") and
7272
write.writesField(_, f, sink)
7373
)
7474
}
7575

76-
override predicate isSink(DataFlow::Node sink) { this.isSink(sink, _) }
76+
override predicate isSink(DataFlow::Node sink) { this.writeIsSink(sink, _) }
7777
}
7878

7979
/**
@@ -92,8 +92,8 @@ predicate hostCheckReachesSink(DataFlow::PathNode sink) {
9292
SsaWithFields sinkAccessPath, SsaWithFields otherSinkAccessPath
9393
|
9494
config.hasFlowPath(source, otherSink) and
95-
config.isSink(sink.getNode(), sinkWrite) and
96-
config.isSink(otherSink.getNode(), otherSinkWrite) and
95+
config.writeIsSink(sink.getNode(), sinkWrite) and
96+
config.writeIsSink(otherSink.getNode(), otherSinkWrite) and
9797
sinkWrite.writesField(sinkAccessPath.getAUse(), _, sink.getNode()) and
9898
otherSinkWrite.writesField(otherSinkAccessPath.getAUse(), _, otherSink.getNode()) and
9999
otherSinkAccessPath = sinkAccessPath.similar()

go/ql/src/Security/CWE-327/InsecureTLS.ql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class TlsVersionFlowConfig extends TaintTracking::Configuration {
6060
/**
6161
* Holds if `source` is a TLS version source yielding value `val`.
6262
*/
63-
predicate isSource(DataFlow::Node source, int val) {
63+
predicate intIsSource(DataFlow::Node source, int val) {
6464
val = source.getIntValue() and
6565
val = getATlsVersion() and
6666
not DataFlow::isReturnedWithError(source)
@@ -74,7 +74,7 @@ class TlsVersionFlowConfig extends TaintTracking::Configuration {
7474
fieldWrite.writesField(base, fld, sink)
7575
}
7676

77-
override predicate isSource(DataFlow::Node source) { isSource(source, _) }
77+
override predicate isSource(DataFlow::Node source) { intIsSource(source, _) }
7878

7979
override predicate isSink(DataFlow::Node sink) { isSink(sink, _, _, _) }
8080
}
@@ -87,7 +87,7 @@ predicate secureTlsVersionFlow(
8787
) {
8888
exists(int version |
8989
config.hasFlowPath(source, sink) and
90-
config.isSource(source.getNode(), version) and
90+
config.intIsSource(source.getNode(), version) and
9191
not isInsecureTlsVersion(version, _, fld.getName())
9292
)
9393
}
@@ -130,7 +130,7 @@ predicate isInsecureTlsVersionFlow(
130130
) {
131131
exists(TlsVersionFlowConfig cfg, int version, Field fld |
132132
cfg.hasFlowPath(source, sink) and
133-
cfg.isSource(source.getNode(), version) and
133+
cfg.intIsSource(source.getNode(), version) and
134134
cfg.isSink(sink.getNode(), fld, base, _) and
135135
isInsecureTlsVersion(version, _, fld.getName()) and
136136
// Exclude cases where a secure TLS version can also flow to the same

go/ql/src/Security/CWE-338/InsecureRandomness.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import DataFlow::PathGraph
1717
from Configuration cfg, DataFlow::PathNode source, DataFlow::PathNode sink, string kind
1818
where
1919
cfg.hasFlowPath(source, sink) and
20-
cfg.isSink(sink.getNode(), kind) and
20+
cfg.isSinkWithKind(sink.getNode(), kind) and
2121
(
2222
kind != "A password-related function"
2323
or

0 commit comments

Comments
 (0)