Merge pull request #5653 from erik-krogh/givenCommand

Approved by asgerf
This commit is contained in:
CodeQL CI
2021-04-12 02:01:32 -07:00
committed by GitHub
2 changed files with 11 additions and 1 deletions

View File

@@ -53,7 +53,12 @@ module UnsafeShellCommandConstruction {
class ExternalInputSource extends Source, DataFlow::ParameterNode {
ExternalInputSource() {
this = Exports::getALibraryInputParameter() and
not this.getName() = ["cmd", "command"] // looks to be on purpose.
not (
// looks to be on purpose.
this.getName() = ["cmd", "command"]
or
this.getName().regexpMatch(".*(Cmd|Command)$") // ends with "Cmd" or "Command"
)
}
}

View File

@@ -483,4 +483,9 @@ module.exports.splitConcat = function (name) {
let args = ' my name is ' + name; // NOT OK
let cmd = 'echo';
cp.exec(cmd + args);
}
module.exports.myCommand = function (myCommand) {
let cmd = `cd ${cwd} ; ${myCommand}`; // OK - the parameter name suggests that it is purposely a shell command.
cp.exec(cmd);
}