Skip to content

Commit e90fb1a

Browse files
committed
reuse classes modelling standard library functions
1 parent d489d63 commit e90fb1a

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

javascript/ql/src/semmle/javascript/PackageExports.qll

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,26 +83,23 @@ DataFlow::Node getAValueExportedByPackage() {
8383
)
8484
or
8585
// Object.defineProperty
86-
exists(DataFlow::MethodCallNode call |
87-
call = DataFlow::globalVarRef("Object").getAMethodCall("defineProperty") and
88-
[call, call.getArgument(0)] = getAValueExportedByPackage()
86+
exists(CallToObjectDefineProperty call |
87+
[call, call.getBaseObject()] = getAValueExportedByPackage()
8988
|
90-
result = call.getArgument(2).getALocalSource().getAPropertyReference("value")
89+
result = call.getPropertyDescriptor().getALocalSource().getAPropertyReference("value")
9190
or
9291
result =
93-
call.getArgument(2)
92+
call.getPropertyDescriptor()
9493
.getALocalSource()
9594
.getAPropertyReference("get")
9695
.(DataFlow::FunctionNode)
9796
.getAReturn()
9897
)
9998
or
10099
// Object.assign
101-
exists(DataFlow::MethodCallNode assign |
102-
assign = DataFlow::globalVarRef("Object").getAMethodCall("assign")
103-
|
104-
getAValueExportedByPackage() = [assign, assign.getArgument(0)] and
105-
result = assign.getAnArgument()
100+
exists(ExtendCall assign |
101+
getAValueExportedByPackage() = [assign, assign.getDestinationOperand()] and
102+
result = assign.getASourceOperand()
106103
)
107104
or
108105
// Array.prototype.{map, reduce, entries, values}
@@ -120,7 +117,7 @@ DataFlow::Node getAValueExportedByPackage() {
120117
exists(DataFlow::MethodCallNode freeze |
121118
freeze =
122119
DataFlow::globalVarRef("Object")
123-
.getAMethodCall(["fromEntries", "freeze", "entries", "values"])
120+
.getAMethodCall(["fromEntries", "freeze", "seal", "entries", "values"])
124121
|
125122
freeze = getAValueExportedByPackage() and
126123
result = freeze.getArgument(0)

0 commit comments

Comments
 (0)