C#: Re-factor SettingsDataFlow to use the new API.

This commit is contained in:
Michael Nebel
2023-04-14 12:02:33 +02:00
parent 5ea6cea894
commit 5b8544343b

View File

@@ -162,18 +162,14 @@ class XmlReaderSettingsCreation extends ObjectCreation {
}
}
private class SettingsDataFlowConfig extends DataFlow3::Configuration {
SettingsDataFlowConfig() { this = "SettingsDataFlowConfig" }
private module SettingsDataFlowConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { source.asExpr() instanceof XmlReaderSettingsCreation }
override predicate isSource(DataFlow::Node source) {
source.asExpr() instanceof XmlReaderSettingsCreation
}
override predicate isSink(DataFlow::Node sink) {
sink.asExpr() instanceof XmlReaderSettingsInstance
}
predicate isSink(DataFlow::Node sink) { sink.asExpr() instanceof XmlReaderSettingsInstance }
}
private module SettingsDataFlow = DataFlow::Global<SettingsDataFlowConfig>;
/** A call to `XmlReader.Create`. */
class XmlReaderCreateCall extends MethodCall {
XmlReaderCreateCall() { this.getTarget() = any(SystemXmlXmlReaderClass r).getCreateMethod() }
@@ -190,8 +186,6 @@ class XmlReaderSettingsInstance extends Expr {
/** Gets a possible creation point for this instance of `XmlReaderSettings`. */
XmlReaderSettingsCreation getASettingsCreation() {
exists(SettingsDataFlowConfig settingsFlow |
settingsFlow.hasFlow(DataFlow::exprNode(result), DataFlow::exprNode(this))
)
SettingsDataFlow::flow(DataFlow::exprNode(result), DataFlow::exprNode(this))
}
}