|
3 | 3 | */ |
4 | 4 |
|
5 | 5 | import go |
6 | | -private import semmle.go.dataflow.DataFlowForStringsNewReplacer |
7 | 6 |
|
8 | 7 | /** Provides predicates and classes for working with string operations. */ |
9 | 8 | module StringOps { |
@@ -228,34 +227,28 @@ module StringOps { |
228 | 227 | * the receiver of a call to `strings.Replacer.Replace` or |
229 | 228 | * `strings.Replacer.WriteString`. |
230 | 229 | */ |
231 | | - private class StringsNewReplacerConfiguration extends DataFlowForStringsNewReplacer::Configuration |
232 | | - { |
233 | | - StringsNewReplacerConfiguration() { this = "StringsNewReplacerConfiguration" } |
| 230 | + private module StringsNewReplacerConfig implements DataFlow::ConfigSig { |
| 231 | + predicate isSource(DataFlow::Node source) { source instanceof StringsNewReplacerCall } |
234 | 232 |
|
235 | | - override predicate isSource(DataFlow::Node source) { |
236 | | - source instanceof StringsNewReplacerCall |
237 | | - } |
238 | | - |
239 | | - override predicate isSink(DataFlow::Node sink) { |
| 233 | + predicate isSink(DataFlow::Node sink) { |
240 | 234 | exists(DataFlow::MethodCallNode call | |
241 | 235 | sink = call.getReceiver() and |
242 | 236 | call.getTarget().hasQualifiedName("strings", "Replacer", ["Replace", "WriteString"]) |
243 | 237 | ) |
244 | 238 | } |
245 | 239 | } |
246 | 240 |
|
| 241 | + private module StringsNewReplacerFlow = DataFlow::Global<StringsNewReplacerConfig>; |
| 242 | + |
247 | 243 | /** |
248 | 244 | * A call to `strings.Replacer.Replace` or `strings.Replacer.WriteString`. |
249 | 245 | */ |
250 | 246 | private class StringsReplacerReplaceOrWriteString extends Range { |
251 | 247 | string replacedString; |
252 | 248 |
|
253 | 249 | StringsReplacerReplaceOrWriteString() { |
254 | | - exists( |
255 | | - StringsNewReplacerConfiguration config, StringsNewReplacerCall source, |
256 | | - DataFlow::Node sink, DataFlow::MethodCallNode call |
257 | | - | |
258 | | - config.hasFlow(source, sink) and |
| 250 | + exists(StringsNewReplacerCall source, DataFlow::Node sink, DataFlow::MethodCallNode call | |
| 251 | + StringsNewReplacerFlow::flow(source, sink) and |
259 | 252 | sink = call.getReceiver() and |
260 | 253 | replacedString = source.getAReplacedArgument().getStringValue() and |
261 | 254 | ( |
|
0 commit comments