Skip to content

Commit abbd1d1

Browse files
committed
Python: Fix errors introduced during port
testing on a database helps..
1 parent 6c82dae commit abbd1d1

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

python/ql/lib/semmle/python/security/injection/RegexInjectionCustomizations.qll

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@ module RegexInjection {
2525
* A sink for "regular expression injection" vulnerabilities is the execution of a regular expression.
2626
* If you have a custom way to execute regular expressions, you can extend `RegexExecution::Range`.
2727
*/
28-
class Sink extends RegexExecution { }
28+
class Sink extends DataFlow::Node {
29+
RegexExecution regexExecution;
30+
31+
Sink() { this = regexExecution.getRegexNode() }
32+
33+
/** Gets the call that executes the regular expression marked by this sink. */
34+
RegexExecution getRegexExecution() { result = regexExecution }
35+
}
2936

3037
/**
3138
* A sanitizer for "regular expression injection" vulnerabilities.

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313

1414
// determine precision above
1515
import python
16+
private import semmle.python.Concepts
1617
import semmle.python.security.injection.RegexInjection
1718
import DataFlow::PathGraph
1819

1920
from
2021
RegexInjection::Configuration config, DataFlow::PathNode source, DataFlow::PathNode sink,
21-
RegexInjection::Sink regexInjectionSink
22+
RegexExecution regexExecution
2223
where
2324
config.hasFlowPath(source, sink) and
24-
regexInjectionSink = sink.getNode()
25+
regexExecution = sink.getNode().(RegexInjection::Sink).getRegexExecution()
2526
select sink.getNode(), source, sink,
26-
"$@ regular expression is constructed from a $@ and executed by $@.",
27-
regexInjectionSink.getRegexNode(), "This", source.getNode(), "user-provided value",
28-
regexInjectionSink, regexInjectionSink.getName()
27+
"$@ regular expression is constructed from a $@ and executed by $@.", sink.getNode(), "This",
28+
source.getNode(), "user-provided value", regexExecution, regexExecution.getName()

0 commit comments

Comments
 (0)