Skip to content

Commit 25d71e6

Browse files
committed
add test in GCP as well
1 parent cc31452 commit 25d71e6

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/gcp_auth_test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,4 +285,25 @@ describe('GoogleCloudPlatformAuth', () => {
285285
expect(opts.headers.Authorization).to.equal(`Bearer ${token}`);
286286
}
287287
});
288+
289+
it('should throw if tried to run JavaScript inside the token key', async () => {
290+
const token = 'token';
291+
const responseStr = `{"token":{"accessToken":"${token}"}}`;
292+
293+
const user = {
294+
authProvider: {
295+
name: 'gcp',
296+
config: {
297+
'cmd-path': join(__dirname, '..', 'test', 'echo space.js'),
298+
'cmd-args': `'${responseStr}'`,
299+
'expiry-key': '{.token.token_expiry}',
300+
301+
// The problematic token
302+
'token-key': '{..[?(' + '(function a(arr){' + 'a([...arr, ...arr])' + '})([1]);)]}',
303+
},
304+
},
305+
} as User;
306+
307+
await expect(auth.applyAuthentication(user, {})).to.eventually.be.rejectedWith('Eval [?(expr)] prevented in JSONPath expression.');
308+
});
288309
});

src/json_path_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect } from 'chai';
22
import { jsonpath } from './json_path';
33

44
describe('jsonpath', () => {
5-
it('should throw if vulnerable for RCE (remote code execution)', () => {
5+
it('should throw if tried to run JavaScript inside the path', () => {
66
expect(() => {
77
jsonpath('$..[?(' + '(function a(arr){' + 'a([...arr, ...arr])' + '})([1]);)]', {
88
nonEmpty: 'object',

0 commit comments

Comments
 (0)