Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -11,12 +11,15 @@
*
* Scrubbing rules (see {@link redactSpanAttributes}):
* - `http.url`, `http.target` and the OTel v1.20+ aliases `url.full`,
* `url.path` get their query-string replaced with `?[scrubbed]`.
* `url.path` get their query-string replaced with `?[scrubbed]`; fragments
* are removed and `url.query` is redacted wholesale. Customer-portal
* capability segments are redacted in URL attributes and span names.
* - HTTP request/response headers are filtered through {@link HEADER_ALLOWLIST}.
* Anything outside the allowlist (notably `authorization`, `cookie`,
* `set-cookie`, `x-api-key`) is dropped.
* - `db.statement` literal-string parameters (`'...'` and `"..."`) are
* rewritten to `?` (defense-in-depth — Prisma already parametrises).
* - `db.statement` and `db.query.text` literal-string parameters (`'...'`
* and `"..."`) are rewritten to `?` (defense-in-depth — Prisma already
* parametrises).
* - `messaging.message_payload` is dropped entirely; the payload-size
* attribute (if present) is preserved.
*
@@ -34,6 +37,7 @@
* a runtime dependency on `@opentelemetry/sdk-trace-base`.
*/
export interface PiiScrubableSpan {
name?: string | undefined;
attributes?: Record<string, unknown> | undefined;
}
@@ -57,14 +61,17 @@ export const HEADER_ALLOWLIST: ReadonlySet<string> = new Set(
"accept-language",
"accept-encoding",
"x-request-id",
"x-forwarded-for",
"referer",
].map((name) => name.toLowerCase()),
);
const QUERY_STRING_PLACEHOLDER = "?[scrubbed]";
const URL_LIKE_ATTRIBUTES = ["http.url", "http.target", "url.full", "url.path", "url.query"] as const;
const URL_LIKE_ATTRIBUTES = ["http.url", "http.target", "http.route", "url.full", "url.path", "url.query"] as const;
const PORTAL_CAPABILITY_ROUTE_PATTERN =
/((?:\/__portal)?\/[a-z0-9][a-z0-9-]{1,62}\/(?:login\/magic|setup|verify-email|reset-password)\/)[A-Za-z0-9_-]+/giu;
const DB_STATEMENT_ATTRIBUTES = ["db.statement", "db.query.text"] as const;
const DROP_ATTRIBUTES = ["messaging.message_payload"] as const;
@@ -72,12 +79,21 @@ const HEADER_PREFIXES = ["http.request.header.", "http.response.header."] as con
/**
* Strips the query-string from a URL-like attribute, replacing it with
* `?[scrubbed]`. Returns the input unchanged when no `?` is present.
* `?[scrubbed]`, and redacts customer-portal capability path segments.
*/
export function scrubUrlQuery(value: string): string {
const queryIndex = value.indexOf("?");
if (queryIndex < 0) return value;
return `${value.slice(0, queryIndex)}${QUERY_STRING_PLACEHOLDER}`;
const fragmentIndex = value.indexOf("#");
if (queryIndex < 0 && fragmentIndex < 0) return redactPortalCapabilityTokens(value);
if (queryIndex >= 0 && (fragmentIndex < 0 || queryIndex < fragmentIndex)) {
return `${redactPortalCapabilityTokens(value.slice(0, queryIndex))}${QUERY_STRING_PLACEHOLDER}`;
}
return redactPortalCapabilityTokens(value.slice(0, fragmentIndex));
}
/** Redacts customer-portal one-time credentials from span/transaction names. */
export function scrubSpanName(value: string): string {
return scrubUrlQuery(value);
}
/**
@@ -148,13 +164,13 @@ export function redactSpanAttributes(attributes: Record<string, unknown> | undef
if ((URL_LIKE_ATTRIBUTES as readonly string[]).includes(key)) {
const value = attributes[key];
if (typeof value === "string") {
attributes[key] = scrubUrlQuery(value);
attributes[key] = key === "url.query" ? (value ? "[scrubbed]" : "") : scrubUrlQuery(value);
}
continue;
}
// Scrub SQL literals from db.statement.
if (key === "db.statement") {
// Scrub SQL literals from current and legacy database statement fields.
if ((DB_STATEMENT_ATTRIBUTES as readonly string[]).includes(key)) {
const value = attributes[key];
if (typeof value === "string") {
attributes[key] = scrubDbStatement(value);
@@ -185,12 +201,19 @@ export class PIISpanProcessor implements DelegateSpanProcessor {
}
onEnd(span: PiiScrubableSpan): void {
if (!redactSpanName(span)) {
return;
}
try {
redactSpanAttributes(span.attributes);
} catch {
// Scrubber failures must never block the exporter chain; the span is
// forwarded as-is on the assumption the exporter will reject malformed
// payloads at its own layer.
// Telemetry is optional; privacy is not. Replace the entire attribute bag
// on scrubber failure, or drop the span when even that is impossible.
try {
span.attributes = {};
} catch {
return;
}
}
this.delegate.onEnd(span);
}
@@ -203,3 +226,20 @@ export class PIISpanProcessor implements DelegateSpanProcessor {
return this.delegate.shutdown();
}
}
function redactPortalCapabilityTokens(value: string): string {
return value.replace(PORTAL_CAPABILITY_ROUTE_PATTERN, "$1redacted");
}
function redactSpanName(span: PiiScrubableSpan): boolean {
if (typeof span.name !== "string") return true;
const sanitized = scrubSpanName(span.name);
if (sanitized === span.name) return true;
try {
span.name = sanitized;
return span.name === sanitized;
} catch {
// A credential-bearing immutable span name cannot be exported safely.
return false;
}
}