mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
C#: Re-factor the dataflow/global tests.
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
import csharp
|
||||
|
||||
class Config extends DataFlow::Configuration {
|
||||
Config() { this = "Config" }
|
||||
|
||||
override predicate isSource(DataFlow::Node source) {
|
||||
module FlowConfig implements DataFlow::ConfigSig {
|
||||
predicate isSource(DataFlow::Node source) {
|
||||
source.asExpr().(StringLiteral).getValue() = "taint source"
|
||||
or
|
||||
source.asParameter().hasName("tainted")
|
||||
}
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) {
|
||||
predicate isSink(DataFlow::Node sink) {
|
||||
exists(MethodCall mc |
|
||||
mc.getTarget().getUndecoratedName() = "Check" and
|
||||
mc.getAnArgument() = sink.asExpr()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
module Flow = DataFlow::Global<FlowConfig>;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import csharp
|
||||
import Common
|
||||
|
||||
from Config c, DataFlow::Node source, DataFlow::Node sink
|
||||
where c.hasFlow(source, sink)
|
||||
from DataFlow::Node source, DataFlow::Node sink
|
||||
where Flow::flow(source, sink)
|
||||
select sink
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
|
||||
import csharp
|
||||
import Common
|
||||
import DataFlow::PathGraph
|
||||
import Flow::PathGraph
|
||||
|
||||
from Config c, DataFlow::PathNode source, DataFlow::PathNode sink, string s
|
||||
from Flow::PathNode source, Flow::PathNode sink, string s
|
||||
where
|
||||
c.hasFlowPath(source, sink) and
|
||||
Flow::flowPath(source, sink) and
|
||||
s = sink.toString()
|
||||
select sink, source, sink, s order by s
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
import csharp
|
||||
import Common
|
||||
|
||||
class TTConfig extends TaintTracking::Configuration instanceof Config {
|
||||
override predicate isSource(DataFlow::Node source) { Config.super.isSource(source) }
|
||||
module Taint = TaintTracking::Global<FlowConfig>;
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) { Config.super.isSink(sink) }
|
||||
}
|
||||
|
||||
from TTConfig c, DataFlow::Node source, DataFlow::Node sink
|
||||
where c.hasFlow(source, sink)
|
||||
from DataFlow::Node source, DataFlow::Node sink
|
||||
where Taint::flow(source, sink)
|
||||
select sink
|
||||
|
||||
@@ -4,16 +4,12 @@
|
||||
|
||||
import csharp
|
||||
import Common
|
||||
import DataFlow::PathGraph
|
||||
import Taint::PathGraph
|
||||
|
||||
class TTConfig extends TaintTracking::Configuration instanceof Config {
|
||||
override predicate isSource(DataFlow::Node source) { Config.super.isSource(source) }
|
||||
module Taint = TaintTracking::Global<FlowConfig>;
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) { Config.super.isSink(sink) }
|
||||
}
|
||||
|
||||
from TTConfig c, DataFlow::PathNode source, DataFlow::PathNode sink, string s
|
||||
from Taint::PathNode source, Taint::PathNode sink, string s
|
||||
where
|
||||
c.hasFlowPath(source, sink) and
|
||||
Taint::flowPath(source, sink) and
|
||||
s = sink.toString()
|
||||
select sink, source, sink, s
|
||||
|
||||
Reference in New Issue
Block a user