Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion javascript/ql/src/LanguageFeatures/InvalidPrototype.ql
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ private import semmle.javascript.dataflow.InferredTypes
*/
predicate isProto(DataFlow::AnalyzedNode e) {
// `o.__proto__ = e`, `{ __proto__: e }`, ...
e = any(DataFlow::PropWrite pwn | pwn.getPropertyName() = "__proto__").getRhs()
e =
any(DataFlow::PropWrite pwn |
pwn.getPropertyName() = "__proto__" and
not pwn.getWriteNode().(Property).isComputed()
).getRhs()
or
// Object.create(e)
e = DataFlow::globalVarRef("Object").getAMemberCall("create").getArgument(0)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* The `js/invalid-prototype-value` query no longer reports computed `__proto__` properties in object literals.
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
| tst.js:8:27:8:28 | 42 | Values of type number cannot be used as prototypes. |
| tst.js:9:15:9:18 | true | Values of type boolean cannot be used as prototypes. |
| tst.js:10:1:10:10 | "function" | Values of type string cannot be used as prototypes. |
| tst.js:15:25:15:26 | 42 | Values of type number cannot be used as prototypes. |
| tst.js:17:19:17:20 | 42 | Values of type number cannot be used as prototypes. |
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ Object.setPrototypeOf(o2, 42); // $ Alert
Object.create(true); // $ Alert
"function".isPrototypeOf(o2); // $ Alert

var o3 = { ["__proto__"]: 42 };
var o4 = { ["__proto__"]: null };

var o5 = { "__proto__": 42 }; // $ Alert
var o6 = {};
o6["__proto__"] = 42; // $ Alert
Loading