File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
src/semmle/javascript/security/dataflow
test/query-tests/Security/CWE-078/lib Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,12 @@ module UnsafeShellCommandConstruction {
5353 class ExternalInputSource extends Source , DataFlow:: ParameterNode {
5454 ExternalInputSource ( ) {
5555 this = Exports:: getALibraryInputParameter ( ) and
56- not this .getName ( ) = [ "cmd" , "command" ] // looks to be on purpose.
56+ not (
57+ // looks to be on purpose.
58+ this .getName ( ) = [ "cmd" , "command" ]
59+ or
60+ this .getName ( ) .regexpMatch ( ".*(Cmd|Command)$" ) // ends with "Cmd" or "Command"
61+ )
5762 }
5863 }
5964
Original file line number Diff line number Diff line change @@ -483,4 +483,9 @@ module.exports.splitConcat = function (name) {
483483 let args = ' my name is ' + name ; // NOT OK
484484 let cmd = 'echo' ;
485485 cp . exec ( cmd + args ) ;
486+ }
487+
488+ module . exports . myCommand = function ( myCommand ) {
489+ let cmd = `cd ${ cwd } ; ${ myCommand } ` ; // OK - the parameter name suggests that it is purposely a shell command.
490+ cp . exec ( cmd ) ;
486491}
You can’t perform that action at this time.
0 commit comments