Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d5c9af3

Browse files
committed
Fixup documentation/code from PR feedback
1 parent f7a4aac commit d5c9af3

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

java/ql/src/Security/CWE/CWE-200/TempDirLocalInformationDisclosureFromSystemProperty.ql

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ private class FileFileCreationSink extends FileCreationSink {
3636
}
3737

3838
/**
39-
* The argument to
40-
a call to one of `Files` file-creating or directory-creating methods, treated as a sink by `TempDirSystemGetPropertyToCreateConfig`.
39+
* The argument to
40+
* a call to one of `Files` file-creating or directory-creating methods, treated as a sink by `TempDirSystemGetPropertyToCreateConfig`.
4141
*/
4242
private class FilesFileCreationSink extends FileCreationSink {
4343
FilesFileCreationSink() {
@@ -81,6 +81,12 @@ private class TempDirSystemGetPropertyToCreateConfig extends TaintTracking::Conf
8181
source.asExpr() instanceof MethodAccessSystemGetPropertyTempDirTainted
8282
}
8383

84+
/**
85+
* Find dataflow from the temp directory system property to the `File` constructor.
86+
* Examples:
87+
* - `new File(System.getProperty("java.io.tmpdir"))`
88+
* - `new File(new File(System.getProperty("java.io.tmpdir")), "/child")`
89+
*/
8490
override predicate isAdditionalTaintStep(DataFlow::Node node1, DataFlow::Node node2) {
8591
isAdditionalFileTaintStep(node1, node2)
8692
}

java/ql/src/Security/CWE/CWE-200/TempDirUtils.qll

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ class MethodFileCreateTempFile extends Method {
4444
}
4545

4646
/**
47-
* Find dataflow from the temp directory system property to the `File` constructor.
48-
* Examples:
49-
* - `new File(System.getProperty("java.io.tmpdir"))`
50-
* - `new File(new File(System.getProperty("java.io.tmpdir")), "/child")`
47+
* Holds if `expDest` is some constructor call `new java.io.File(x)` and `expSource` is `x`.
5148
*/
5249
private predicate isFileConstructorArgument(Expr expSource, Expr exprDest) {
5350
exists(ConstructorCall construtorCall |
@@ -69,7 +66,7 @@ private class TaintFollowingFileMethod extends Method {
6966

7067
private predicate isTaintPropagatingFileTransformation(Expr expSource, Expr exprDest) {
7168
exists(MethodAccess fileMethodAccess |
72-
fileMethodAccess.getMethod() instanceof TaintPropagatingFileMethod and
69+
fileMethodAccess.getMethod() instanceof TaintFollowingFileMethod and
7370
fileMethodAccess.getQualifier() = expSource and
7471
fileMethodAccess = exprDest
7572
)
@@ -80,6 +77,6 @@ private predicate isTaintPropagatingFileTransformation(Expr expSource, Expr expr
8077
* For example, `taintedFile.getCanonicalFile()` is itself tainted.
8178
*/
8279
predicate isAdditionalFileTaintStep(DataFlow::Node node1, DataFlow::Node node2) {
83-
isTaintedFileCreation(node1.asExpr(), node2.asExpr()) or
84-
isTaintFollowingFileTransformation(node1.asExpr(), node2.asExpr())
80+
isFileConstructorArgument(node1.asExpr(), node2.asExpr()) or
81+
isTaintPropagatingFileTransformation(node1.asExpr(), node2.asExpr())
8582
}

0 commit comments

Comments
 (0)