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 {
53
53
class ExternalInputSource extends Source , DataFlow:: ParameterNode {
54
54
ExternalInputSource ( ) {
55
55
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
+ )
57
62
}
58
63
}
59
64
Original file line number Diff line number Diff line change @@ -483,4 +483,9 @@ module.exports.splitConcat = function (name) {
483
483
let args = ' my name is ' + name ; // NOT OK
484
484
let cmd = 'echo' ;
485
485
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 ) ;
486
491
}
You can’t perform that action at this time.
0 commit comments