Skip to content

Commit 5b85443

Browse files
committed
C#: Re-factor SettingsDataFlow to use the new API.
1 parent 5ea6cea commit 5b85443

File tree

1 file changed

+6
-12
lines changed
  • csharp/ql/lib/semmle/code/csharp/frameworks/system

1 file changed

+6
-12
lines changed

csharp/ql/lib/semmle/code/csharp/frameworks/system/Xml.qll

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,14 @@ class XmlReaderSettingsCreation extends ObjectCreation {
162162
}
163163
}
164164

165-
private class SettingsDataFlowConfig extends DataFlow3::Configuration {
166-
SettingsDataFlowConfig() { this = "SettingsDataFlowConfig" }
165+
private module SettingsDataFlowConfig implements DataFlow::ConfigSig {
166+
predicate isSource(DataFlow::Node source) { source.asExpr() instanceof XmlReaderSettingsCreation }
167167

168-
override predicate isSource(DataFlow::Node source) {
169-
source.asExpr() instanceof XmlReaderSettingsCreation
170-
}
171-
172-
override predicate isSink(DataFlow::Node sink) {
173-
sink.asExpr() instanceof XmlReaderSettingsInstance
174-
}
168+
predicate isSink(DataFlow::Node sink) { sink.asExpr() instanceof XmlReaderSettingsInstance }
175169
}
176170

171+
private module SettingsDataFlow = DataFlow::Global<SettingsDataFlowConfig>;
172+
177173
/** A call to `XmlReader.Create`. */
178174
class XmlReaderCreateCall extends MethodCall {
179175
XmlReaderCreateCall() { this.getTarget() = any(SystemXmlXmlReaderClass r).getCreateMethod() }
@@ -190,8 +186,6 @@ class XmlReaderSettingsInstance extends Expr {
190186

191187
/** Gets a possible creation point for this instance of `XmlReaderSettings`. */
192188
XmlReaderSettingsCreation getASettingsCreation() {
193-
exists(SettingsDataFlowConfig settingsFlow |
194-
settingsFlow.hasFlow(DataFlow::exprNode(result), DataFlow::exprNode(this))
195-
)
189+
SettingsDataFlow::flow(DataFlow::exprNode(result), DataFlow::exprNode(this))
196190
}
197191
}

0 commit comments

Comments
 (0)