-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref(core): Do not check baggage validity (#14479)
This PR drops the validation for baggage content. We didn't do this for browser previously, only for node, but it adds bundle size and does not appear too important. I left the trace header validation in for now, we may also drop this but it is smaller and I guess also more important to us...?
- Loading branch information
Showing
2 changed files
with
1 addition
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ import { | |
import { getAsyncContextStrategy } from '../../../src/asyncContext'; | ||
import { freezeDscOnSpan } from '../../../src/tracing/dynamicSamplingContext'; | ||
|
||
import { isValidBaggageString } from '../../../src/utils/traceData'; | ||
import type { TestClientOptions } from '../../mocks/client'; | ||
import { TestClient, getDefaultTestClientOptions } from '../../mocks/client'; | ||
|
||
|
@@ -281,75 +280,3 @@ describe('getTraceData', () => { | |
expect(traceData).toEqual({}); | ||
}); | ||
}); | ||
|
||
describe('isValidBaggageString', () => { | ||
it.each([ | ||
'sentry-environment=production', | ||
'sentry-environment=staging,sentry-public_key=key,sentry-trace_id=abc', | ||
// @ is allowed in values | ||
'[email protected]', | ||
// spaces are allowed around the delimiters | ||
'sentry-environment=staging , sentry-public_key=key ,[email protected]', | ||
'sentry-environment=staging , thirdparty=value ,[email protected]', | ||
// these characters are explicitly allowed for keys in the baggage spec: | ||
"!#$%&'*+-.^_`|~1234567890abcxyzABCXYZ=true", | ||
// special characters in values are fine (except for ",;\ - see other test) | ||
'key=(value)', | ||
'key=[{(value)}]', | ||
'key=some$value', | ||
'key=more#value', | ||
'key=max&value', | ||
'key=max:value', | ||
'key=x=value', | ||
])('returns true if the baggage string is valid (%s)', baggageString => { | ||
expect(isValidBaggageString(baggageString)).toBe(true); | ||
}); | ||
|
||
it.each([ | ||
// baggage spec doesn't permit leading spaces | ||
' sentry-environment=production,sentry-publickey=key,sentry-trace_id=abc', | ||
// no spaces in keys or values | ||
'sentry-public key=key', | ||
'sentry-publickey=my key', | ||
// no delimiters ("(),/:;<=>?@[\]{}") in keys | ||
'asdf(x=value', | ||
'asdf)x=value', | ||
'asdf,x=value', | ||
'asdf/x=value', | ||
'asdf:x=value', | ||
'asdf;x=value', | ||
'asdf<x=value', | ||
'asdf>x=value', | ||
'asdf?x=value', | ||
'asdf@x=value', | ||
'asdf[x=value', | ||
'asdf]x=value', | ||
'asdf\\x=value', | ||
'asdf{x=value', | ||
'asdf}x=value', | ||
// no ,;\" in values | ||
'key=va,lue', | ||
'key=va;lue', | ||
'key=va\\lue', | ||
'key=va"lue"', | ||
// baggage headers can have properties but we currently don't support them | ||
'sentry-environment=production;prop1=foo;prop2=bar,nextkey=value', | ||
// no fishy stuff | ||
'absolutely not a valid baggage string', | ||
'val"/><script>alert("xss")</script>', | ||
'something"/>', | ||
'<script>alert("xss")</script>', | ||
'/>', | ||
'" onblur="alert("xss")', | ||
])('returns false if the baggage string is invalid (%s)', baggageString => { | ||
expect(isValidBaggageString(baggageString)).toBe(false); | ||
}); | ||
|
||
it('returns false if the baggage string is empty', () => { | ||
expect(isValidBaggageString('')).toBe(false); | ||
}); | ||
|
||
it('returns false if the baggage string is empty', () => { | ||
expect(isValidBaggageString(undefined)).toBe(false); | ||
}); | ||
}); |