mirror of
https://github.com/github/codeql.git
synced 2026-06-25 06:37:07 +02:00
71 lines
2.1 KiB
Plaintext
71 lines
2.1 KiB
Plaintext
/**
|
|
* Provides default sources, sinks and sanitizers for detecting
|
|
* "code injection"
|
|
* vulnerabilities, as well as extension points for adding your own.
|
|
*/
|
|
|
|
private import python
|
|
private import semmle.python.dataflow.new.DataFlow
|
|
private import semmle.python.Concepts
|
|
private import semmle.python.dataflow.new.RemoteFlowSources
|
|
private import semmle.python.dataflow.new.BarrierGuards
|
|
private import semmle.python.frameworks.data.ModelsAsData
|
|
|
|
/**
|
|
* Provides default sources, sinks and sanitizers for detecting
|
|
* "code injection"
|
|
* vulnerabilities, as well as extension points for adding your own.
|
|
*/
|
|
module CodeInjection {
|
|
/**
|
|
* A data flow source for "code injection" vulnerabilities.
|
|
*/
|
|
abstract class Source extends DataFlow::Node { }
|
|
|
|
/**
|
|
* A data flow sink for "code injection" vulnerabilities.
|
|
*/
|
|
abstract class Sink extends DataFlow::Node { }
|
|
|
|
/**
|
|
* A sanitizer for "code injection" vulnerabilities.
|
|
*/
|
|
abstract class Sanitizer extends DataFlow::Node { }
|
|
|
|
/**
|
|
* DEPRECATED: Use `ActiveThreatModelSource` from Concepts instead!
|
|
*/
|
|
deprecated class RemoteFlowSourceAsSource = ActiveThreatModelSourceAsSource;
|
|
|
|
/**
|
|
* An active threat-model source, considered as a flow source.
|
|
*/
|
|
private class ActiveThreatModelSourceAsSource extends Source, ActiveThreatModelSource { }
|
|
|
|
/**
|
|
* A code execution, considered as a flow sink.
|
|
*/
|
|
class CodeExecutionAsSink extends Sink {
|
|
CodeExecutionAsSink() { this = any(CodeExecution e).getCode() }
|
|
}
|
|
|
|
private class SinkFromModel extends Sink {
|
|
SinkFromModel() { ModelOutput::sinkNode(this, "code-injection") }
|
|
}
|
|
|
|
/**
|
|
* A comparison with a constant, considered as a sanitizer-guard.
|
|
*/
|
|
class ConstCompareAsSanitizerGuard extends Sanitizer, ConstCompareBarrier { }
|
|
|
|
/** DEPRECATED: Use ConstCompareAsSanitizerGuard instead. */
|
|
deprecated class StringConstCompareAsSanitizerGuard = ConstCompareAsSanitizerGuard;
|
|
|
|
/**
|
|
* A sanitizer defined via models-as-data with kind "code-injection".
|
|
*/
|
|
class SanitizerFromModel extends Sanitizer {
|
|
SanitizerFromModel() { ModelOutput::barrierNode(this, "code-injection") }
|
|
}
|
|
}
|