Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ All notable changes to `sessionpipe-gui`. The format follows

## [Unreleased]

### Fixed

- Search's redaction fast path recognizes the cookie, authorization and signed-link triggers added in sessionpipe-core 0.18–0.19.

## [0.8.19] - 2026-12-04

### Added
Expand Down
37 changes: 36 additions & 1 deletion server/search/sources/redact.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,27 @@ const SECRETS = [
'apiKey: "Zq81mLkP0vXy"',
"client_secret=Hj28Ks91Lq",
];
/** One sample of every text rule core 0.18 added under the same id (cookies, named values,
* a link's query key). Core 0.17.0 leaves them as they are, so for these only the parity
* with core is asserted: it is what fails when a core bump adds a rule MAYBE_SECRET lacks. */
const LATER = [
`Cookie: sessionid=${R(16)}`,
`curl -H 'Set-Cookie: sid=${R(16)}; Path=/; HttpOnly'`,
`HTTP_COOKIE=sid=${R(16)}`,
`curl --cookie "sid=${R(16)}" https-less.example`,
`curl -b 'sid=${R(16)}' example.com/a`,
`added cookie sid=${R(16)}`,
`{"name": "Authorization", "value": "${R(24)}"}`,
`{"name": "sid", "value": "${R(20)}", "domain": ".example.com", "path": "/"}`,
`page.addCookies([{ name: "sid", value: "${R(20)}" }])`,
`GET /x?sig=${R(20)} HTTP/1.1`,
`fetch('/dl?X-Amz-Signature=${R(24, HEX)}')`,
`/o?a=1&x-goog-signature=${R(24, HEX)}`,
`/m?k=${R(20)}`,
`/m?signature=${R(20)}`,
`<a href="/dl?a=1&amp;sig=${R(20)}">`,
`{"coo\u212aie": {"name": "sid", "value": "${R(20)}"}}`,
];
const WORDS =
"the retry webhook delivery fix build test deploy src/a.ts --flag x=1 key: value TOKEN tokenizer passes :// https://example.com".split(
" ",
Expand All @@ -69,6 +90,19 @@ describe("redaction fast path", () => {
const src = readFileSync(new URL("../../../node_modules/sessionpipe-core/dist/index.js", import.meta.url), "utf8");
const block = /var TOKEN_PATTERNS = \[([\s\S]*?)\n\];/.exec(src)?.[1] ?? "";
expect(block.split("\n").filter((l) => /^\s*\/.*\/g,?\s*$/.test(l))).toHaveLength(34);
// Core adds rules under the same id (0.18 did: cookies, named values, query keys), so the
// fast path is checked against each core release: a bump must add its rules' samples
// to LATER and its version here.
const pkg = new URL("../../../node_modules/sessionpipe-core/package.json", import.meta.url);
expect(["0.17.0", "0.19.1"]).toContain(JSON.parse(readFileSync(pkg, "utf8")).version);
});

it("every rule core added under the same id is redacted exactly as core does", () => {
for (const s of LATER) {
for (const t of [s, `see ${s} here`, `${s}\n`, s.toUpperCase(), s.toLowerCase()]) {
expect(redact(t)).toBe(redactSecrets(t));
}
}
});

it("every rule's sample is redacted exactly as core does", () => {
Expand All @@ -92,8 +126,9 @@ describe("redaction fast path", () => {
const n = 1 + rnd(12);
for (let k = 0; k < n; k++) {
const r = rnd(10);
const pool = rnd(2) ? SECRETS : LATER;
parts.push(
r === 0 ? (SECRETS[rnd(SECRETS.length)] ?? "") : r === 1 ? R(5 + rnd(50)) : (WORDS[rnd(WORDS.length)] ?? ""),
r === 0 ? (pool[rnd(pool.length)] ?? "") : r === 1 ? R(5 + rnd(50)) : (WORDS[rnd(WORDS.length)] ?? ""),
);
}
const t = parts.join(rnd(3) ? " " : "");
Expand Down
22 changes: 16 additions & 6 deletions server/search/sources/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,28 @@ export function cut(text: string, max: number): string {
/**
* A necessary condition for `redactSecrets` (secrets@1) to change a text: every rule needs a
* trigger word (`pass…`, `pwd`, `secret`, `…key`, `token`, `cred…`, `Bearer`/`Basic`), a URL
* (`://`), or one of its token prefixes. A text with none of them comes back unchanged, so
* it skips the ~35 regex passes (a quarter of the build's CPU on dense history). Bound to the
* ruleset id: when core ships another ruleset, every text takes the full path again until
* this list is checked against it (redact.test.ts pins the parity).
* (`://`), or one of its token prefixes. Since sessionpipe-core 0.18 the same id also cuts a
* cookie (`Cookie:`, `Set-Cookie`, `--cookie`, curl's `-b '…'`), a value named `Authorization`
* or written beside a cookie's attributes, and a link's `?sig=`/`&X-Amz-Signature=`-style key
* (also written `&amp;sig=`). Core lower-cases names, and the Kelvin sign K (U+212A) lower-cases
* to `k`, so a text holding it takes the full path too.
* A text with none of them comes back unchanged, so it skips the ~35 regex passes (a quarter
* of the build's CPU on dense history). Bound to the ruleset id: when core ships another
* ruleset, every text takes the full path again until this list is checked against it
* (redact.test.ts pins the parity and the core versions it was checked on).
*/
const MAYBE_SECRET =
/pass|pwd|secret|key|token|cred|bearer|basic|:\/\/|AKIA|ASIA|ABIA|ACCA|gh[pousr]_|github_pat_|glpat-|xox[abposre]-|sk-|[sr]k_(?:live|test)_|whsec_|AIza|ya29\.|1\/\/0|GOCSPX-|xai-|gsk_|pplx-|hf_|pcsk_|npm_|pypi-|SG\.|shp(?:at|ss|ca|pa)_|dop_v1_|lin_(?:api|oauth)_|ntn_|sbp_|figd_|dp\.(?:pt|st|sa|ct)\.|grn_|ss_|:AA|eyJ/i;
/pass|pwd|secret|key|token|cred|bearer|basic|cookie|authorization|-b\s|(?:[?&]|&amp;)(?:k|sig|signature|x-amz-signature|x-goog-signature)=|\u212a|:\/\/|AKIA|ASIA|ABIA|ACCA|gh[pousr]_|github_pat_|glpat-|xox[abposre]-|sk-|[sr]k_(?:live|test)_|whsec_|AIza|ya29\.|1\/\/0|GOCSPX-|xai-|gsk_|pplx-|hf_|pcsk_|npm_|pypi-|SG\.|shp(?:at|ss|ca|pa)_|dop_v1_|lin_(?:api|oauth)_|ntn_|sbp_|figd_|dp\.(?:pt|st|sa|ct)\.|grn_|ss_|:AA|eyJ/i;
/** A cookie written as an object with no cookie word in sight: a `name` and a `value` beside
* two of its attributes (`{"name":"sid","value":"…","domain":"…","path":"/"}`). */
const COOKIE_MARK = /domain|path|expires|httponly|secure|samesite/i;
const FAST = RULESET_SECRETS === "secrets@1";

/** sessionpipe-core's redactSecrets, skipped only when it provably changes nothing. */
export function redact(text: string): string {
return FAST && !MAYBE_SECRET.test(text) ? text : redactSecrets(text);
return FAST && !MAYBE_SECRET.test(text) && !(/value/i.test(text) && /name/i.test(text) && COOKIE_MARK.test(text))
? text
: redactSecrets(text);
}

/** Redacted and cut: the last step for every emitted text. Redaction runs before the cut
Expand Down
Loading