Skip to content

Commit afe7872

Browse files
authored
Merge pull request github#11565 from asgerf/js/rephined-variable-in-access-path
JS: handle rephined variable in access path
2 parents c1c0432 + 80777b8 commit afe7872

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

javascript/ql/lib/semmle/javascript/dataflow/internal/AccessPaths.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ private PropAccess namedPropAccess(AccessPath base, PropertyName name, BasicBloc
4545

4646
private SsaVariable getRefinedVariable(SsaVariable variable) {
4747
result = variable.getDefinition().(SsaRefinementNode).getAnInput()
48+
or
49+
result = variable.getDefinition().(SsaPhiNode).getRephinedVariable()
4850
}
4951

5052
private SsaVariable getARefinementOf(SsaVariable variable) { variable = getRefinedVariable(result) }
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import * as dummy from 'dummy';
2+
3+
function oneUse() {
4+
let taint = source();
5+
6+
if (!isSafe(taint)) {
7+
return;
8+
}
9+
10+
let array = [];
11+
if (taint) {
12+
array.push(taint);
13+
}
14+
15+
sink(array.join()); // OK
16+
}
17+
18+
function secondUse() {
19+
let taint = source();
20+
21+
if (!isSafe(taint)) {
22+
return;
23+
}
24+
25+
let array = [];
26+
if (taint) {
27+
array.push(taint);
28+
}
29+
if (taint) {
30+
array.push(taint);
31+
}
32+
33+
sink(array.join()); // OK
34+
}

0 commit comments

Comments
 (0)