spot: sanitize url query params
This commit is contained in:
parent
0f65ff856a
commit
9a9f850697
1 changed files with 18 additions and 1 deletions
|
|
@ -130,6 +130,23 @@ function obscureSensitiveData(obj: Record<string, any> | any[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function tryFilterUrl(url: string) {
|
||||||
|
if (!url) return ''
|
||||||
|
try {
|
||||||
|
const urlObj = new URL(url);
|
||||||
|
if (urlObj.searchParams) {
|
||||||
|
for (const key of urlObj.searchParams.keys()) {
|
||||||
|
if (sensitiveParams.has(key.toLowerCase())) {
|
||||||
|
urlObj.searchParams.set(key, "******");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return urlObj.toString();
|
||||||
|
} catch (e) {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function createSpotNetworkRequest(
|
export function createSpotNetworkRequest(
|
||||||
trackedRequest: TrackedRequest,
|
trackedRequest: TrackedRequest,
|
||||||
trackedTab?: number,
|
trackedTab?: number,
|
||||||
|
|
@ -185,7 +202,7 @@ export function createSpotNetworkRequest(
|
||||||
time: trackedRequest.timeStamp,
|
time: trackedRequest.timeStamp,
|
||||||
statusCode: status,
|
statusCode: status,
|
||||||
error: trackedRequest.error,
|
error: trackedRequest.error,
|
||||||
url: trackedRequest.url,
|
url: tryFilterUrl(trackedRequest.url),
|
||||||
fromCache: trackedRequest.fromCache || false,
|
fromCache: trackedRequest.fromCache || false,
|
||||||
encodedBodySize: reqSize,
|
encodedBodySize: reqSize,
|
||||||
responseBodySize: trackedRequest.responseSize,
|
responseBodySize: trackedRequest.responseSize,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue