@@ -13,7 +13,6 @@ import {
1313import { getAsyncContextStrategy } from '../../../src/asyncContext' ;
1414import { freezeDscOnSpan } from '../../../src/tracing/dynamicSamplingContext' ;
1515
16- import { isValidBaggageString } from '../../../src/utils/traceData' ;
1716import type { TestClientOptions } from '../../mocks/client' ;
1817import { TestClient , getDefaultTestClientOptions } from '../../mocks/client' ;
1918
@@ -281,75 +280,3 @@ describe('getTraceData', () => {
281280 expect ( traceData ) . toEqual ( { } ) ;
282281 } ) ;
283282} ) ;
284-
285- describe ( 'isValidBaggageString' , ( ) => {
286- it . each ( [
287- 'sentry-environment=production' ,
288- 'sentry-environment=staging,sentry-public_key=key,sentry-trace_id=abc' ,
289- // @ is allowed in values
290- 'sentry-release=project@1.0.0' ,
291- // spaces are allowed around the delimiters
292- 'sentry-environment=staging , sentry-public_key=key ,sentry-release=myproject@1.0.0' ,
293- 'sentry-environment=staging , thirdparty=value ,sentry-release=myproject@1.0.0' ,
294- // these characters are explicitly allowed for keys in the baggage spec:
295- "!#$%&'*+-.^_`|~1234567890abcxyzABCXYZ=true" ,
296- // special characters in values are fine (except for ",;\ - see other test)
297- 'key=(value)' ,
298- 'key=[{(value)}]' ,
299- 'key=some$value' ,
300- 'key=more#value' ,
301- 'key=max&value' ,
302- 'key=max:value' ,
303- 'key=x=value' ,
304- ] ) ( 'returns true if the baggage string is valid (%s)' , baggageString => {
305- expect ( isValidBaggageString ( baggageString ) ) . toBe ( true ) ;
306- } ) ;
307-
308- it . each ( [
309- // baggage spec doesn't permit leading spaces
310- ' sentry-environment=production,sentry-publickey=key,sentry-trace_id=abc' ,
311- // no spaces in keys or values
312- 'sentry-public key=key' ,
313- 'sentry-publickey=my key' ,
314- // no delimiters ("(),/:;<=>?@[\]{}") in keys
315- 'asdf(x=value' ,
316- 'asdf)x=value' ,
317- 'asdf,x=value' ,
318- 'asdf/x=value' ,
319- 'asdf:x=value' ,
320- 'asdf;x=value' ,
321- 'asdf<x=value' ,
322- 'asdf>x=value' ,
323- 'asdf?x=value' ,
324- 'asdf@x=value' ,
325- 'asdf[x=value' ,
326- 'asdf]x=value' ,
327- 'asdf\\x=value' ,
328- 'asdf{x=value' ,
329- 'asdf}x=value' ,
330- // no ,;\" in values
331- 'key=va,lue' ,
332- 'key=va;lue' ,
333- 'key=va\\lue' ,
334- 'key=va"lue"' ,
335- // baggage headers can have properties but we currently don't support them
336- 'sentry-environment=production;prop1=foo;prop2=bar,nextkey=value' ,
337- // no fishy stuff
338- 'absolutely not a valid baggage string' ,
339- 'val"/><script>alert("xss")</script>' ,
340- 'something"/>' ,
341- '<script>alert("xss")</script>' ,
342- '/>' ,
343- '" onblur="alert("xss")' ,
344- ] ) ( 'returns false if the baggage string is invalid (%s)' , baggageString => {
345- expect ( isValidBaggageString ( baggageString ) ) . toBe ( false ) ;
346- } ) ;
347-
348- it ( 'returns false if the baggage string is empty' , ( ) => {
349- expect ( isValidBaggageString ( '' ) ) . toBe ( false ) ;
350- } ) ;
351-
352- it ( 'returns false if the baggage string is empty' , ( ) => {
353- expect ( isValidBaggageString ( undefined ) ) . toBe ( false ) ;
354- } ) ;
355- } ) ;
0 commit comments