Skip to content

Commit b8a9ac3

Browse files
committed
add lValueFlowStep for rest-pattern nested inside a property-pattern (and removed old incorrect approach)
1 parent b510e47 commit b8a9ac3

3 files changed

Lines changed: 9 additions & 15 deletions

File tree

javascript/ql/src/semmle/javascript/DefUse.qll

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,6 @@ private predicate defn(ControlFlowNode def, Expr lhs) {
8585
exists(EnumMember member | def = member.getIdentifier() |
8686
lhs = def and not exists(member.getInitializer())
8787
)
88-
or
89-
exists(PropertyPattern prop, ObjectPattern obj, Expr rest |
90-
prop.getValuePattern() = obj and obj.getRest() = rest
91-
|
92-
lhs = rest and def = prop
93-
)
9488
}
9589

9690
/**

javascript/ql/src/semmle/javascript/dataflow/DataFlow.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,6 +1347,11 @@ module DataFlow {
13471347
succ = lvalueNode(pattern.getValuePattern())
13481348
)
13491349
or
1350+
exists(PropertyPattern pattern |
1351+
pred = TPropNode(pattern) and
1352+
succ = lvalueNode(pattern.getValuePattern().(ObjectPattern).getRest())
1353+
)
1354+
or
13501355
exists(Expr element |
13511356
pred = TElementPatternNode(_, element) and
13521357
succ = lvalueNode(element)
@@ -1386,11 +1391,6 @@ module DataFlow {
13861391
succ = valueNode(v.getAUse())
13871392
)
13881393
or
1389-
exists(SsaExplicitDefinition def |
1390-
pred.getAstNode() = def.getDef() and
1391-
succ = TSsaDefNode(def)
1392-
)
1393-
or
13941394
exists(Expr predExpr, Expr succExpr |
13951395
pred = valueNode(predExpr) and succ = valueNode(succExpr)
13961396
|

javascript/ql/test/query-tests/Security/CWE-078/IndirectCommandInjection.expected

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ nodes
7979
| command-line-parameter-command-injection.js:43:22:43:58 | require ... parse() |
8080
| command-line-parameter-command-injection.js:43:22:43:58 | require ... parse() |
8181
| command-line-parameter-command-injection.js:43:22:43:62 | require ... e().foo |
82-
| command-line-parameter-command-injection.js:48:3:50:3 | args |
82+
| command-line-parameter-command-injection.js:47:8:53:12 | args |
8383
| command-line-parameter-command-injection.js:48:3:50:3 | argv: { ... rgs\\n\\t\\t} |
8484
| command-line-parameter-command-injection.js:48:3:50:3 | argv: { ... rgs\\n\\t\\t} |
8585
| command-line-parameter-command-injection.js:55:10:55:25 | "cmd.sh " + args |
@@ -155,9 +155,9 @@ edges
155155
| command-line-parameter-command-injection.js:43:22:43:58 | require ... parse() | command-line-parameter-command-injection.js:43:22:43:62 | require ... e().foo |
156156
| command-line-parameter-command-injection.js:43:22:43:62 | require ... e().foo | command-line-parameter-command-injection.js:43:10:43:62 | "cmd.sh ... e().foo |
157157
| command-line-parameter-command-injection.js:43:22:43:62 | require ... e().foo | command-line-parameter-command-injection.js:43:10:43:62 | "cmd.sh ... e().foo |
158-
| command-line-parameter-command-injection.js:48:3:50:3 | args | command-line-parameter-command-injection.js:55:22:55:25 | args |
159-
| command-line-parameter-command-injection.js:48:3:50:3 | argv: { ... rgs\\n\\t\\t} | command-line-parameter-command-injection.js:48:3:50:3 | args |
160-
| command-line-parameter-command-injection.js:48:3:50:3 | argv: { ... rgs\\n\\t\\t} | command-line-parameter-command-injection.js:48:3:50:3 | args |
158+
| command-line-parameter-command-injection.js:47:8:53:12 | args | command-line-parameter-command-injection.js:55:22:55:25 | args |
159+
| command-line-parameter-command-injection.js:48:3:50:3 | argv: { ... rgs\\n\\t\\t} | command-line-parameter-command-injection.js:47:8:53:12 | args |
160+
| command-line-parameter-command-injection.js:48:3:50:3 | argv: { ... rgs\\n\\t\\t} | command-line-parameter-command-injection.js:47:8:53:12 | args |
161161
| command-line-parameter-command-injection.js:55:22:55:25 | args | command-line-parameter-command-injection.js:55:10:55:25 | "cmd.sh " + args |
162162
| command-line-parameter-command-injection.js:55:22:55:25 | args | command-line-parameter-command-injection.js:55:10:55:25 | "cmd.sh " + args |
163163
#select

0 commit comments

Comments
 (0)