-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
feat: Sanitize error for security #9937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: alpha
Are you sure you want to change the base?
Changes from 12 commits
a310696
a413efd
d78f994
79bf5f5
51f360c
bb3eef0
79ed425
fdf074a
f40fda6
767aba0
16cf793
bbb007f
7f282c3
70382e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -263,55 +263,75 @@ describe('AudiencesRouter', () => { | |
| }); | ||
|
|
||
| it('should only create with master key', done => { | ||
| const logger = require('../lib/logger').default; | ||
| const loggerErrorSpy = spyOn(logger, 'error').and.callThrough(); | ||
| loggerErrorSpy.calls.reset(); | ||
| Parse._request('POST', 'push_audiences', { | ||
| name: 'My Audience', | ||
| query: JSON.stringify({ deviceType: 'ios' }), | ||
| }).then( | ||
| () => {}, | ||
| error => { | ||
| expect(error.message).toEqual('unauthorized: master key is required'); | ||
| expect(error.message).toEqual('Permission denied'); | ||
| expect(loggerErrorSpy).toHaveBeenCalledWith('Sanitized error:', jasmine.stringContaining('unauthorized: master key is required')); | ||
| done(); | ||
| } | ||
| ); | ||
| }); | ||
|
|
||
| it('should only find with master key', done => { | ||
| const logger = require('../lib/logger').default; | ||
| const loggerErrorSpy = spyOn(logger, 'error').and.callThrough(); | ||
|
||
| loggerErrorSpy.calls.reset(); | ||
| Parse._request('GET', 'push_audiences', {}).then( | ||
| () => {}, | ||
| error => { | ||
| expect(error.message).toEqual('unauthorized: master key is required'); | ||
| expect(error.message).toEqual('Permission denied'); | ||
| expect(loggerErrorSpy).toHaveBeenCalledWith('Sanitized error:', jasmine.stringContaining('unauthorized: master key is required')); | ||
| done(); | ||
| } | ||
| ); | ||
| }); | ||
|
|
||
| it('should only get with master key', done => { | ||
| const logger = require('../lib/logger').default; | ||
| const loggerErrorSpy = spyOn(logger, 'error').and.callThrough(); | ||
| loggerErrorSpy.calls.reset(); | ||
| Parse._request('GET', `push_audiences/someId`, {}).then( | ||
| () => {}, | ||
| error => { | ||
| expect(error.message).toEqual('unauthorized: master key is required'); | ||
| expect(error.message).toEqual('Permission denied'); | ||
| expect(loggerErrorSpy).toHaveBeenCalledWith('Sanitized error:', jasmine.stringContaining('unauthorized: master key is required')); | ||
| done(); | ||
| } | ||
| ); | ||
| }); | ||
|
|
||
| it('should only update with master key', done => { | ||
| const logger = require('../lib/logger').default; | ||
| const loggerErrorSpy = spyOn(logger, 'error').and.callThrough(); | ||
| loggerErrorSpy.calls.reset(); | ||
| Parse._request('PUT', `push_audiences/someId`, { | ||
| name: 'My Audience 2', | ||
| }).then( | ||
| () => {}, | ||
| error => { | ||
| expect(error.message).toEqual('unauthorized: master key is required'); | ||
| expect(error.message).toEqual('Permission denied'); | ||
| expect(loggerErrorSpy).toHaveBeenCalledWith('Sanitized error:', jasmine.stringContaining('unauthorized: master key is required')); | ||
| done(); | ||
| } | ||
| ); | ||
| }); | ||
|
|
||
| it('should only delete with master key', done => { | ||
| const logger = require('../lib/logger').default; | ||
| const loggerErrorSpy = spyOn(logger, 'error').and.callThrough(); | ||
| loggerErrorSpy.calls.reset(); | ||
| Parse._request('DELETE', `push_audiences/someId`, {}).then( | ||
| () => {}, | ||
| error => { | ||
| expect(error.message).toEqual('unauthorized: master key is required'); | ||
| expect(error.message).toEqual('Permission denied'); | ||
| expect(loggerErrorSpy).toHaveBeenCalledWith('Sanitized error:', jasmine.stringContaining('unauthorized: master key is required')); | ||
| done(); | ||
| } | ||
| ); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.