@@ -123,6 +123,10 @@ test('testWebhookValidation', async function testWebhookValidation(): Promise<an
123
123
'{"webhook":{"id":"1234567890"},"trigger":"FILE.UPLOADED","source":{"id":"1234567890","type":"file","name":"\uD83D\uDE00 2020-08-05.txt"}}' ;
124
124
const bodyWithCarriageReturn : string =
125
125
'{"webhook":{"id":"1234567890"},"trigger":"FILE.UPLOADED","source":{"id":"1234567890","type":"file","name":"test \\r"}}' ;
126
+ const bodyWithForwardSlash : string =
127
+ '{"webhook":{"id":"1234567890"},"trigger":"FILE.UPLOADED","source":{"id":"1234567890","type":"file","name":"\\/"}}' ;
128
+ const bodyWithBackSlash : string =
129
+ '{"webhook":{"id":"1234567890"},"trigger":"FILE.UPLOADED","source":{"id":"1234567890","type":"file","name":"\\\\"}}' ;
126
130
const headers : {
127
131
readonly [ key : string ] : string ;
128
132
} = {
@@ -157,6 +161,22 @@ test('testWebhookValidation', async function testWebhookValidation(): Promise<an
157
161
[ 'box-signature-primary' ] : 'SVkbKgy3dEEf2PbbzpNu2lDZS7zZ/aboU7HOZgBGrJk=' ,
158
162
} ,
159
163
} ;
164
+ const headersWithForwardSlash : {
165
+ readonly [ key : string ] : any ;
166
+ } = {
167
+ ...headers ,
168
+ ...{
169
+ [ 'box-signature-primary' ] : 't41PWT5ZB6OcysnD6SDy9Ud+p9hdXxIdXqcdweyZv/Q=' ,
170
+ } ,
171
+ } ;
172
+ const headersWithBackSlash : {
173
+ readonly [ key : string ] : any ;
174
+ } = {
175
+ ...headers ,
176
+ ...{
177
+ [ 'box-signature-primary' ] : 'ERpMZwUQsGDTfj82ehdX6VvDZfvOhK5ULNfVmwVAGe0=' ,
178
+ } ,
179
+ } ;
160
180
const currentDatetime : string = dateTimeToString (
161
181
epochSecondsToDateTime ( getEpochTimeInSeconds ( ) ) ,
162
182
) ;
@@ -307,6 +327,28 @@ test('testWebhookValidation', async function testWebhookValidation(): Promise<an
307
327
) {
308
328
throw new Error ( 'Assertion failed' ) ;
309
329
}
330
+ if (
331
+ ! (
332
+ ( await computeWebhookSignature (
333
+ bodyWithForwardSlash ,
334
+ headersWithForwardSlash ,
335
+ primaryKey ,
336
+ ) ) == headersWithForwardSlash [ 'box-signature-primary' ]
337
+ )
338
+ ) {
339
+ throw new Error ( 'Assertion failed' ) ;
340
+ }
341
+ if (
342
+ ! (
343
+ ( await computeWebhookSignature (
344
+ bodyWithBackSlash ,
345
+ headersWithBackSlash ,
346
+ primaryKey ,
347
+ ) ) == headersWithBackSlash [ 'box-signature-primary' ]
348
+ )
349
+ ) {
350
+ throw new Error ( 'Assertion failed' ) ;
351
+ }
310
352
if (
311
353
! ( await WebhooksManager . validateMessage (
312
354
body ,
0 commit comments