mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
C#: Re-factor CodeInjection to use the new API.
This commit is contained in:
@@ -25,6 +25,8 @@ abstract class Sink extends DataFlow::ExprNode { }
|
||||
abstract class Sanitizer extends DataFlow::ExprNode { }
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use `CodeInjection` instead.
|
||||
*
|
||||
* A taint-tracking configuration for user input treated as code vulnerabilities.
|
||||
*/
|
||||
class TaintTrackingConfiguration extends TaintTracking::Configuration {
|
||||
@@ -37,6 +39,22 @@ class TaintTrackingConfiguration extends TaintTracking::Configuration {
|
||||
override predicate isSanitizer(DataFlow::Node node) { node instanceof Sanitizer }
|
||||
}
|
||||
|
||||
/**
|
||||
* A taint-tracking configuration for user input treated as code vulnerabilities.
|
||||
*/
|
||||
private module CodeInjectionConfig implements DataFlow::ConfigSig {
|
||||
predicate isSource(DataFlow::Node source) { source instanceof Source }
|
||||
|
||||
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
|
||||
|
||||
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
|
||||
}
|
||||
|
||||
/**
|
||||
* A taint-tracking module for user input treated as code vulnerabilities.
|
||||
*/
|
||||
module CodeInjection = TaintTracking::Global<CodeInjectionConfig>;
|
||||
|
||||
/** A source of remote user input. */
|
||||
class RemoteSource extends Source instanceof RemoteFlowSource { }
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
|
||||
import csharp
|
||||
import semmle.code.csharp.security.dataflow.CodeInjectionQuery
|
||||
import semmle.code.csharp.dataflow.DataFlow::DataFlow::PathGraph
|
||||
import CodeInjection::PathGraph
|
||||
|
||||
from TaintTrackingConfiguration c, DataFlow::PathNode source, DataFlow::PathNode sink
|
||||
where c.hasFlowPath(source, sink)
|
||||
from CodeInjection::PathNode source, CodeInjection::PathNode sink
|
||||
where CodeInjection::flowPath(source, sink)
|
||||
select sink.getNode(), source, sink, "This code compilation depends on a $@.", source.getNode(),
|
||||
"user-provided value"
|
||||
|
||||
Reference in New Issue
Block a user