mirror of
https://github.com/github/codeql.git
synced 2026-05-02 04:05:14 +02:00
Fix Sink utilization in select
This commit is contained in:
@@ -16,13 +16,10 @@ import python
|
||||
import experimental.semmle.python.security.injection.RegexInjection
|
||||
import DataFlow::PathGraph
|
||||
|
||||
from
|
||||
RegexInjectionFlowConfig config, DataFlow::PathNode source, DataFlow::PathNode sink,
|
||||
RegexInjectionSink castedSink
|
||||
where
|
||||
config.hasFlowPath(source, sink) and
|
||||
castedSink = sink.getNode()
|
||||
from RegexInjectionFlowConfig config, DataFlow::PathNode source, DataFlow::PathNode sink
|
||||
where config.hasFlowPath(source, sink)
|
||||
select sink.getNode(), source, sink,
|
||||
"$@ regular expression is constructed from a $@ and executed by $@.", sink.getNode(), "This",
|
||||
source.getNode(), "user-provided value", castedSink,
|
||||
castedSink.getRegexModule() + "." + castedSink.asExpr().(Attribute).getName()
|
||||
source.getNode(), "user-provided value", sink.getNode(),
|
||||
sink.getNode().(RegexInjectionSink).getRegexModule() + "." +
|
||||
sink.getNode().(RegexInjectionSink).getRegexMethod().getName()
|
||||
|
||||
@@ -11,15 +11,19 @@ import semmle.python.dataflow.new.RemoteFlowSources
|
||||
|
||||
class RegexInjectionSink extends DataFlow::Node {
|
||||
string regexModule;
|
||||
Attribute regexMethod;
|
||||
|
||||
RegexInjectionSink() {
|
||||
exists(RegexExecution reExec |
|
||||
this = reExec.getRegexNode() and
|
||||
regexModule = reExec.getRegexModule()
|
||||
regexModule = reExec.getRegexModule() and
|
||||
regexMethod = reExec.(DataFlow::CallCfgNode).getFunction().asExpr().(Attribute)
|
||||
)
|
||||
}
|
||||
|
||||
string getRegexModule() { result = regexModule }
|
||||
|
||||
Attribute getRegexMethod() { result = regexMethod }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user