From cfa2ec1084a6497a408542b445beeb430e239b36 Mon Sep 17 00:00:00 2001 From: Asger F Date: Wed, 7 Aug 2019 10:20:32 +0100 Subject: [PATCH] JS: Remove fake JSONType from es5.js externs --- javascript/externs/es/es5.js | 18 ++---------------- .../semmle/javascript/GlobalAccessPaths.qll | 5 ----- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/javascript/externs/es/es5.js b/javascript/externs/es/es5.js index a04e533ba1e..ffbc01e6aba 100644 --- a/javascript/externs/es/es5.js +++ b/javascript/externs/es/es5.js @@ -236,20 +236,13 @@ Date.prototype.toISOString = function() {}; Date.prototype.toJSON = function(opt_ignoredKey) {}; -/** - * A fake type to model the JSON object. - * @constructor - */ -function JSONType() {} - - /** * @param {string} jsonStr The string to parse. * @param {(function(string, *) : *)=} opt_reviver * @return {*} The JSON object. * @throws {Error} */ -JSONType.prototype.parse = function(jsonStr, opt_reviver) {}; +JSON.parse = function(jsonStr, opt_reviver) {}; /** @@ -259,11 +252,4 @@ JSONType.prototype.parse = function(jsonStr, opt_reviver) {}; * @return {string} JSON string which represents jsonObj. * @throws {Error} */ -JSONType.prototype.stringify = function(jsonObj, opt_replacer, opt_space) {}; - - -/** - * @type {!JSONType} - * @suppress {duplicate} - */ -var JSON; +JSON.stringify = function(jsonObj, opt_replacer, opt_space) {}; diff --git a/javascript/ql/src/semmle/javascript/GlobalAccessPaths.qll b/javascript/ql/src/semmle/javascript/GlobalAccessPaths.qll index 708bc27750d..a2fe1e0ec8e 100644 --- a/javascript/ql/src/semmle/javascript/GlobalAccessPaths.qll +++ b/javascript/ql/src/semmle/javascript/GlobalAccessPaths.qll @@ -116,11 +116,6 @@ module GlobalAccessPath { // Note: Avoid unneeded materialization of DataFlow::Node.getFile() rhs.getAstNode().getFile() = file ) - or - // Hard-code JSON methods from the externs file, since they aren't explicitly assigned. - (accessPath = "JSON.parse" or accessPath = "JSON.stringify") and - file.getBaseName() = "es5.js" and - any(TopLevel tl | tl.getFile() = file).isExterns() } /**