Refactor PartialPathTraversal

This commit is contained in:
Ed Minnix
2023-03-21 18:01:57 -04:00
parent f8e26f1571
commit 469ac80d40
3 changed files with 37 additions and 13 deletions

View File

@@ -1,21 +1,24 @@
import java
import TestUtilities.InlineFlowTest
import TestUtilities.InlineExpectationsTest
import semmle.code.java.security.PartialPathTraversalQuery
class EnableLegacy extends EnableLegacyConfiguration {
EnableLegacy() { exists(this) }
}
class TestRemoteSource extends RemoteFlowSource {
TestRemoteSource() { this.asParameter().hasName(["dir", "path"]) }
override string getSourceType() { result = "TestSource" }
}
class Test extends InlineFlowTest {
override DataFlow::Configuration getValueFlowConfig() { none() }
class Test extends InlineExpectationsTest {
Test() { this = "PartialPathTraversalFromRemoteTest" }
override TaintTracking::Configuration getTaintFlowConfig() {
result instanceof PartialPathTraversalFromRemoteConfig
override string getARelevantTag() { result = "hasTaintFlow" }
override predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "hasTaintFlow" and
exists(DataFlow::Node sink | PartialPathTraversalFromRemoteFlow::flowTo(sink) |
sink.getLocation() = location and
element = sink.toString() and
value = ""
)
}
}