add a few arrary methods to TaintedPath.qll

This commit is contained in:
Erik Krogh Kristensen 2020-02-11 11:19:57 +01:00
Родитель b9bc21637e
Коммит 35d8151374
2 изменённых файлов: 36 добавлений и 5 удалений

Просмотреть файл

@ -93,13 +93,38 @@ module TaintedPath {
|
name = argumentlessMethodName
)
or
)
or
// array method calls of interest
exists(DataFlow::MethodCallNode mcn, string name | dst = mcn and mcn.calls(src, name) |
// A `str.split()` call can either split into path elements (`str.split("/")`) or split by some other string.
name = "split" and
not exists(DataFlow::Node splitBy | splitBy = mcn.getArgument(0) |
splitBy.mayHaveStringValue("/") or
any(DataFlow::RegExpLiteralNode reg | reg.getRoot().getAMatchedString() = "/")
.flowsTo(splitBy)
(
if
exists(DataFlow::Node splitBy | splitBy = mcn.getArgument(0) |
splitBy.mayHaveStringValue("/") or
any(DataFlow::RegExpLiteralNode reg | reg.getRoot().getAMatchedString() = "/")
.flowsTo(splitBy)
)
then
srclabel.(Label::PosixPath).canContainDotDotSlash() and
dstlabel instanceof Label::SplitPath
else srclabel = dstlabel
)
or
(
name = "pop" or
name = "shift" or
name = "slice" or
name = "splice"
) and
dstlabel instanceof Label::SplitPath and
srclabel instanceof Label::SplitPath
or
name = "join" and
mcn.getArgument(0).mayHaveStringValue("/") and
srclabel instanceof Label::SplitPath and
dstlabel.(Label::PosixPath).canContainDotDotSlash()
)
}

Просмотреть файл

@ -108,6 +108,12 @@ module TaintedPath {
not (isNormalized() and isAbsolute())
}
}
class SplitPath extends DataFlow::FlowLabel {
SplitPath() {
this = "splitPath"
}
}
}
/**