From a88908787f1f1a06674dc5600bd19332d135519f Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Wed, 14 Aug 2019 12:49:14 -0500 Subject: [PATCH 1/2] Fix: Lint no-prototype-builtins Closes: https://github.com/parse-community/parse-server/issues/5842 Reference: https://eslint.org/docs/rules/no-prototype-builtins --- .eslintrc.json | 1 - spec/ParseQuery.Aggregate.spec.js | 44 +++++++++++++------ spec/Schema.spec.js | 16 ++++--- spec/VerifyUserPassword.spec.js | 24 +++++----- src/Adapters/Auth/index.js | 2 +- .../Storage/Mongo/MongoStorageAdapter.js | 6 +-- src/Adapters/Storage/Mongo/MongoTransform.js | 2 +- .../Postgres/PostgresStorageAdapter.js | 8 ++-- src/Controllers/DatabaseController.js | 2 +- src/Controllers/PushController.js | 16 ++++--- src/LiveQuery/ParseLiveQueryServer.js | 6 +-- src/LiveQuery/QueryTools.js | 2 +- src/ParseServer.js | 4 +- src/Push/utils.js | 2 +- src/RestQuery.js | 2 +- src/RestWrite.js | 2 +- src/Routers/AggregateRouter.js | 4 +- src/Routers/UsersRouter.js | 2 +- src/StatusHandler.js | 2 +- src/cli/utils/commander.js | 2 +- src/cloud-code/Parse.Cloud.js | 5 ++- src/defaults.js | 2 +- 22 files changed, 93 insertions(+), 63 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 92bcda7b69..7e6bdec06a 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -23,7 +23,6 @@ "prefer-const": "error", "space-infix-ops": "error", "no-useless-escape": "off", - "no-prototype-builtins": "off", "require-atomic-updates": "off" } } diff --git a/spec/ParseQuery.Aggregate.spec.js b/spec/ParseQuery.Aggregate.spec.js index 78af9f4aeb..6c0ce38688 100644 --- a/spec/ParseQuery.Aggregate.spec.js +++ b/spec/ParseQuery.Aggregate.spec.js @@ -127,9 +127,15 @@ describe('Parse.Query Aggregate testing', () => { get(Parse.serverURL + '/aggregate/TestObject', options) .then(resp => { expect(resp.results.length).toBe(3); - expect(resp.results[0].hasOwnProperty('objectId')).toBe(true); - expect(resp.results[1].hasOwnProperty('objectId')).toBe(true); - expect(resp.results[2].hasOwnProperty('objectId')).toBe(true); + expect(Object.hasOwnProperty.call(resp.results[0], 'objectId')).toBe( + true + ); + expect(Object.hasOwnProperty.call(resp.results[1], 'objectId')).toBe( + true + ); + expect(Object.hasOwnProperty.call(resp.results[2], 'objectId')).toBe( + true + ); expect(resp.results[0].objectId).not.toBe(undefined); expect(resp.results[1].objectId).not.toBe(undefined); expect(resp.results[2].objectId).not.toBe(undefined); @@ -148,9 +154,9 @@ describe('Parse.Query Aggregate testing', () => { }); const resp = await get(Parse.serverURL + '/aggregate/TestObject', options); expect(resp.results.length).toBe(3); - expect(resp.results[0].hasOwnProperty('objectId')).toBe(true); - expect(resp.results[1].hasOwnProperty('objectId')).toBe(true); - expect(resp.results[2].hasOwnProperty('objectId')).toBe(true); + expect(Object.hasOwnProperty.call(resp.results[0], 'objectId')).toBe(true); + expect(Object.hasOwnProperty.call(resp.results[1], 'objectId')).toBe(true); + expect(Object.hasOwnProperty.call(resp.results[2], 'objectId')).toBe(true); expect(resp.results[0].objectId).not.toBe(undefined); expect(resp.results[1].objectId).not.toBe(undefined); expect(resp.results[2].objectId).not.toBe(undefined); @@ -371,8 +377,8 @@ describe('Parse.Query Aggregate testing', () => { expect(results.length).toEqual(4); for (let i = 0; i < results.length; i++) { const item = results[i]; - expect(item.hasOwnProperty('updatedAt')).toEqual(true); - expect(item.hasOwnProperty('objectId')).toEqual(false); + expect(Object.hasOwnProperty.call(item, 'updatedAt')).toEqual(true); + expect(Object.hasOwnProperty.call(item, 'objectId')).toEqual(false); } done(); }); @@ -482,7 +488,9 @@ describe('Parse.Query Aggregate testing', () => { }); get(Parse.serverURL + '/aggregate/TestObject', options) .then(resp => { - expect(resp.results[0].hasOwnProperty('objectId')).toBe(true); + expect(Object.hasOwnProperty.call(resp.results[0], 'objectId')).toBe( + true + ); expect(resp.results[0].objectId).toBe(null); expect(resp.results[0].total).toBe(50); done(); @@ -498,7 +506,9 @@ describe('Parse.Query Aggregate testing', () => { }); get(Parse.serverURL + '/aggregate/TestObject', options) .then(resp => { - expect(resp.results[0].hasOwnProperty('objectId')).toBe(true); + expect(Object.hasOwnProperty.call(resp.results[0], 'objectId')).toBe( + true + ); expect(resp.results[0].objectId).toBe(null); expect(resp.results[0].total).toBe(4); done(); @@ -514,7 +524,9 @@ describe('Parse.Query Aggregate testing', () => { }); get(Parse.serverURL + '/aggregate/TestObject', options) .then(resp => { - expect(resp.results[0].hasOwnProperty('objectId')).toBe(true); + expect(Object.hasOwnProperty.call(resp.results[0], 'objectId')).toBe( + true + ); expect(resp.results[0].objectId).toBe(null); expect(resp.results[0].minScore).toBe(10); done(); @@ -530,7 +542,9 @@ describe('Parse.Query Aggregate testing', () => { }); get(Parse.serverURL + '/aggregate/TestObject', options) .then(resp => { - expect(resp.results[0].hasOwnProperty('objectId')).toBe(true); + expect(Object.hasOwnProperty.call(resp.results[0], 'objectId')).toBe( + true + ); expect(resp.results[0].objectId).toBe(null); expect(resp.results[0].maxScore).toBe(20); done(); @@ -546,7 +560,9 @@ describe('Parse.Query Aggregate testing', () => { }); get(Parse.serverURL + '/aggregate/TestObject', options) .then(resp => { - expect(resp.results[0].hasOwnProperty('objectId')).toBe(true); + expect(Object.hasOwnProperty.call(resp.results[0], 'objectId')).toBe( + true + ); expect(resp.results[0].objectId).toBe(null); expect(resp.results[0].avgScore).toBe(12.5); done(); @@ -966,7 +982,7 @@ describe('Parse.Query Aggregate testing', () => { .then(resp => { expect(resp.results.length).toBe(2); resp.results.forEach(result => { - expect(result.hasOwnProperty('objectId')).toBe(true); + expect(Object.hasOwnProperty.call(result, 'objectId')).toBe(true); expect(result.name).toBe(undefined); expect(result.sender).toBe(undefined); expect(result.size).toBe(undefined); diff --git a/spec/Schema.spec.js b/spec/Schema.spec.js index 17e75a306e..8c2d7791a1 100644 --- a/spec/Schema.spec.js +++ b/spec/Schema.spec.js @@ -1382,19 +1382,23 @@ describe('SchemaController', () => { it('properly handles volatile _Schemas', done => { function validateSchemaStructure(schema) { - expect(schema.hasOwnProperty('className')).toBe(true); - expect(schema.hasOwnProperty('fields')).toBe(true); - expect(schema.hasOwnProperty('classLevelPermissions')).toBe(true); + expect(Object.hasOwnProperty.call(schema, 'className')).toBe(true); + expect(Object.hasOwnProperty.call(schema, 'fields')).toBe(true); + expect(Object.hasOwnProperty.call(schema, 'classLevelPermissions')).toBe( + true + ); } function validateSchemaDataStructure(schemaData) { Object.keys(schemaData).forEach(className => { const schema = schemaData[className]; // Hooks has className... if (className != '_Hooks') { - expect(schema.hasOwnProperty('className')).toBe(false); + expect(Object.hasOwnProperty.call(schema, 'className')).toBe(false); } - expect(schema.hasOwnProperty('fields')).toBe(false); - expect(schema.hasOwnProperty('classLevelPermissions')).toBe(false); + expect(Object.hasOwnProperty.call(schema, 'fields')).toBe(false); + expect( + Object.hasOwnProperty.call(schema, 'classLevelPermissions') + ).toBe(false); }); } let schema; diff --git a/spec/VerifyUserPassword.spec.js b/spec/VerifyUserPassword.spec.js index c66a1433da..8b9aa3a867 100644 --- a/spec/VerifyUserPassword.spec.js +++ b/spec/VerifyUserPassword.spec.js @@ -469,8 +469,8 @@ describe('Verify User Password', () => { const res = response.data; expect(typeof res).toBe('object'); expect(typeof res['objectId']).toEqual('string'); - expect(res.hasOwnProperty('sessionToken')).toEqual(false); - expect(res.hasOwnProperty('password')).toEqual(false); + expect(Object.hasOwnProperty.call(res, 'sessionToken')).toEqual(false); + expect(Object.hasOwnProperty.call(res, 'password')).toEqual(false); done(); }) .catch(err => { @@ -493,8 +493,8 @@ describe('Verify User Password', () => { const res = response.data; expect(typeof res).toBe('object'); expect(typeof res['objectId']).toEqual('string'); - expect(res.hasOwnProperty('sessionToken')).toEqual(false); - expect(res.hasOwnProperty('password')).toEqual(false); + expect(Object.hasOwnProperty.call(res, 'sessionToken')).toEqual(false); + expect(Object.hasOwnProperty.call(res, 'password')).toEqual(false); done(); }); }); @@ -513,8 +513,8 @@ describe('Verify User Password', () => { const res = response.data; expect(typeof res).toBe('object'); expect(typeof res['objectId']).toEqual('string'); - expect(res.hasOwnProperty('sessionToken')).toEqual(false); - expect(res.hasOwnProperty('password')).toEqual(false); + expect(Object.hasOwnProperty.call(res, 'sessionToken')).toEqual(false); + expect(Object.hasOwnProperty.call(res, 'password')).toEqual(false); done(); }); }); @@ -544,8 +544,8 @@ describe('Verify User Password', () => { expect(typeof res).toBe('string'); const body = JSON.parse(res); expect(typeof body['objectId']).toEqual('string'); - expect(body.hasOwnProperty('sessionToken')).toEqual(false); - expect(body.hasOwnProperty('password')).toEqual(false); + expect(Object.hasOwnProperty.call(body, 'sessionToken')).toEqual(false); + expect(Object.hasOwnProperty.call(body, 'password')).toEqual(false); done(); }); }); @@ -575,8 +575,8 @@ describe('Verify User Password', () => { expect(typeof res).toBe('string'); const body = JSON.parse(res); expect(typeof body['objectId']).toEqual('string'); - expect(body.hasOwnProperty('sessionToken')).toEqual(false); - expect(body.hasOwnProperty('password')).toEqual(false); + expect(Object.hasOwnProperty.call(body, 'sessionToken')).toEqual(false); + expect(Object.hasOwnProperty.call(body, 'password')).toEqual(false); done(); }); }); @@ -603,8 +603,8 @@ describe('Verify User Password', () => { const res = response.data; expect(typeof res).toBe('object'); expect(typeof res['objectId']).toEqual('string'); - expect(res.hasOwnProperty('sessionToken')).toEqual(false); - expect(res.hasOwnProperty('password')).toEqual(false); + expect(Object.hasOwnProperty.call(res, 'sessionToken')).toEqual(false); + expect(Object.hasOwnProperty.call(res, 'password')).toEqual(false); done(); }); }); diff --git a/src/Adapters/Auth/index.js b/src/Adapters/Auth/index.js index 3be34f0a59..771b202146 100755 --- a/src/Adapters/Auth/index.js +++ b/src/Adapters/Auth/index.js @@ -67,7 +67,7 @@ function loadAuthAdapter(provider, authOptions) { const providerOptions = authOptions[provider]; if ( providerOptions && - providerOptions.hasOwnProperty('oauth2') && + Object.hasOwnProperty.call(providerOptions, 'oauth2') && providerOptions['oauth2'] === true ) { defaultAdapter = oauth2; diff --git a/src/Adapters/Storage/Mongo/MongoStorageAdapter.js b/src/Adapters/Storage/Mongo/MongoStorageAdapter.js index 0f611509e8..b82ec6958c 100644 --- a/src/Adapters/Storage/Mongo/MongoStorageAdapter.js +++ b/src/Adapters/Storage/Mongo/MongoStorageAdapter.js @@ -279,7 +279,7 @@ export class MongoStorageAdapter implements StorageAdapter { delete existingIndexes[name]; } else { Object.keys(field).forEach(key => { - if (!fields.hasOwnProperty(key)) { + if (!Object.hasOwnProperty.call(fields, key)) { throw new Parse.Error( Parse.Error.INVALID_QUERY, `Field ${key} does not exist, cannot add index.` @@ -795,7 +795,7 @@ export class MongoStorageAdapter implements StorageAdapter { ) .then(results => { results.forEach(result => { - if (result.hasOwnProperty('_id')) { + if (Object.hasOwnProperty.call(result, '_id')) { if (isPointerField && result._id) { result._id = result._id.split('$')[1]; } @@ -1024,7 +1024,7 @@ export class MongoStorageAdapter implements StorageAdapter { const existingIndexes = schema.indexes; for (const key in existingIndexes) { const index = existingIndexes[key]; - if (index.hasOwnProperty(fieldName)) { + if (Object.hasOwnProperty.call(index, fieldName)) { return Promise.resolve(); } } diff --git a/src/Adapters/Storage/Mongo/MongoTransform.js b/src/Adapters/Storage/Mongo/MongoTransform.js index 7db6994868..78ff7d130f 100644 --- a/src/Adapters/Storage/Mongo/MongoTransform.js +++ b/src/Adapters/Storage/Mongo/MongoTransform.js @@ -1282,7 +1282,7 @@ const nestedMongoObjectToNestedParseObject = mongoObject => { } if ( - mongoObject.hasOwnProperty('__type') && + Object.hasOwnProperty.call(mongoObject, '__type') && mongoObject.__type == 'Date' && mongoObject.iso instanceof Date ) { diff --git a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js index 4fc955bd30..faf88e23cc 100644 --- a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js +++ b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js @@ -903,7 +903,7 @@ export class PostgresStorageAdapter implements StorageAdapter { delete existingIndexes[name]; } else { Object.keys(field).forEach(key => { - if (!fields.hasOwnProperty(key)) { + if (!Object.hasOwnProperty.call(fields, key)) { throw new Parse.Error( Parse.Error.INVALID_QUERY, `Field ${key} does not exist, cannot add index.` @@ -2219,7 +2219,9 @@ export class PostgresStorageAdapter implements StorageAdapter { } if (stage.$match) { const patterns = []; - const orOrAnd = stage.$match.hasOwnProperty('$or') ? ' OR ' : ' AND '; + const orOrAnd = Object.hasOwnProperty.call(stage.$match, '$or') + ? ' OR ' + : ' AND '; if (stage.$match.$or) { const collapse = {}; @@ -2294,7 +2296,7 @@ export class PostgresStorageAdapter implements StorageAdapter { ) .then(results => { results.forEach(result => { - if (!result.hasOwnProperty('objectId')) { + if (!Object.hasOwnProperty.call(result, 'objectId')) { result.objectId = null; } if (groupValues) { diff --git a/src/Controllers/DatabaseController.js b/src/Controllers/DatabaseController.js index 0dc89c412a..5f1c3e882c 100644 --- a/src/Controllers/DatabaseController.js +++ b/src/Controllers/DatabaseController.js @@ -1487,7 +1487,7 @@ class DatabaseController { [key]: userPointer, }; // if we already have a constraint on the key, use the $and - if (query.hasOwnProperty(key)) { + if (Object.hasOwnProperty.call(query, key)) { return { $and: [q, query] }; } // otherwise just add the constaint diff --git a/src/Controllers/PushController.js b/src/Controllers/PushController.js index fcc910134b..aa09dc62ff 100644 --- a/src/Controllers/PushController.js +++ b/src/Controllers/PushController.js @@ -32,7 +32,10 @@ export class PushController { } // Immediate push - if (body.expiration_interval && !body.hasOwnProperty('push_time')) { + if ( + body.expiration_interval && + !Object.hasOwnProperty.call(body, 'push_time') + ) { const ttlMs = body.expiration_interval * 1000; body.expiration_time = new Date(now.valueOf() + ttlMs).valueOf(); } @@ -121,7 +124,7 @@ export class PushController { }) .then(() => { if ( - body.hasOwnProperty('push_time') && + Object.hasOwnProperty.call(body, 'push_time') && config.hasPushScheduledSupport ) { return Promise.resolve(); @@ -147,7 +150,7 @@ export class PushController { * @returns {Number|undefined} The expiration time if it exists in the request */ static getExpirationTime(body = {}) { - var hasExpirationTime = body.hasOwnProperty('expiration_time'); + var hasExpirationTime = Object.hasOwnProperty.call(body, 'expiration_time'); if (!hasExpirationTime) { return; } @@ -174,7 +177,10 @@ export class PushController { } static getExpirationInterval(body = {}) { - const hasExpirationInterval = body.hasOwnProperty('expiration_interval'); + const hasExpirationInterval = Object.hasOwnProperty.call( + body, + 'expiration_interval' + ); if (!hasExpirationInterval) { return; } @@ -198,7 +204,7 @@ export class PushController { * @returns {Number|undefined} The push time if it exists in the request */ static getPushTime(body = {}) { - var hasPushTime = body.hasOwnProperty('push_time'); + var hasPushTime = Object.hasOwnProperty.call(body, 'push_time'); if (!hasPushTime) { return; } diff --git a/src/LiveQuery/ParseLiveQueryServer.js b/src/LiveQuery/ParseLiveQueryServer.js index b447e284b8..03d1619302 100644 --- a/src/LiveQuery/ParseLiveQueryServer.js +++ b/src/LiveQuery/ParseLiveQueryServer.js @@ -600,7 +600,7 @@ class ParseLiveQueryServer { ) { return false; } - if (!request || !request.hasOwnProperty('masterKey')) { + if (!request || !Object.hasOwnProperty.call(request, 'masterKey')) { return false; } return request.masterKey === validKeyPairs.get('masterKey'); @@ -623,7 +623,7 @@ class ParseLiveQueryServer { _handleSubscribe(parseWebsocket: any, request: any): any { // If we can not find this client, return error to client - if (!parseWebsocket.hasOwnProperty('clientId')) { + if (!Object.hasOwnProperty.call(parseWebsocket, 'clientId')) { Client.pushError( parseWebsocket, 2, @@ -699,7 +699,7 @@ class ParseLiveQueryServer { notifyClient: boolean = true ): any { // If we can not find this client, return error to client - if (!parseWebsocket.hasOwnProperty('clientId')) { + if (!Object.hasOwnProperty.call(parseWebsocket, 'clientId')) { Client.pushError( parseWebsocket, 2, diff --git a/src/LiveQuery/QueryTools.js b/src/LiveQuery/QueryTools.js index b3fe6dc075..ea5c96f120 100644 --- a/src/LiveQuery/QueryTools.js +++ b/src/LiveQuery/QueryTools.js @@ -13,7 +13,7 @@ var Parse = require('parse/node'); * Convert $or queries into an array of where conditions */ function flattenOrQueries(where) { - if (!where.hasOwnProperty('$or')) { + if (!Object.hasOwnProperty.call(where, '$or')) { return where; } var accum = []; diff --git a/src/ParseServer.js b/src/ParseServer.js index d353a0ee44..58f033dd0f 100644 --- a/src/ParseServer.js +++ b/src/ParseServer.js @@ -356,12 +356,12 @@ function addParseCloud() { function injectDefaults(options: ParseServerOptions) { Object.keys(defaults).forEach(key => { - if (!options.hasOwnProperty(key)) { + if (!Object.hasOwnProperty.call(options, key)) { options[key] = defaults[key]; } }); - if (!options.hasOwnProperty('serverURL')) { + if (!Object.hasOwnProperty.call(options, 'serverURL')) { options.serverURL = `http://localhost:${options.port}${options.mountPath}`; } diff --git a/src/Push/utils.js b/src/Push/utils.js index fe0b2d6c29..260d85528d 100644 --- a/src/Push/utils.js +++ b/src/Push/utils.js @@ -132,7 +132,7 @@ export function validatePushType(where = {}, validPushTypes = []) { export function applyDeviceTokenExists(where) { where = deepcopy(where); - if (!where.hasOwnProperty('deviceToken')) { + if (!Object.hasOwnProperty.call(where, 'deviceToken')) { where['deviceToken'] = { $exists: true }; } return where; diff --git a/src/RestQuery.js b/src/RestQuery.js index 90cd535fa7..6dc2617184 100644 --- a/src/RestQuery.js +++ b/src/RestQuery.js @@ -71,7 +71,7 @@ function RestQuery( // If we have keys, we probably want to force some includes (n-1 level) // See issue: https://github.com/parse-community/parse-server/issues/3185 - if (restOptions.hasOwnProperty('keys')) { + if (Object.hasOwnProperty.call(restOptions, 'keys')) { const keysForInclude = restOptions.keys .split(',') .filter(key => { diff --git a/src/RestWrite.js b/src/RestWrite.js index 148bf4a3af..331b6f24bb 100644 --- a/src/RestWrite.js +++ b/src/RestWrite.js @@ -1711,7 +1711,7 @@ RestWrite.prototype._updateResponseWithData = function(response, data) { this.storage.fieldsChangedByTrigger.forEach(fieldName => { const dataValue = data[fieldName]; - if (!response.hasOwnProperty(fieldName)) { + if (!Object.hasOwnProperty.call(response, fieldName)) { response[fieldName] = dataValue; } diff --git a/src/Routers/AggregateRouter.js b/src/Routers/AggregateRouter.js index 90ee52f16a..7fe95499a0 100644 --- a/src/Routers/AggregateRouter.js +++ b/src/Routers/AggregateRouter.js @@ -122,13 +122,13 @@ export class AggregateRouter extends ClassesRouter { ); } if (stageName === 'group') { - if (stage[stageName].hasOwnProperty('_id')) { + if (Object.hasOwnProperty.call(stage[stageName], '_id')) { throw new Parse.Error( Parse.Error.INVALID_QUERY, `Invalid parameter for query: group. Please use objectId instead of _id` ); } - if (!stage[stageName].hasOwnProperty('objectId')) { + if (!Object.hasOwnProperty.call(stage[stageName], 'objectId')) { throw new Parse.Error( Parse.Error.INVALID_QUERY, `Invalid parameter for query: group. objectId is required` diff --git a/src/Routers/UsersRouter.js b/src/Routers/UsersRouter.js index 3cbe6ce90e..cead30f576 100644 --- a/src/Routers/UsersRouter.js +++ b/src/Routers/UsersRouter.js @@ -20,7 +20,7 @@ export class UsersRouter extends ClassesRouter { */ static removeHiddenProperties(obj) { for (var key in obj) { - if (obj.hasOwnProperty(key)) { + if (Object.hasOwnProperty.call(obj, key)) { // Regexp comes from Parse.Object.prototype.validate if (key !== '__type' && !/^[A-Za-z][0-9A-Za-z_]*$/.test(key)) { delete obj[key]; diff --git a/src/StatusHandler.js b/src/StatusHandler.js index 43cd10750e..293ee28bfd 100644 --- a/src/StatusHandler.js +++ b/src/StatusHandler.js @@ -148,7 +148,7 @@ export function pushStatusHandler(config, existingObjectId) { const now = new Date(); let pushTime = now.toISOString(); let status = 'pending'; - if (body.hasOwnProperty('push_time')) { + if (Object.hasOwnProperty.call(body, 'push_time')) { if (config.hasPushScheduledSupport) { pushTime = body.push_time; status = 'scheduled'; diff --git a/src/cli/utils/commander.js b/src/cli/utils/commander.js index 5eead78c29..c57e5a7b02 100644 --- a/src/cli/utils/commander.js +++ b/src/cli/utils/commander.js @@ -102,7 +102,7 @@ function parseConfigFile(program) { Command.prototype.setValuesIfNeeded = function(options) { Object.keys(options).forEach(key => { - if (!this.hasOwnProperty(key)) { + if (!Object.hasOwnProperty.call(this, key)) { this[key] = options[key]; } }); diff --git a/src/cloud-code/Parse.Cloud.js b/src/cloud-code/Parse.Cloud.js index 19a1b550b0..8df15a0840 100644 --- a/src/cloud-code/Parse.Cloud.js +++ b/src/cloud-code/Parse.Cloud.js @@ -2,7 +2,10 @@ import { Parse } from 'parse/node'; import * as triggers from '../triggers'; function isParseObjectConstructor(object) { - return typeof object === 'function' && object.hasOwnProperty('className'); + return ( + typeof object === 'function' && + Object.hasOwnProperty.call(object, 'className') + ); } function getClassName(parseClass) { diff --git a/src/defaults.js b/src/defaults.js index 3c9d01fb95..8025736b42 100644 --- a/src/defaults.js +++ b/src/defaults.js @@ -19,7 +19,7 @@ const { verbose, level } = (() => { const DefinitionDefaults = Object.keys(ParseServerOptions).reduce( (memo, key) => { const def = ParseServerOptions[key]; - if (def.hasOwnProperty('default')) { + if (Object.hasOwnProperty.call(def, 'default')) { memo[key] = def.default; } return memo; From a98dca302ed251a1128d6f6135862fb628f94acc Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Wed, 14 Aug 2019 16:13:13 -0500 Subject: [PATCH 2/2] replace Object.hasOwnProperty.call --- spec/ParseQuery.Aggregate.spec.js | 72 +++++++++++-------- spec/Schema.spec.js | 18 +++-- spec/VerifyUserPassword.spec.js | 48 +++++++++---- src/Adapters/Auth/index.js | 2 +- .../Storage/Mongo/MongoStorageAdapter.js | 6 +- src/Adapters/Storage/Mongo/MongoTransform.js | 2 +- .../Postgres/PostgresStorageAdapter.js | 9 ++- src/Controllers/DatabaseController.js | 4 +- src/Controllers/PushController.js | 13 ++-- src/LiveQuery/ParseLiveQueryServer.js | 9 ++- src/LiveQuery/QueryTools.js | 2 +- src/ParseServer.js | 4 +- src/Push/utils.js | 2 +- src/RestQuery.js | 2 +- src/RestWrite.js | 2 +- src/Routers/AggregateRouter.js | 4 +- src/Routers/UsersRouter.js | 2 +- src/StatusHandler.js | 2 +- src/cli/utils/commander.js | 2 +- src/cloud-code/Parse.Cloud.js | 2 +- src/defaults.js | 2 +- 21 files changed, 130 insertions(+), 79 deletions(-) diff --git a/spec/ParseQuery.Aggregate.spec.js b/spec/ParseQuery.Aggregate.spec.js index 6c0ce38688..7e8dbe33dd 100644 --- a/spec/ParseQuery.Aggregate.spec.js +++ b/spec/ParseQuery.Aggregate.spec.js @@ -127,15 +127,15 @@ describe('Parse.Query Aggregate testing', () => { get(Parse.serverURL + '/aggregate/TestObject', options) .then(resp => { expect(resp.results.length).toBe(3); - expect(Object.hasOwnProperty.call(resp.results[0], 'objectId')).toBe( - true - ); - expect(Object.hasOwnProperty.call(resp.results[1], 'objectId')).toBe( - true - ); - expect(Object.hasOwnProperty.call(resp.results[2], 'objectId')).toBe( - true - ); + expect( + Object.prototype.hasOwnProperty.call(resp.results[0], 'objectId') + ).toBe(true); + expect( + Object.prototype.hasOwnProperty.call(resp.results[1], 'objectId') + ).toBe(true); + expect( + Object.prototype.hasOwnProperty.call(resp.results[2], 'objectId') + ).toBe(true); expect(resp.results[0].objectId).not.toBe(undefined); expect(resp.results[1].objectId).not.toBe(undefined); expect(resp.results[2].objectId).not.toBe(undefined); @@ -154,9 +154,15 @@ describe('Parse.Query Aggregate testing', () => { }); const resp = await get(Parse.serverURL + '/aggregate/TestObject', options); expect(resp.results.length).toBe(3); - expect(Object.hasOwnProperty.call(resp.results[0], 'objectId')).toBe(true); - expect(Object.hasOwnProperty.call(resp.results[1], 'objectId')).toBe(true); - expect(Object.hasOwnProperty.call(resp.results[2], 'objectId')).toBe(true); + expect( + Object.prototype.hasOwnProperty.call(resp.results[0], 'objectId') + ).toBe(true); + expect( + Object.prototype.hasOwnProperty.call(resp.results[1], 'objectId') + ).toBe(true); + expect( + Object.prototype.hasOwnProperty.call(resp.results[2], 'objectId') + ).toBe(true); expect(resp.results[0].objectId).not.toBe(undefined); expect(resp.results[1].objectId).not.toBe(undefined); expect(resp.results[2].objectId).not.toBe(undefined); @@ -377,8 +383,12 @@ describe('Parse.Query Aggregate testing', () => { expect(results.length).toEqual(4); for (let i = 0; i < results.length; i++) { const item = results[i]; - expect(Object.hasOwnProperty.call(item, 'updatedAt')).toEqual(true); - expect(Object.hasOwnProperty.call(item, 'objectId')).toEqual(false); + expect(Object.prototype.hasOwnProperty.call(item, 'updatedAt')).toEqual( + true + ); + expect(Object.prototype.hasOwnProperty.call(item, 'objectId')).toEqual( + false + ); } done(); }); @@ -488,9 +498,9 @@ describe('Parse.Query Aggregate testing', () => { }); get(Parse.serverURL + '/aggregate/TestObject', options) .then(resp => { - expect(Object.hasOwnProperty.call(resp.results[0], 'objectId')).toBe( - true - ); + expect( + Object.prototype.hasOwnProperty.call(resp.results[0], 'objectId') + ).toBe(true); expect(resp.results[0].objectId).toBe(null); expect(resp.results[0].total).toBe(50); done(); @@ -506,9 +516,9 @@ describe('Parse.Query Aggregate testing', () => { }); get(Parse.serverURL + '/aggregate/TestObject', options) .then(resp => { - expect(Object.hasOwnProperty.call(resp.results[0], 'objectId')).toBe( - true - ); + expect( + Object.prototype.hasOwnProperty.call(resp.results[0], 'objectId') + ).toBe(true); expect(resp.results[0].objectId).toBe(null); expect(resp.results[0].total).toBe(4); done(); @@ -524,9 +534,9 @@ describe('Parse.Query Aggregate testing', () => { }); get(Parse.serverURL + '/aggregate/TestObject', options) .then(resp => { - expect(Object.hasOwnProperty.call(resp.results[0], 'objectId')).toBe( - true - ); + expect( + Object.prototype.hasOwnProperty.call(resp.results[0], 'objectId') + ).toBe(true); expect(resp.results[0].objectId).toBe(null); expect(resp.results[0].minScore).toBe(10); done(); @@ -542,9 +552,9 @@ describe('Parse.Query Aggregate testing', () => { }); get(Parse.serverURL + '/aggregate/TestObject', options) .then(resp => { - expect(Object.hasOwnProperty.call(resp.results[0], 'objectId')).toBe( - true - ); + expect( + Object.prototype.hasOwnProperty.call(resp.results[0], 'objectId') + ).toBe(true); expect(resp.results[0].objectId).toBe(null); expect(resp.results[0].maxScore).toBe(20); done(); @@ -560,9 +570,9 @@ describe('Parse.Query Aggregate testing', () => { }); get(Parse.serverURL + '/aggregate/TestObject', options) .then(resp => { - expect(Object.hasOwnProperty.call(resp.results[0], 'objectId')).toBe( - true - ); + expect( + Object.prototype.hasOwnProperty.call(resp.results[0], 'objectId') + ).toBe(true); expect(resp.results[0].objectId).toBe(null); expect(resp.results[0].avgScore).toBe(12.5); done(); @@ -982,7 +992,9 @@ describe('Parse.Query Aggregate testing', () => { .then(resp => { expect(resp.results.length).toBe(2); resp.results.forEach(result => { - expect(Object.hasOwnProperty.call(result, 'objectId')).toBe(true); + expect(Object.prototype.hasOwnProperty.call(result, 'objectId')).toBe( + true + ); expect(result.name).toBe(undefined); expect(result.sender).toBe(undefined); expect(result.size).toBe(undefined); diff --git a/spec/Schema.spec.js b/spec/Schema.spec.js index 8c2d7791a1..d45647d386 100644 --- a/spec/Schema.spec.js +++ b/spec/Schema.spec.js @@ -1382,22 +1382,28 @@ describe('SchemaController', () => { it('properly handles volatile _Schemas', done => { function validateSchemaStructure(schema) { - expect(Object.hasOwnProperty.call(schema, 'className')).toBe(true); - expect(Object.hasOwnProperty.call(schema, 'fields')).toBe(true); - expect(Object.hasOwnProperty.call(schema, 'classLevelPermissions')).toBe( + expect(Object.prototype.hasOwnProperty.call(schema, 'className')).toBe( true ); + expect(Object.prototype.hasOwnProperty.call(schema, 'fields')).toBe(true); + expect( + Object.prototype.hasOwnProperty.call(schema, 'classLevelPermissions') + ).toBe(true); } function validateSchemaDataStructure(schemaData) { Object.keys(schemaData).forEach(className => { const schema = schemaData[className]; // Hooks has className... if (className != '_Hooks') { - expect(Object.hasOwnProperty.call(schema, 'className')).toBe(false); + expect( + Object.prototype.hasOwnProperty.call(schema, 'className') + ).toBe(false); } - expect(Object.hasOwnProperty.call(schema, 'fields')).toBe(false); + expect(Object.prototype.hasOwnProperty.call(schema, 'fields')).toBe( + false + ); expect( - Object.hasOwnProperty.call(schema, 'classLevelPermissions') + Object.prototype.hasOwnProperty.call(schema, 'classLevelPermissions') ).toBe(false); }); } diff --git a/spec/VerifyUserPassword.spec.js b/spec/VerifyUserPassword.spec.js index 8b9aa3a867..c40985671b 100644 --- a/spec/VerifyUserPassword.spec.js +++ b/spec/VerifyUserPassword.spec.js @@ -469,8 +469,12 @@ describe('Verify User Password', () => { const res = response.data; expect(typeof res).toBe('object'); expect(typeof res['objectId']).toEqual('string'); - expect(Object.hasOwnProperty.call(res, 'sessionToken')).toEqual(false); - expect(Object.hasOwnProperty.call(res, 'password')).toEqual(false); + expect( + Object.prototype.hasOwnProperty.call(res, 'sessionToken') + ).toEqual(false); + expect(Object.prototype.hasOwnProperty.call(res, 'password')).toEqual( + false + ); done(); }) .catch(err => { @@ -493,8 +497,12 @@ describe('Verify User Password', () => { const res = response.data; expect(typeof res).toBe('object'); expect(typeof res['objectId']).toEqual('string'); - expect(Object.hasOwnProperty.call(res, 'sessionToken')).toEqual(false); - expect(Object.hasOwnProperty.call(res, 'password')).toEqual(false); + expect( + Object.prototype.hasOwnProperty.call(res, 'sessionToken') + ).toEqual(false); + expect(Object.prototype.hasOwnProperty.call(res, 'password')).toEqual( + false + ); done(); }); }); @@ -513,8 +521,12 @@ describe('Verify User Password', () => { const res = response.data; expect(typeof res).toBe('object'); expect(typeof res['objectId']).toEqual('string'); - expect(Object.hasOwnProperty.call(res, 'sessionToken')).toEqual(false); - expect(Object.hasOwnProperty.call(res, 'password')).toEqual(false); + expect( + Object.prototype.hasOwnProperty.call(res, 'sessionToken') + ).toEqual(false); + expect(Object.prototype.hasOwnProperty.call(res, 'password')).toEqual( + false + ); done(); }); }); @@ -544,8 +556,12 @@ describe('Verify User Password', () => { expect(typeof res).toBe('string'); const body = JSON.parse(res); expect(typeof body['objectId']).toEqual('string'); - expect(Object.hasOwnProperty.call(body, 'sessionToken')).toEqual(false); - expect(Object.hasOwnProperty.call(body, 'password')).toEqual(false); + expect( + Object.prototype.hasOwnProperty.call(body, 'sessionToken') + ).toEqual(false); + expect(Object.prototype.hasOwnProperty.call(body, 'password')).toEqual( + false + ); done(); }); }); @@ -575,8 +591,12 @@ describe('Verify User Password', () => { expect(typeof res).toBe('string'); const body = JSON.parse(res); expect(typeof body['objectId']).toEqual('string'); - expect(Object.hasOwnProperty.call(body, 'sessionToken')).toEqual(false); - expect(Object.hasOwnProperty.call(body, 'password')).toEqual(false); + expect( + Object.prototype.hasOwnProperty.call(body, 'sessionToken') + ).toEqual(false); + expect(Object.prototype.hasOwnProperty.call(body, 'password')).toEqual( + false + ); done(); }); }); @@ -603,8 +623,12 @@ describe('Verify User Password', () => { const res = response.data; expect(typeof res).toBe('object'); expect(typeof res['objectId']).toEqual('string'); - expect(Object.hasOwnProperty.call(res, 'sessionToken')).toEqual(false); - expect(Object.hasOwnProperty.call(res, 'password')).toEqual(false); + expect( + Object.prototype.hasOwnProperty.call(res, 'sessionToken') + ).toEqual(false); + expect(Object.prototype.hasOwnProperty.call(res, 'password')).toEqual( + false + ); done(); }); }); diff --git a/src/Adapters/Auth/index.js b/src/Adapters/Auth/index.js index 771b202146..5cc3f73466 100755 --- a/src/Adapters/Auth/index.js +++ b/src/Adapters/Auth/index.js @@ -67,7 +67,7 @@ function loadAuthAdapter(provider, authOptions) { const providerOptions = authOptions[provider]; if ( providerOptions && - Object.hasOwnProperty.call(providerOptions, 'oauth2') && + Object.prototype.hasOwnProperty.call(providerOptions, 'oauth2') && providerOptions['oauth2'] === true ) { defaultAdapter = oauth2; diff --git a/src/Adapters/Storage/Mongo/MongoStorageAdapter.js b/src/Adapters/Storage/Mongo/MongoStorageAdapter.js index b82ec6958c..365729ccc6 100644 --- a/src/Adapters/Storage/Mongo/MongoStorageAdapter.js +++ b/src/Adapters/Storage/Mongo/MongoStorageAdapter.js @@ -279,7 +279,7 @@ export class MongoStorageAdapter implements StorageAdapter { delete existingIndexes[name]; } else { Object.keys(field).forEach(key => { - if (!Object.hasOwnProperty.call(fields, key)) { + if (!Object.prototype.hasOwnProperty.call(fields, key)) { throw new Parse.Error( Parse.Error.INVALID_QUERY, `Field ${key} does not exist, cannot add index.` @@ -795,7 +795,7 @@ export class MongoStorageAdapter implements StorageAdapter { ) .then(results => { results.forEach(result => { - if (Object.hasOwnProperty.call(result, '_id')) { + if (Object.prototype.hasOwnProperty.call(result, '_id')) { if (isPointerField && result._id) { result._id = result._id.split('$')[1]; } @@ -1024,7 +1024,7 @@ export class MongoStorageAdapter implements StorageAdapter { const existingIndexes = schema.indexes; for (const key in existingIndexes) { const index = existingIndexes[key]; - if (Object.hasOwnProperty.call(index, fieldName)) { + if (Object.prototype.hasOwnProperty.call(index, fieldName)) { return Promise.resolve(); } } diff --git a/src/Adapters/Storage/Mongo/MongoTransform.js b/src/Adapters/Storage/Mongo/MongoTransform.js index 78ff7d130f..9f920e9608 100644 --- a/src/Adapters/Storage/Mongo/MongoTransform.js +++ b/src/Adapters/Storage/Mongo/MongoTransform.js @@ -1282,7 +1282,7 @@ const nestedMongoObjectToNestedParseObject = mongoObject => { } if ( - Object.hasOwnProperty.call(mongoObject, '__type') && + Object.prototype.hasOwnProperty.call(mongoObject, '__type') && mongoObject.__type == 'Date' && mongoObject.iso instanceof Date ) { diff --git a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js index faf88e23cc..e462db1201 100644 --- a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js +++ b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js @@ -903,7 +903,7 @@ export class PostgresStorageAdapter implements StorageAdapter { delete existingIndexes[name]; } else { Object.keys(field).forEach(key => { - if (!Object.hasOwnProperty.call(fields, key)) { + if (!Object.prototype.hasOwnProperty.call(fields, key)) { throw new Parse.Error( Parse.Error.INVALID_QUERY, `Field ${key} does not exist, cannot add index.` @@ -2219,7 +2219,10 @@ export class PostgresStorageAdapter implements StorageAdapter { } if (stage.$match) { const patterns = []; - const orOrAnd = Object.hasOwnProperty.call(stage.$match, '$or') + const orOrAnd = Object.prototype.hasOwnProperty.call( + stage.$match, + '$or' + ) ? ' OR ' : ' AND '; @@ -2296,7 +2299,7 @@ export class PostgresStorageAdapter implements StorageAdapter { ) .then(results => { results.forEach(result => { - if (!Object.hasOwnProperty.call(result, 'objectId')) { + if (!Object.prototype.hasOwnProperty.call(result, 'objectId')) { result.objectId = null; } if (groupValues) { diff --git a/src/Controllers/DatabaseController.js b/src/Controllers/DatabaseController.js index 5f1c3e882c..285e552c39 100644 --- a/src/Controllers/DatabaseController.js +++ b/src/Controllers/DatabaseController.js @@ -119,7 +119,7 @@ const validateQuery = ( */ Object.keys(query).forEach(key => { const noCollisions = !query.$or.some(subq => - Object.hasOwnProperty.call(subq, key) + Object.prototype.hasOwnProperty.call(subq, key) ); let hasNears = false; if (query[key] != null && typeof query[key] == 'object') { @@ -1487,7 +1487,7 @@ class DatabaseController { [key]: userPointer, }; // if we already have a constraint on the key, use the $and - if (Object.hasOwnProperty.call(query, key)) { + if (Object.prototype.hasOwnProperty.call(query, key)) { return { $and: [q, query] }; } // otherwise just add the constaint diff --git a/src/Controllers/PushController.js b/src/Controllers/PushController.js index aa09dc62ff..4739235810 100644 --- a/src/Controllers/PushController.js +++ b/src/Controllers/PushController.js @@ -34,7 +34,7 @@ export class PushController { // Immediate push if ( body.expiration_interval && - !Object.hasOwnProperty.call(body, 'push_time') + !Object.prototype.hasOwnProperty.call(body, 'push_time') ) { const ttlMs = body.expiration_interval * 1000; body.expiration_time = new Date(now.valueOf() + ttlMs).valueOf(); @@ -124,7 +124,7 @@ export class PushController { }) .then(() => { if ( - Object.hasOwnProperty.call(body, 'push_time') && + Object.prototype.hasOwnProperty.call(body, 'push_time') && config.hasPushScheduledSupport ) { return Promise.resolve(); @@ -150,7 +150,10 @@ export class PushController { * @returns {Number|undefined} The expiration time if it exists in the request */ static getExpirationTime(body = {}) { - var hasExpirationTime = Object.hasOwnProperty.call(body, 'expiration_time'); + var hasExpirationTime = Object.prototype.hasOwnProperty.call( + body, + 'expiration_time' + ); if (!hasExpirationTime) { return; } @@ -177,7 +180,7 @@ export class PushController { } static getExpirationInterval(body = {}) { - const hasExpirationInterval = Object.hasOwnProperty.call( + const hasExpirationInterval = Object.prototype.hasOwnProperty.call( body, 'expiration_interval' ); @@ -204,7 +207,7 @@ export class PushController { * @returns {Number|undefined} The push time if it exists in the request */ static getPushTime(body = {}) { - var hasPushTime = Object.hasOwnProperty.call(body, 'push_time'); + var hasPushTime = Object.prototype.hasOwnProperty.call(body, 'push_time'); if (!hasPushTime) { return; } diff --git a/src/LiveQuery/ParseLiveQueryServer.js b/src/LiveQuery/ParseLiveQueryServer.js index 03d1619302..b0d254f2e8 100644 --- a/src/LiveQuery/ParseLiveQueryServer.js +++ b/src/LiveQuery/ParseLiveQueryServer.js @@ -600,7 +600,10 @@ class ParseLiveQueryServer { ) { return false; } - if (!request || !Object.hasOwnProperty.call(request, 'masterKey')) { + if ( + !request || + !Object.prototype.hasOwnProperty.call(request, 'masterKey') + ) { return false; } return request.masterKey === validKeyPairs.get('masterKey'); @@ -623,7 +626,7 @@ class ParseLiveQueryServer { _handleSubscribe(parseWebsocket: any, request: any): any { // If we can not find this client, return error to client - if (!Object.hasOwnProperty.call(parseWebsocket, 'clientId')) { + if (!Object.prototype.hasOwnProperty.call(parseWebsocket, 'clientId')) { Client.pushError( parseWebsocket, 2, @@ -699,7 +702,7 @@ class ParseLiveQueryServer { notifyClient: boolean = true ): any { // If we can not find this client, return error to client - if (!Object.hasOwnProperty.call(parseWebsocket, 'clientId')) { + if (!Object.prototype.hasOwnProperty.call(parseWebsocket, 'clientId')) { Client.pushError( parseWebsocket, 2, diff --git a/src/LiveQuery/QueryTools.js b/src/LiveQuery/QueryTools.js index ea5c96f120..c5e588d0e2 100644 --- a/src/LiveQuery/QueryTools.js +++ b/src/LiveQuery/QueryTools.js @@ -13,7 +13,7 @@ var Parse = require('parse/node'); * Convert $or queries into an array of where conditions */ function flattenOrQueries(where) { - if (!Object.hasOwnProperty.call(where, '$or')) { + if (!Object.prototype.hasOwnProperty.call(where, '$or')) { return where; } var accum = []; diff --git a/src/ParseServer.js b/src/ParseServer.js index 58f033dd0f..7c851713fa 100644 --- a/src/ParseServer.js +++ b/src/ParseServer.js @@ -356,12 +356,12 @@ function addParseCloud() { function injectDefaults(options: ParseServerOptions) { Object.keys(defaults).forEach(key => { - if (!Object.hasOwnProperty.call(options, key)) { + if (!Object.prototype.hasOwnProperty.call(options, key)) { options[key] = defaults[key]; } }); - if (!Object.hasOwnProperty.call(options, 'serverURL')) { + if (!Object.prototype.hasOwnProperty.call(options, 'serverURL')) { options.serverURL = `http://localhost:${options.port}${options.mountPath}`; } diff --git a/src/Push/utils.js b/src/Push/utils.js index 260d85528d..ce7023917e 100644 --- a/src/Push/utils.js +++ b/src/Push/utils.js @@ -132,7 +132,7 @@ export function validatePushType(where = {}, validPushTypes = []) { export function applyDeviceTokenExists(where) { where = deepcopy(where); - if (!Object.hasOwnProperty.call(where, 'deviceToken')) { + if (!Object.prototype.hasOwnProperty.call(where, 'deviceToken')) { where['deviceToken'] = { $exists: true }; } return where; diff --git a/src/RestQuery.js b/src/RestQuery.js index 6dc2617184..70ce333ec6 100644 --- a/src/RestQuery.js +++ b/src/RestQuery.js @@ -71,7 +71,7 @@ function RestQuery( // If we have keys, we probably want to force some includes (n-1 level) // See issue: https://github.com/parse-community/parse-server/issues/3185 - if (Object.hasOwnProperty.call(restOptions, 'keys')) { + if (Object.prototype.hasOwnProperty.call(restOptions, 'keys')) { const keysForInclude = restOptions.keys .split(',') .filter(key => { diff --git a/src/RestWrite.js b/src/RestWrite.js index 331b6f24bb..083254ed4b 100644 --- a/src/RestWrite.js +++ b/src/RestWrite.js @@ -1711,7 +1711,7 @@ RestWrite.prototype._updateResponseWithData = function(response, data) { this.storage.fieldsChangedByTrigger.forEach(fieldName => { const dataValue = data[fieldName]; - if (!Object.hasOwnProperty.call(response, fieldName)) { + if (!Object.prototype.hasOwnProperty.call(response, fieldName)) { response[fieldName] = dataValue; } diff --git a/src/Routers/AggregateRouter.js b/src/Routers/AggregateRouter.js index 7fe95499a0..591ebd3469 100644 --- a/src/Routers/AggregateRouter.js +++ b/src/Routers/AggregateRouter.js @@ -122,13 +122,13 @@ export class AggregateRouter extends ClassesRouter { ); } if (stageName === 'group') { - if (Object.hasOwnProperty.call(stage[stageName], '_id')) { + if (Object.prototype.hasOwnProperty.call(stage[stageName], '_id')) { throw new Parse.Error( Parse.Error.INVALID_QUERY, `Invalid parameter for query: group. Please use objectId instead of _id` ); } - if (!Object.hasOwnProperty.call(stage[stageName], 'objectId')) { + if (!Object.prototype.hasOwnProperty.call(stage[stageName], 'objectId')) { throw new Parse.Error( Parse.Error.INVALID_QUERY, `Invalid parameter for query: group. objectId is required` diff --git a/src/Routers/UsersRouter.js b/src/Routers/UsersRouter.js index cead30f576..b6ddc28fae 100644 --- a/src/Routers/UsersRouter.js +++ b/src/Routers/UsersRouter.js @@ -20,7 +20,7 @@ export class UsersRouter extends ClassesRouter { */ static removeHiddenProperties(obj) { for (var key in obj) { - if (Object.hasOwnProperty.call(obj, key)) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { // Regexp comes from Parse.Object.prototype.validate if (key !== '__type' && !/^[A-Za-z][0-9A-Za-z_]*$/.test(key)) { delete obj[key]; diff --git a/src/StatusHandler.js b/src/StatusHandler.js index 293ee28bfd..db8e816596 100644 --- a/src/StatusHandler.js +++ b/src/StatusHandler.js @@ -148,7 +148,7 @@ export function pushStatusHandler(config, existingObjectId) { const now = new Date(); let pushTime = now.toISOString(); let status = 'pending'; - if (Object.hasOwnProperty.call(body, 'push_time')) { + if (Object.prototype.hasOwnProperty.call(body, 'push_time')) { if (config.hasPushScheduledSupport) { pushTime = body.push_time; status = 'scheduled'; diff --git a/src/cli/utils/commander.js b/src/cli/utils/commander.js index c57e5a7b02..a4e9683074 100644 --- a/src/cli/utils/commander.js +++ b/src/cli/utils/commander.js @@ -102,7 +102,7 @@ function parseConfigFile(program) { Command.prototype.setValuesIfNeeded = function(options) { Object.keys(options).forEach(key => { - if (!Object.hasOwnProperty.call(this, key)) { + if (!Object.prototype.hasOwnProperty.call(this, key)) { this[key] = options[key]; } }); diff --git a/src/cloud-code/Parse.Cloud.js b/src/cloud-code/Parse.Cloud.js index 8df15a0840..9039c3ef2f 100644 --- a/src/cloud-code/Parse.Cloud.js +++ b/src/cloud-code/Parse.Cloud.js @@ -4,7 +4,7 @@ import * as triggers from '../triggers'; function isParseObjectConstructor(object) { return ( typeof object === 'function' && - Object.hasOwnProperty.call(object, 'className') + Object.prototype.hasOwnProperty.call(object, 'className') ); } diff --git a/src/defaults.js b/src/defaults.js index 8025736b42..ba603424a8 100644 --- a/src/defaults.js +++ b/src/defaults.js @@ -19,7 +19,7 @@ const { verbose, level } = (() => { const DefinitionDefaults = Object.keys(ParseServerOptions).reduce( (memo, key) => { const def = ParseServerOptions[key]; - if (Object.hasOwnProperty.call(def, 'default')) { + if (Object.prototype.hasOwnProperty.call(def, 'default')) { memo[key] = def.default; } return memo;