Skip to content

Commit c10d03e

Browse files
authored
Merge pull request github#13820 from owen-mc/go/refactor-data-flow-configurations
Go: Make flow configurations use new data flow API
2 parents 36bdadf + 35a300f commit c10d03e

File tree

138 files changed

+2467
-2523
lines changed

Some content is hidden

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

138 files changed

+2467
-2523
lines changed

config/identical-files.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowImpl5.qll",
2323
"go/ql/lib/semmle/go/dataflow/internal/DataFlowImpl1.qll",
2424
"go/ql/lib/semmle/go/dataflow/internal/DataFlowImpl2.qll",
25-
"go/ql/lib/semmle/go/dataflow/internal/DataFlowImplForStringsNewReplacer.qll",
2625
"python/ql/lib/semmle/python/dataflow/new/internal/DataFlowImpl1.qll",
2726
"python/ql/lib/semmle/python/dataflow/new/internal/DataFlowImpl2.qll",
2827
"python/ql/lib/semmle/python/dataflow/new/internal/DataFlowImpl3.qll",
@@ -572,4 +571,4 @@
572571
"python/ql/lib/semmle/python/security/internal/EncryptionKeySizes.qll",
573572
"java/ql/lib/semmle/code/java/security/internal/EncryptionKeySizes.qll"
574573
]
575-
}
574+
}

go/ql/lib/semmle/go/StringOps.qll

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
*/
44

55
import go
6-
private import semmle.go.dataflow.DataFlowForStringsNewReplacer
76

87
/** Provides predicates and classes for working with string operations. */
98
module StringOps {
@@ -223,39 +222,32 @@ module StringOps {
223222
}
224223
}
225224

226-
/**
227-
* A configuration for tracking flow from a call to `strings.NewReplacer` to
228-
* the receiver of a call to `strings.Replacer.Replace` or
229-
* `strings.Replacer.WriteString`.
230-
*/
231-
private class StringsNewReplacerConfiguration extends DataFlowForStringsNewReplacer::Configuration
232-
{
233-
StringsNewReplacerConfiguration() { this = "StringsNewReplacerConfiguration" }
234-
235-
override predicate isSource(DataFlow::Node source) {
236-
source instanceof StringsNewReplacerCall
237-
}
225+
private module StringsNewReplacerConfig implements DataFlow::ConfigSig {
226+
predicate isSource(DataFlow::Node source) { source instanceof StringsNewReplacerCall }
238227

239-
override predicate isSink(DataFlow::Node sink) {
228+
predicate isSink(DataFlow::Node sink) {
240229
exists(DataFlow::MethodCallNode call |
241230
sink = call.getReceiver() and
242231
call.getTarget().hasQualifiedName("strings", "Replacer", ["Replace", "WriteString"])
243232
)
244233
}
245234
}
246235

236+
/**
237+
* Tracks data flow from a call to `strings.NewReplacer` to the receiver of
238+
* a call to `strings.Replacer.Replace` or `strings.Replacer.WriteString`.
239+
*/
240+
private module StringsNewReplacerFlow = DataFlow::Global<StringsNewReplacerConfig>;
241+
247242
/**
248243
* A call to `strings.Replacer.Replace` or `strings.Replacer.WriteString`.
249244
*/
250245
private class StringsReplacerReplaceOrWriteString extends Range {
251246
string replacedString;
252247

253248
StringsReplacerReplaceOrWriteString() {
254-
exists(
255-
StringsNewReplacerConfiguration config, StringsNewReplacerCall source,
256-
DataFlow::Node sink, DataFlow::MethodCallNode call
257-
|
258-
config.hasFlow(source, sink) and
249+
exists(StringsNewReplacerCall source, DataFlow::Node sink, DataFlow::MethodCallNode call |
250+
StringsNewReplacerFlow::flow(source, sink) and
259251
sink = call.getReceiver() and
260252
replacedString = source.getAReplacedArgument().getStringValue() and
261253
(

go/ql/lib/semmle/go/dataflow/DataFlowForStringsNewReplacer.qll

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)