Skip to content

Commit 07fdcf2

Browse files
committed
Refactor Security.CWE.CWE-022.ZipSlip
1 parent e60e1a2 commit 07fdcf2

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

java/ql/src/Security/CWE/CWE-022/ZipSlip.ql

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ import semmle.code.java.controlflow.Guards
1717
import semmle.code.java.dataflow.SSA
1818
import semmle.code.java.dataflow.TaintTracking
1919
import semmle.code.java.security.PathSanitizer
20-
import DataFlow
21-
import PathGraph
2220
private import semmle.code.java.dataflow.ExternalFlow
2321

2422
/**
@@ -36,27 +34,29 @@ class ArchiveEntryNameMethod extends Method {
3634
}
3735
}
3836

39-
class ZipSlipConfiguration extends TaintTracking::Configuration {
40-
ZipSlipConfiguration() { this = "ZipSlip" }
41-
42-
override predicate isSource(Node source) {
37+
private module ZipSlipConfiguration implements DataFlow::ConfigSig {
38+
predicate isSource(DataFlow::Node source) {
4339
source.asExpr().(MethodAccess).getMethod() instanceof ArchiveEntryNameMethod
4440
}
4541

46-
override predicate isSink(Node sink) { sink instanceof FileCreationSink }
42+
predicate isSink(DataFlow::Node sink) { sink instanceof FileCreationSink }
4743

48-
override predicate isSanitizer(Node node) { node instanceof PathInjectionSanitizer }
44+
predicate isBarrier(DataFlow::Node node) { node instanceof PathInjectionSanitizer }
4945
}
5046

47+
module ZipSlipFlow = TaintTracking::Make<ZipSlipConfiguration>;
48+
49+
import ZipSlipFlow::PathGraph
50+
5151
/**
5252
* A sink that represents a file creation, such as a file write, copy or move operation.
5353
*/
5454
private class FileCreationSink extends DataFlow::Node {
5555
FileCreationSink() { sinkNode(this, "create-file") }
5656
}
5757

58-
from PathNode source, PathNode sink
59-
where any(ZipSlipConfiguration c).hasFlowPath(source, sink)
58+
from ZipSlipFlow::PathNode source, ZipSlipFlow::PathNode sink
59+
where ZipSlipFlow::hasFlowPath(source, sink)
6060
select source.getNode(), source, sink,
6161
"Unsanitized archive entry, which may contain '..', is used in a $@.", sink.getNode(),
6262
"file system operation"

0 commit comments

Comments
 (0)