File tree Expand file tree Collapse file tree 4 files changed +26
-6
lines changed Expand file tree Collapse file tree 4 files changed +26
-6
lines changed Original file line number Diff line number Diff line change 1
1
import * as proc from 'child_process' ;
2
2
import https = require( 'https' ) ;
3
- import * as jsonpath from 'jsonpath-plus' ;
4
3
import request = require( 'request' ) ;
5
4
6
5
import { Authenticator } from './auth' ;
7
6
import { User } from './config_types' ;
7
+ import { jsonpath } from './json_path' ;
8
8
9
9
/* FIXME: maybe we can extend the User and User.authProvider type to have a proper type.
10
10
Currently user.authProvider has `any` type and so we don't have a type for user.authProvider.config.
@@ -94,7 +94,7 @@ export class AzureAuth implements Authenticator {
94
94
const tokenPathKey = '$' + tokenPathKeyInConfig . slice ( 1 , - 1 ) ;
95
95
const expiryPathKey = '$' + expiryPathKeyInConfig . slice ( 1 , - 1 ) ;
96
96
97
- config [ 'access-token' ] = jsonpath . JSONPath ( tokenPathKey , resultObj ) ;
98
- config . expiry = jsonpath . JSONPath ( expiryPathKey , resultObj ) ;
97
+ config [ 'access-token' ] = jsonpath ( tokenPathKey , resultObj ) ;
98
+ config . expiry = jsonpath ( expiryPathKey , resultObj ) ;
99
99
}
100
100
}
Original file line number Diff line number Diff line change 1
1
import * as proc from 'child_process' ;
2
2
import https = require( 'https' ) ;
3
- import * as jsonpath from 'jsonpath-plus' ;
4
3
import request = require( 'request' ) ;
5
4
6
5
import { Authenticator } from './auth' ;
7
6
import { User } from './config_types' ;
7
+ import { jsonpath } from './json_path' ;
8
8
9
9
/* FIXME: maybe we can extend the User and User.authProvider type to have a proper type.
10
10
Currently user.authProvider has `any` type and so we don't have a type for user.authProvider.config.
@@ -90,7 +90,7 @@ export class GoogleCloudPlatformAuth implements Authenticator {
90
90
const tokenPathKey = '$' + tokenPathKeyInConfig . slice ( 1 , - 1 ) ;
91
91
const expiryPathKey = '$' + expiryPathKeyInConfig . slice ( 1 , - 1 ) ;
92
92
93
- config [ 'access-token' ] = jsonpath . JSONPath ( tokenPathKey , resultObj ) ;
94
- config . expiry = jsonpath . JSONPath ( expiryPathKey , resultObj ) ;
93
+ config [ 'access-token' ] = jsonpath ( tokenPathKey , resultObj ) ;
94
+ config . expiry = jsonpath ( expiryPathKey , resultObj ) ;
95
95
}
96
96
}
Original file line number Diff line number Diff line change
1
+ import { JSONPath } from 'jsonpath-plus' ;
2
+
3
+ export function jsonpath ( path : string , json : object ) : any {
4
+ return JSONPath ( {
5
+ path,
6
+ json,
7
+
8
+ preventEval : true ,
9
+ } ) ;
10
+ }
Original file line number Diff line number Diff line change
1
+ import { expect } from 'chai' ;
2
+ import { jsonpath } from './json_path' ;
3
+
4
+ describe ( 'jsonpath' , ( ) => {
5
+ it ( 'should throw if vulnerable for RCE (remote code execution)' , ( ) => {
6
+ expect ( ( ) => {
7
+ jsonpath ( '$..[?(' + '(function a(arr){' + 'a([...arr, ...arr])' + '})([1]);)]' , { nonEmpty : 'object' } ) ;
8
+ } ) . to . throw ( ) ;
9
+ } ) ;
10
+ } ) ;
You can’t perform that action at this time.
0 commit comments