Skip to content

Commit d948e10

Browse files
committed
Python: Move experimental HeaderInjection to new dataflow API
1 parent 53e57da commit d948e10

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

python/ql/src/experimental/Security/CWE-113/HeaderInjection.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
// determine precision above
1515
import python
1616
import experimental.semmle.python.security.injection.HTTPHeaders
17-
import DataFlow::PathGraph
17+
import HeaderInjectionFlow::PathGraph
1818

19-
from HeaderInjectionFlowConfig config, DataFlow::PathNode source, DataFlow::PathNode sink
20-
where config.hasFlowPath(source, sink)
19+
from HeaderInjectionFlow::PathNode source, HeaderInjectionFlow::PathNode sink
20+
where HeaderInjectionFlow::flowPath(source, sink)
2121
select sink.getNode(), source, sink, "This HTTP header is constructed from a $@.", source.getNode(),
2222
"user-provided value"

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ import semmle.python.dataflow.new.RemoteFlowSources
77
/**
88
* A taint-tracking configuration for detecting HTTP Header injections.
99
*/
10-
class HeaderInjectionFlowConfig extends TaintTracking::Configuration {
11-
HeaderInjectionFlowConfig() { this = "HeaderInjectionFlowConfig" }
10+
private module HeaderInjectionConfig implements DataFlow::ConfigSig {
11+
predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
1212

13-
override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
14-
15-
override predicate isSink(DataFlow::Node sink) {
13+
predicate isSink(DataFlow::Node sink) {
1614
exists(HeaderDeclaration headerDeclaration |
1715
sink in [headerDeclaration.getNameArg(), headerDeclaration.getValueArg()]
1816
)
1917
}
2018
}
19+
20+
/** Global taint-tracking for detecting "HTTP Header injection" vulnerabilities. */
21+
module HeaderInjectionFlow = TaintTracking::Global<HeaderInjectionConfig>;

0 commit comments

Comments
 (0)