Skip to content

Commit 8709daf

Browse files
authored
Merge pull request from GHSA-2479-qvv7-47qq
* Failing test * provide fix * clearer test * failing expect
1 parent 54ba9a0 commit 8709daf

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

Diff for: spec/AudienceRouter.spec.js

+25
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const auth = require('../lib/Auth');
22
const Config = require('../lib/Config');
33
const rest = require('../lib/rest');
4+
const request = require('../lib/request');
45
const AudiencesRouter = require('../lib/Routers/AudiencesRouter')
56
.AudiencesRouter;
67

@@ -438,4 +439,28 @@ describe('AudiencesRouter', () => {
438439
});
439440
});
440441
});
442+
443+
it('should handle _Audience invalid fields via rest', async () => {
444+
await reconfigureServer({
445+
appId: 'test',
446+
restAPIKey: 'test',
447+
publicServerURL: 'http://localhost:8378/1',
448+
});
449+
try {
450+
await request({
451+
method: 'POST',
452+
url: 'http://localhost:8378/1/classes/_Audience',
453+
body: { lorem: 'ipsum', _method: 'POST' },
454+
headers: {
455+
'X-Parse-Application-Id': 'test',
456+
'X-Parse-REST-API-Key': 'test',
457+
'Content-Type': 'application/json',
458+
},
459+
});
460+
expect(true).toBeFalsy();
461+
} catch (e) {
462+
expect(e.data.code).toBe(107);
463+
expect(e.data.error).toBe('Could not add field lorem');
464+
}
465+
});
441466
});

Diff for: src/Controllers/SchemaController.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,7 @@ function validateCLP(perms: ClassLevelPermissions, fields: SchemaFields) {
228228
// @flow-disable-next
229229
throw new Parse.Error(
230230
Parse.Error.INVALID_JSON,
231-
`'${
232-
perms[operation]
233-
}' is not a valid value for class level permissions ${operation}`
231+
`'${perms[operation]}' is not a valid value for class level permissions ${operation}`
234232
);
235233
} else {
236234
perms[operation].forEach(key => {
@@ -395,6 +393,9 @@ class SchemaData {
395393
this.__data = {};
396394
this.__protectedFields = protectedFields;
397395
allSchemas.forEach(schema => {
396+
if (volatileClasses.includes(schema.className)) {
397+
return;
398+
}
398399
Object.defineProperty(this, schema.className, {
399400
get: () => {
400401
if (!this.__data[schema.className]) {

0 commit comments

Comments
 (0)