Skip to content

Commit abfa94c

Browse files
authored
fix: Security upgrade to parse 7.0.1 (#9877)
1 parent 84cebd4 commit abfa94c

File tree

10 files changed

+230
-91
lines changed

10 files changed

+230
-91
lines changed

package-lock.json

Lines changed: 46 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"mongodb": "6.17.0",
5050
"mustache": "4.2.0",
5151
"otpauth": "9.4.0",
52-
"parse": "6.1.1",
52+
"parse": "7.0.1",
5353
"path-to-regexp": "6.3.0",
5454
"pg-monitor": "3.0.0",
5555
"pg-promise": "12.2.0",

spec/Adapters/Auth/linkedIn.spec.js

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,16 @@ describe('LinkedInAdapter', function () {
8989

9090
describe('Test getUserFromAccessToken', function () {
9191
it('should fetch user successfully', async function () {
92-
global.fetch = jasmine.createSpy().and.returnValue(
93-
Promise.resolve({
94-
ok: true,
95-
json: () => Promise.resolve({ id: 'validUserId' }),
96-
})
97-
);
92+
mockFetch([
93+
{
94+
url: 'https://api.linkedin.com/v2/me',
95+
method: 'GET',
96+
response: {
97+
ok: true,
98+
json: () => Promise.resolve({ id: 'validUserId' }),
99+
},
100+
},
101+
]);
98102

99103
const user = await adapter.getUserFromAccessToken('validToken', false);
100104

@@ -104,14 +108,21 @@ describe('LinkedInAdapter', function () {
104108
'x-li-format': 'json',
105109
'x-li-src': undefined,
106110
},
111+
method: 'GET',
107112
});
108113
expect(user).toEqual({ id: 'validUserId' });
109114
});
110115

111116
it('should throw error for invalid response', async function () {
112-
global.fetch = jasmine.createSpy().and.returnValue(
113-
Promise.resolve({ ok: false })
114-
);
117+
mockFetch([
118+
{
119+
url: 'https://api.linkedin.com/v2/me',
120+
method: 'GET',
121+
response: {
122+
ok: false,
123+
},
124+
},
125+
]);
115126

116127
await expectAsync(adapter.getUserFromAccessToken('invalidToken', false)).toBeRejectedWith(
117128
new Error('LinkedIn API request failed.')
@@ -121,12 +132,16 @@ describe('LinkedInAdapter', function () {
121132

122133
describe('Test getAccessTokenFromCode', function () {
123134
it('should fetch token successfully', async function () {
124-
global.fetch = jasmine.createSpy().and.returnValue(
125-
Promise.resolve({
126-
ok: true,
127-
json: () => Promise.resolve({ access_token: 'validToken' }),
128-
})
129-
);
135+
mockFetch([
136+
{
137+
url: 'https://www.linkedin.com/oauth/v2/accessToken',
138+
method: 'POST',
139+
response: {
140+
ok: true,
141+
json: () => Promise.resolve({ access_token: 'validToken' }),
142+
},
143+
},
144+
]);
130145

131146
const tokenResponse = await adapter.getAccessTokenFromCode('validCode', 'http://example.com');
132147

@@ -139,9 +154,15 @@ describe('LinkedInAdapter', function () {
139154
});
140155

141156
it('should throw error for invalid response', async function () {
142-
global.fetch = jasmine.createSpy().and.returnValue(
143-
Promise.resolve({ ok: false })
144-
);
157+
mockFetch([
158+
{
159+
url: 'https://www.linkedin.com/oauth/v2/accessToken',
160+
method: 'POST',
161+
response: {
162+
ok: false,
163+
},
164+
},
165+
]);
145166

146167
await expectAsync(
147168
adapter.getAccessTokenFromCode('invalidCode', 'http://example.com')

spec/Adapters/Auth/wechat.spec.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ describe('WeChatAdapter', function () {
2323
const user = await adapter.getUserFromAccessToken('validToken', { id: 'validOpenId' });
2424

2525
expect(global.fetch).toHaveBeenCalledWith(
26-
'https://api.weixin.qq.com/sns/auth?access_token=validToken&openid=validOpenId'
26+
'https://api.weixin.qq.com/sns/auth?access_token=validToken&openid=validOpenId',
27+
jasmine.any(Object)
2728
);
2829
expect(user).toEqual({ errcode: 0, id: 'validUserId' });
2930
});
@@ -64,7 +65,8 @@ describe('WeChatAdapter', function () {
6465
const token = await adapter.getAccessTokenFromCode(authData);
6566

6667
expect(global.fetch).toHaveBeenCalledWith(
67-
'https://api.weixin.qq.com/sns/oauth2/access_token?appid=validAppId&secret=validAppSecret&code=validCode&grant_type=authorization_code'
68+
'https://api.weixin.qq.com/sns/oauth2/access_token?appid=validAppId&secret=validAppSecret&code=validCode&grant_type=authorization_code',
69+
jasmine.any(Object)
6870
);
6971
expect(token).toEqual('validToken');
7072
});

spec/CloudCodeLogger.spec.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ describe('Cloud Code Logger', () => {
189189
});
190190
});
191191

192-
it_id('8088de8a-7cba-4035-8b05-4a903307e674')(it)('should log cloud function execution using the custom log level', async done => {
192+
it_id('8088de8a-7cba-4035-8b05-4a903307e674')(it)('should log cloud function execution using the custom log level', async () => {
193193
Parse.Cloud.define('aFunction', () => {
194194
return 'it worked!';
195195
});
@@ -203,6 +203,7 @@ describe('Cloud Code Logger', () => {
203203
expect(log).toEqual('info');
204204
});
205205

206+
Parse.Cloud._removeAllHooks();
206207
await reconfigureServer({
207208
silent: true,
208209
logLevels: {
@@ -211,6 +212,10 @@ describe('Cloud Code Logger', () => {
211212
},
212213
});
213214

215+
Parse.Cloud.define('bFunction', () => {
216+
throw new Error('Failed');
217+
});
218+
214219
spy = spyOn(Config.get('test').loggerController.adapter, 'log').and.callThrough();
215220

216221
try {
@@ -221,15 +226,12 @@ describe('Cloud Code Logger', () => {
221226
.allArgs()
222227
.find(log => log[1].startsWith('Failed running cloud function bFunction for '))?.[0];
223228
expect(log).toEqual('info');
224-
done();
225229
}
226230
});
227231

228232
it('should log cloud function triggers using the custom log level', async () => {
229-
Parse.Cloud.beforeSave('TestClass', () => {});
230-
Parse.Cloud.afterSave('TestClass', () => {});
231-
232233
const execTest = async (logLevel, triggerBeforeSuccess, triggerAfter) => {
234+
Parse.Cloud._removeAllHooks();
233235
await reconfigureServer({
234236
silent: true,
235237
logLevel,
@@ -239,6 +241,9 @@ describe('Cloud Code Logger', () => {
239241
},
240242
});
241243

244+
Parse.Cloud.beforeSave('TestClass', () => { });
245+
Parse.Cloud.afterSave('TestClass', () => { });
246+
242247
spy = spyOn(Config.get('test').loggerController.adapter, 'log').and.callThrough();
243248
const obj = new Parse.Object('TestClass');
244249
await obj.save();
@@ -344,6 +349,7 @@ describe('Cloud Code Logger', () => {
344349
});
345350

346351
it('should log cloud function execution using the silent log level', async () => {
352+
Parse.Cloud._removeAllHooks();
347353
await reconfigureServer({
348354
logLevels: {
349355
cloudFunctionSuccess: 'silent',
@@ -367,6 +373,7 @@ describe('Cloud Code Logger', () => {
367373
});
368374

369375
it('should log cloud function triggers using the silent log level', async () => {
376+
Parse.Cloud._removeAllHooks();
370377
await reconfigureServer({
371378
logLevels: {
372379
triggerAfter: 'silent',

spec/ParseObject.spec.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,10 +1395,10 @@ describe('Parse.Object testing', () => {
13951395
.save()
13961396
.then(function () {
13971397
const query = new Parse.Query(TestObject);
1398-
return query.find(object.id);
1398+
return query.get(object.id);
13991399
})
1400-
.then(function (results) {
1401-
updatedObject = results[0];
1400+
.then(function (result) {
1401+
updatedObject = result;
14021402
updatedObject.set('x', 11);
14031403
return updatedObject.save();
14041404
})
@@ -1409,7 +1409,8 @@ describe('Parse.Object testing', () => {
14091409
equal(object.createdAt.getTime(), updatedObject.createdAt.getTime());
14101410
equal(object.updatedAt.getTime(), updatedObject.updatedAt.getTime());
14111411
done();
1412-
});
1412+
})
1413+
.catch(done.fail);
14131414
});
14141415

14151416
xit('fetchAll backbone-style callbacks', function (done) {

0 commit comments

Comments
 (0)