mirror of
https://github.com/github/codeql.git
synced 2025-12-21 19:26:31 +01:00
add a few arrary methods to TaintedPath.qll
This commit is contained in:
@@ -93,13 +93,38 @@ module TaintedPath {
|
|||||||
|
|
|
|
||||||
name = argumentlessMethodName
|
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
|
name = "split" and
|
||||||
not exists(DataFlow::Node splitBy | splitBy = mcn.getArgument(0) |
|
(
|
||||||
|
if
|
||||||
|
exists(DataFlow::Node splitBy | splitBy = mcn.getArgument(0) |
|
||||||
splitBy.mayHaveStringValue("/") or
|
splitBy.mayHaveStringValue("/") or
|
||||||
any(DataFlow::RegExpLiteralNode reg | reg.getRoot().getAMatchedString() = "/")
|
any(DataFlow::RegExpLiteralNode reg | reg.getRoot().getAMatchedString() = "/")
|
||||||
.flowsTo(splitBy)
|
.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())
|
not (isNormalized() and isAbsolute())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class SplitPath extends DataFlow::FlowLabel {
|
||||||
|
SplitPath() {
|
||||||
|
this = "splitPath"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user