Skip to content

Commit f751103

Browse files
committed
Fix Sink utilization in select
1 parent a5850f4 commit f751103

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

python/ql/src/experimental/Security/CWE-730/RegexInjection.ql

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,10 @@ import python
1616
import experimental.semmle.python.security.injection.RegexInjection
1717
import DataFlow::PathGraph
1818

19-
from
20-
RegexInjectionFlowConfig config, DataFlow::PathNode source, DataFlow::PathNode sink,
21-
RegexInjectionSink castedSink
22-
where
23-
config.hasFlowPath(source, sink) and
24-
castedSink = sink.getNode()
19+
from RegexInjectionFlowConfig config, DataFlow::PathNode source, DataFlow::PathNode sink
20+
where config.hasFlowPath(source, sink)
2521
select sink.getNode(), source, sink,
2622
"$@ regular expression is constructed from a $@ and executed by $@.", sink.getNode(), "This",
27-
source.getNode(), "user-provided value", castedSink,
28-
castedSink.getRegexModule() + "." + castedSink.asExpr().(Attribute).getName()
23+
source.getNode(), "user-provided value", sink.getNode(),
24+
sink.getNode().(RegexInjectionSink).getRegexModule() + "." +
25+
sink.getNode().(RegexInjectionSink).getRegexMethod().getName()

python/ql/src/experimental/semmle/python/security/injection/RegexInjection.qll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@ import semmle.python.dataflow.new.RemoteFlowSources
1111

1212
class RegexInjectionSink extends DataFlow::Node {
1313
string regexModule;
14+
Attribute regexMethod;
1415

1516
RegexInjectionSink() {
1617
exists(RegexExecution reExec |
1718
this = reExec.getRegexNode() and
18-
regexModule = reExec.getRegexModule()
19+
regexModule = reExec.getRegexModule() and
20+
regexMethod = reExec.(DataFlow::CallCfgNode).getFunction().asExpr().(Attribute)
1921
)
2022
}
2123

2224
string getRegexModule() { result = regexModule }
25+
26+
Attribute getRegexMethod() { result = regexMethod }
2327
}
2428

2529
/**

0 commit comments

Comments
 (0)