File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -133,12 +133,14 @@ describe("deriveSessionName", () => {
133133 expect ( deriveSessionName ( "cmd 'a b\\' next" ) ) . toBe ( "cmd a b\\" ) ;
134134 } ) ;
135135
136- it ( "returns a label without catastrophic backtracking on an unterminated quote followed by backslashes" , ( ) => {
137- const malicious = `node "${ "\\" . repeat ( 50000 ) } ` ;
138- const start = process . hrtime . bigint ( ) ;
139- const label = deriveSessionName ( malicious ) ;
140- const elapsedMs = Number ( process . hrtime . bigint ( ) - start ) / 1e6 ;
141- expect ( typeof label ) . toBe ( "string" ) ;
142- expect ( elapsedMs ) . toBeLessThan ( 100 ) ;
136+ it ( "returns a label without catastrophic backtracking on unterminated quoted backslash runs" , ( ) => {
137+ for ( const quote of [ `"` , `'` ] ) {
138+ const malicious = `node ${ quote } ${ "\\" . repeat ( 50000 ) } ` ;
139+ const start = process . hrtime . bigint ( ) ;
140+ const label = deriveSessionName ( malicious ) ;
141+ const elapsedMs = Number ( process . hrtime . bigint ( ) - start ) / 1e6 ;
142+ expect ( typeof label ) . toBe ( "string" ) ;
143+ expect ( elapsedMs ) . toBeLessThan ( 100 ) ;
144+ }
143145 } ) ;
144146} ) ;
You can’t perform that action at this time.
0 commit comments