Skip to content

Commit 75a8437

Browse files
committed
JS: Do not generate def-nodes for decorated parameters
1 parent ca145f2 commit 75a8437

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

javascript/ql/lib/semmle/javascript/ApiGraphs.qll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -813,12 +813,6 @@ module API {
813813
lbl = Label::decoratedMember() and
814814
ref = DataFlow::valueNode(method.getBody())
815815
)
816-
or
817-
exists(Parameter param |
818-
useNodeFlowsToDecorator(base, param.getADecorator()) and
819-
lbl = Label::decoratedParameter() and
820-
ref = DataFlow::parameterNode(param)
821-
)
822816
}
823817

824818
/** Holds if `ref` is a use that should have an incoming edge from `base` labelled `lbl`, induced by a decorator. */
@@ -829,6 +823,12 @@ module API {
829823
lbl = Label::decoratedMember() and
830824
ref = DataFlow::parameterNode(accessor.getBody().getParameter(0))
831825
)
826+
or
827+
exists(Parameter param |
828+
useNodeFlowsToDecorator(base, param.getADecorator()) and
829+
lbl = Label::decoratedParameter() and
830+
ref = DataFlow::parameterNode(param)
831+
)
832832
}
833833

834834
/** Holds if `rhs` is a def node that should have an incoming edge from `base` labelled `lbl`, induced by a decorator. */

javascript/ql/test/library-tests/frameworks/data/paramDecorator.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ class C {
66
decoratedParamSource(@testlib.ParamDecoratorSource x) {
77
sink(x) // NOT OK
88
}
9-
decoratedParamSink(@testlib.ParamDecoratorSink x) { // NOT OK - though slightly weird alert location
9+
decoratedParamSink(@testlib.ParamDecoratorSink x) { // OK
1010
}
1111
decoratedParamSink2(@testlib.ParamDecoratorSink x) { // OK
12-
x.push(source());
12+
x.push(source()); // OK
1313
}
1414
}
1515

16-
new C().decoratedParamSink(source());
17-
new C().decoratedParamSink2([]);
16+
new C().decoratedParamSink(source()); // OK - parameter decorators can't be used to mark the parameter as a sink
17+
new C().decoratedParamSink2([]); // OK

javascript/ql/test/library-tests/frameworks/data/test.expected

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
consistencyIssue
2-
| library-tests/frameworks/data/paramDecorator.ts:11 | did not expect an alert, but found an alert for BasicTaintTracking | OK | |
32
taintFlow
43
| paramDecorator.ts:6:54:6:54 | x | paramDecorator.ts:7:10:7:10 | x |
5-
| paramDecorator.ts:12:12:12:19 | source() | paramDecorator.ts:11:51:11:51 | x |
6-
| paramDecorator.ts:16:28:16:35 | source() | paramDecorator.ts:9:50:9:50 | x |
74
| test.js:5:30:5:37 | source() | test.js:5:8:5:38 | testlib ... urce()) |
85
| test.js:6:22:6:29 | source() | test.js:6:8:6:30 | preserv ... urce()) |
96
| test.js:7:41:7:48 | source() | test.js:7:8:7:49 | require ... urce()) |
@@ -59,8 +56,6 @@ taintFlow
5956
| test.js:187:31:187:31 | x | test.js:189:10:189:10 | x |
6057
| test.js:203:32:203:39 | source() | test.js:203:32:203:39 | source() |
6158
isSink
62-
| paramDecorator.ts:9:50:9:50 | x | test-sink |
63-
| paramDecorator.ts:11:51:11:51 | x | test-sink |
6459
| test.js:54:18:54:25 | source() | test-sink |
6560
| test.js:55:22:55:29 | source() | test-sink |
6661
| test.js:57:24:57:31 | source() | test-sink |

0 commit comments

Comments
 (0)