Skip to content

Commit a739f49

Browse files
committed
Address review comments
1 parent 503a716 commit a739f49

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ module LogInjection {
6565
*/
6666
class ReplacerReplaceSanitizer extends Sanitizer {
6767
ReplacerReplaceSanitizer() {
68-
this.(DataFlow::MethodCallNode).getTarget().hasQualifiedName("strings", "Replacer", "Replace")
68+
exists(DataFlow::MethodCallNode call |
69+
call.(DataFlow::MethodCallNode)
70+
.getTarget()
71+
.hasQualifiedName("strings", "Replacer", "Replace") and
72+
this = call.getResult()
73+
)
6974
}
7075
}
7176

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,7 @@ module StringBreak {
109109
class StringsNewReplacerCall extends DataFlow::CallNode {
110110
StringsNewReplacerCall() { this.getTarget().hasQualifiedName("strings", "NewReplacer") }
111111

112-
DataFlow::Node getAReplacedArgument() {
113-
exists(int m, int n | m = 2 * n and n = m / 2 and result = getArgument(m))
114-
}
112+
DataFlow::Node getAReplacedArgument() { exists(int n | n % 2 = 0 and result = getArgument(n)) }
115113
}
116114

117115
class StringsNewReplacerConfiguration extends DataFlow2::Configuration {
@@ -135,10 +133,14 @@ module StringBreak {
135133
Quote quote;
136134

137135
ReplacerReplaceSanitizer() {
138-
exists(StringsNewReplacerConfiguration config, DataFlow::Node source, DataFlow::Node sink |
136+
exists(
137+
StringsNewReplacerConfiguration config, DataFlow::Node source, DataFlow::Node sink,
138+
DataFlow::MethodCallNode call
139+
|
139140
config.hasFlow(source, sink) and
140-
this.getTarget().hasQualifiedName("strings", "Replacer", "Replace") and
141-
sink = this.getReceiver() and
141+
call.getTarget().hasQualifiedName("strings", "Replacer", "Replace") and
142+
sink = call.getReceiver() and
143+
this = call.getResult() and
142144
quote = source.(StringsNewReplacerCall).getAReplacedArgument().getStringValue()
143145
)
144146
}

0 commit comments

Comments
 (0)