mirror of
https://github.com/github/codeql.git
synced 2026-04-27 17:55:19 +02:00
@@ -190,6 +190,27 @@ module UnsafeShellCommandConstruction {
|
||||
override DataFlow::Node getAlertLocation() { result = this }
|
||||
}
|
||||
|
||||
/**
|
||||
* A joined path (`path.{resolve/join}(..)`) that is later executed as a shell command.
|
||||
* Joining a path is similar to string concatenation that automatically inserts slashes.
|
||||
*/
|
||||
class JoinedPathEndingInCommandExecutionSink extends Sink {
|
||||
DataFlow::MethodCallNode joinCall;
|
||||
SystemCommandExecution sys;
|
||||
|
||||
JoinedPathEndingInCommandExecutionSink() {
|
||||
this = joinCall.getAnArgument() and
|
||||
joinCall = DataFlow::moduleMember("path", ["resolve", "join"]).getACall() and
|
||||
joinCall = isExecutedAsShellCommand(DataFlow::TypeBackTracker::end(), sys)
|
||||
}
|
||||
|
||||
override string getSinkType() { result = "Path concatenation" }
|
||||
|
||||
override SystemCommandExecution getCommandExecution() { result = sys }
|
||||
|
||||
override DataFlow::Node getAlertLocation() { result = this }
|
||||
}
|
||||
|
||||
/**
|
||||
* A sanitizer like: "'"+name.replace(/'/g,"'\\''")+"'"
|
||||
* Which sanitizes on Unix.
|
||||
|
||||
Reference in New Issue
Block a user