Skip to content

Commit 6632dfa

Browse files
committed
Ruby: fix another SystemCommandExecution::isShellInterpreted implementation
1 parent 348ad95 commit 6632dfa

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

ruby/ql/lib/codeql/ruby/frameworks/PosixSpawn.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ module PosixSpawn {
6262
// is shell interpreted unless there is another argument with a string
6363
// constant value.
6464
override predicate isShellInterpreted(DataFlow::Node arg) {
65+
this.argument(arg) and
6566
not exists(DataFlow::Node otherArg |
6667
otherArg != arg and
67-
this.argument(arg) and
6868
this.argument(otherArg) and
6969
otherArg.asExpr().getConstantValue().isString(_)
7070
)

ruby/ql/test/library-tests/frameworks/PosixSpawn.ql

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import codeql.ruby.DataFlow
55
query predicate systemCalls(
66
PosixSpawn::SystemCall call, DataFlow::Node arg, boolean shellInterpreted
77
) {
8-
arg = call.getAnArgument() and
9-
if call.isShellInterpreted(arg) then shellInterpreted = true else shellInterpreted = false
8+
call.isShellInterpreted(arg) and shellInterpreted = true
9+
or
10+
not call.isShellInterpreted(arg) and arg = call.getAnArgument() and shellInterpreted = false
1011
}
1112

1213
query predicate childCalls(PosixSpawn::ChildCall call, DataFlow::Node arg, boolean shellInterpreted) {
13-
arg = call.getAnArgument() and
14-
if call.isShellInterpreted(arg) then shellInterpreted = true else shellInterpreted = false
14+
call.isShellInterpreted(arg) and shellInterpreted = true
15+
or
16+
not call.isShellInterpreted(arg) and arg = call.getAnArgument() and shellInterpreted = false
1517
}

0 commit comments

Comments
 (0)