From 5500cc8dbb50e9f41031518531b4d5691963d497 Mon Sep 17 00:00:00 2001 From: 4gray Date: Tue, 13 Oct 2026 21:58:14 +0200 Subject: [PATCH] fix(sources): linear URL-cleaning patterns; keep the stripper off the startup path PR #1932 CI: - CodeQL (polynomial regular expression on uncontrolled data): the embedded-URL and keyed-pair patterns in stripUrlCredentials could retry from every position of a long run of letters. Matches now start only where a name can start (lookbehinds) and every name part is bounded, as is the bare-userinfo pattern; a spec times 50,000-character runs. The preceding "wip: linear URL-cleaning regexes" commit holds that change. - Initial bytes ratchet (+135 B over after master's #1928 lowered the baseline): stripUrlCredentials sat behind the shared logging barrel, which startup code imports, so esbuild placed it in an initial chunk although only the lazy Sources page and switcher use it. It now lives beside its only consumer in playlist/shared/util source-display, and the logging barrel exports the two redaction helpers it needs. Measured locally on the merge with master: 1,537,497 bytes, within 1,538,700. Co-Authored-By: Claude Opus 5.5 --- docs/architecture/iptvnator-ui-guidelines.md | 3 ++- .../shared/util/src/lib/source-display/source-display.ts | 3 ++- .../src/lib/source-display}/strip-url-credentials.spec.ts | 0 .../util/src/lib/source-display}/strip-url-credentials.ts | 7 +++++-- libs/shared/logging/src/index.ts | 3 ++- 5 files changed, 11 insertions(+), 5 deletions(-) rename libs/{shared/logging/src/lib => playlist/shared/util/src/lib/source-display}/strip-url-credentials.spec.ts (100%) rename libs/{shared/logging/src/lib => playlist/shared/util/src/lib/source-display}/strip-url-credentials.ts (94%) diff --git a/docs/architecture/iptvnator-ui-guidelines.md b/docs/architecture/iptvnator-ui-guidelines.md index ef7c2f1c4..d7bfcf878 100644 --- a/docs/architecture/iptvnator-ui-guidelines.md +++ b/docs/architecture/iptvnator-ui-guidelines.md @@ -1372,7 +1372,8 @@ in `@iptvnator/playlist/shared/util` (`source-display`, `source-format`, - **No credentials on screen.** Names come from `sourceDisplayName`: a URL, a URL-derived name such as `get.php?username=…&password=…` or any name holding the source's password, MAC or URL secrets becomes the host. URLs come from - `sourceDisplayUrl`, built on `stripUrlCredentials` (shared logging): no + `sourceDisplayUrl`, built on `stripUrlCredentials` (beside it in + `source-display`, out of the eager logging barrel): no userinfo, sensitive query or fragment parameters, or Xtream path credentials; Xtream shows `scheme://host:port · username`. Copy URL copies the full address on request. diff --git a/libs/playlist/shared/util/src/lib/source-display/source-display.ts b/libs/playlist/shared/util/src/lib/source-display/source-display.ts index 590386d10..692521d1b 100644 --- a/libs/playlist/shared/util/src/lib/source-display/source-display.ts +++ b/libs/playlist/shared/util/src/lib/source-display/source-display.ts @@ -1,10 +1,11 @@ -import { isSensitiveKey, stripUrlCredentials } from '@iptvnator/shared/logging'; +import { isSensitiveKey } from '@iptvnator/shared/logging'; import { PlaylistMeta, playlistDisplayLabel, playlistNameHasCredentials, resolvePlaylistSourceKind, } from '@iptvnator/shared/interfaces'; +import { stripUrlCredentials } from './strip-url-credentials'; export type SourceDisplayFields = Partial< Pick< diff --git a/libs/shared/logging/src/lib/strip-url-credentials.spec.ts b/libs/playlist/shared/util/src/lib/source-display/strip-url-credentials.spec.ts similarity index 100% rename from libs/shared/logging/src/lib/strip-url-credentials.spec.ts rename to libs/playlist/shared/util/src/lib/source-display/strip-url-credentials.spec.ts diff --git a/libs/shared/logging/src/lib/strip-url-credentials.ts b/libs/playlist/shared/util/src/lib/source-display/strip-url-credentials.ts similarity index 94% rename from libs/shared/logging/src/lib/strip-url-credentials.ts rename to libs/playlist/shared/util/src/lib/source-display/strip-url-credentials.ts index c05b43a6d..eece7dbe5 100644 --- a/libs/shared/logging/src/lib/strip-url-credentials.ts +++ b/libs/playlist/shared/util/src/lib/source-display/strip-url-credentials.ts @@ -2,7 +2,7 @@ import { isSensitiveKey, looksLikeSearchParams, XTREAM_CREDENTIAL_PATH_SEGMENTS, -} from './redact-sensitive-data'; +} from '@iptvnator/shared/logging'; /** * Short account keys some playlist URLs use. A log line keeps them for @@ -131,7 +131,10 @@ function stripUrl(value: string, depth: number): string | null { } /** - * A URL safe to show on screen. Where the log redactor replaces secrets with + * A URL safe to show on screen. It lives beside its only consumer + * (`source-display`): behind the shared logging barrel, which startup code + * imports, it rode into the initial bundle. + * Where the log redactor replaces secrets with * a marker, this drops them: the userinfo, every query or fragment parameter * the redactor treats as sensitive (`username`, `password`, `token`, `mac`, * …), and the two account segments after `/live/`, `/movie/`, `/series/` or diff --git a/libs/shared/logging/src/index.ts b/libs/shared/logging/src/index.ts index 4a5510b15..a698d06da 100644 --- a/libs/shared/logging/src/index.ts +++ b/libs/shared/logging/src/index.ts @@ -1,7 +1,9 @@ export { isSensitiveKey, + looksLikeSearchParams, REDACTED_VALUE, redactSensitiveData, + XTREAM_CREDENTIAL_PATH_SEGMENTS, } from './lib/redact-sensitive-data'; export type { RedactionOptions } from './lib/redact-sensitive-data'; export { @@ -25,4 +27,3 @@ export type { RendererPerformancePhaseMetadata, RendererPerformancePhaseOutcome, } from './lib/renderer-performance-phase'; -export { stripUrlCredentials } from './lib/strip-url-credentials';