mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Convert path injection barrier to MaD
This commit is contained in:
committed by
Anders Schack-Mulligen
parent
f6e40bd49d
commit
f6e3c77145
@@ -162,3 +162,8 @@ extensions:
|
|||||||
extensible: sourceModel
|
extensible: sourceModel
|
||||||
data:
|
data:
|
||||||
- ["java.io", "FileInputStream", True, "FileInputStream", "", "", "Argument[this]", "file", "manual"]
|
- ["java.io", "FileInputStream", True, "FileInputStream", "", "", "Argument[this]", "file", "manual"]
|
||||||
|
- addsTo:
|
||||||
|
pack: codeql/java-all
|
||||||
|
extensible: barrierModel
|
||||||
|
data:
|
||||||
|
- ["java.io", "File", True, "getName", "()", "", "ReturnValue", "path-injection", "manual"]
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ module;
|
|||||||
|
|
||||||
import java
|
import java
|
||||||
private import semmle.code.java.controlflow.Guards
|
private import semmle.code.java.controlflow.Guards
|
||||||
|
private import semmle.code.java.dataflow.ExternalFlow
|
||||||
private import semmle.code.java.dataflow.FlowSources
|
private import semmle.code.java.dataflow.FlowSources
|
||||||
private import semmle.code.java.dataflow.SSA
|
private import semmle.code.java.dataflow.SSA
|
||||||
private import semmle.code.java.frameworks.kotlin.IO
|
private import semmle.code.java.frameworks.kotlin.IO
|
||||||
@@ -288,19 +289,8 @@ private Method getSourceMethod(Method m) {
|
|||||||
result = m
|
result = m
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private class DefaultPathInjectionSanitizer extends PathInjectionSanitizer {
|
||||||
* A sanitizer that protects against path injection vulnerabilities
|
DefaultPathInjectionSanitizer() { barrierNode(this, "path-injection") }
|
||||||
* by extracting the final component of the user provided path.
|
|
||||||
*
|
|
||||||
* TODO: convert this class to models-as-data if sanitizer support is added
|
|
||||||
*/
|
|
||||||
private class FileGetNameSanitizer extends PathInjectionSanitizer {
|
|
||||||
FileGetNameSanitizer() {
|
|
||||||
exists(MethodCall mc |
|
|
||||||
mc.getMethod().hasQualifiedName("java.io", "File", "getName") and
|
|
||||||
this.asExpr() = mc
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Holds if `g` is a guard that checks for `..` components. */
|
/** Holds if `g` is a guard that checks for `..` components. */
|
||||||
|
|||||||
Reference in New Issue
Block a user