pi-roundtable 0.7.6 → 0.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/kit/diagnostics.ts +33 -9
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,13 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [0.7.7] - 2026-10-03
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- `scrubDiagnostic` takes linear time on a long run of `eyJ-` too: the JWT pattern now starts at the beginning of a run (a JWT glued directly after `-` is no longer masked by that pattern, only as the value of a secret-named field).
|
|
13
|
+
- `scrubDiagnostic` reads a quoted value up to its closing quote, so a secret holding `}`, `]`, blanks, `&`, `,` or `;` is masked whole; `}` and `]` end only an unquoted value. A value an earlier rule already masked is not masked again (no `[redacted]]`).
|
|
14
|
+
|
|
8
15
|
## [0.7.6] - 2026-10-03
|
|
9
16
|
|
|
10
17
|
### Changed
|
package/package.json
CHANGED
package/src/kit/diagnostics.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/*
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* takes time
|
|
2
|
+
* A pattern whose first characters can recur inside the run it then scans (a leading `\b` before a
|
|
3
|
+
* repeatable class, or a literal such as `eyJ` that may appear again after a `-`) restarts at every
|
|
4
|
+
* repeat and takes quadratic time. Those patterns start at the beginning of a run of their own
|
|
5
|
+
* character class through a lookbehind; the others begin with a literal that cannot recur inside
|
|
6
|
+
* what they scan. Scrubbing then takes time linear in the text at any length.
|
|
5
7
|
*/
|
|
6
8
|
|
|
7
9
|
/** Tool text that may name a credential: userinfo in URLs, bearer values, and well-known token shapes. */
|
|
@@ -24,7 +26,10 @@ const CREDENTIALS: [RegExp, string | ((...match: string[]) => string)][] = [
|
|
|
24
26
|
/\b(cookie|set-cookie|x-api-key|x-auth-token|x-access-token)\s*:\s*[^\r\n]+/gi,
|
|
25
27
|
"$1: [redacted]",
|
|
26
28
|
],
|
|
27
|
-
[
|
|
29
|
+
[
|
|
30
|
+
/(?<![A-Za-z0-9_-])eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]*/g,
|
|
31
|
+
"[redacted]",
|
|
32
|
+
],
|
|
28
33
|
[
|
|
29
34
|
/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g,
|
|
30
35
|
"[redacted]",
|
|
@@ -56,7 +61,26 @@ function secretKind(name: string): "secret" | "token" | undefined {
|
|
|
56
61
|
|
|
57
62
|
/** The name and separator of an assignment, query parameter or JSON field; the value is read separately. */
|
|
58
63
|
const ASSIGNMENT = /(?<![a-z0-9_-])([a-z0-9_-]+)(["']?\s*[:=]\s*["']?)/gi;
|
|
59
|
-
|
|
64
|
+
/** An unquoted value ends at a blank, a quote, a separator or a closing bracket. */
|
|
65
|
+
const UNQUOTED = /[^\s"',&;}\]]+/y;
|
|
66
|
+
/** A quoted value runs to its closing quote, whatever it holds. */
|
|
67
|
+
const DOUBLE_QUOTED = /[^"]+/y;
|
|
68
|
+
const SINGLE_QUOTED = /[^']+/y;
|
|
69
|
+
|
|
70
|
+
/** The value that follows a separator ending in `end`, or undefined when there is none. */
|
|
71
|
+
function valueAt(
|
|
72
|
+
text: string,
|
|
73
|
+
end: number,
|
|
74
|
+
separator: string,
|
|
75
|
+
): string | undefined {
|
|
76
|
+
const quote = separator.endsWith('"')
|
|
77
|
+
? DOUBLE_QUOTED
|
|
78
|
+
: separator.endsWith("'")
|
|
79
|
+
? SINGLE_QUOTED
|
|
80
|
+
: UNQUOTED;
|
|
81
|
+
quote.lastIndex = end;
|
|
82
|
+
return quote.exec(text)?.[0];
|
|
83
|
+
}
|
|
60
84
|
|
|
61
85
|
/** Masks the value of every assignment whose name says it is a secret, in any case. */
|
|
62
86
|
function maskAssignments(text: string): string {
|
|
@@ -69,10 +93,10 @@ function maskAssignments(text: string): string {
|
|
|
69
93
|
// The value is read only for a secret name, so ordinary text costs nothing more to pass.
|
|
70
94
|
const kind = secretKind(match[1] ?? "");
|
|
71
95
|
if (!kind) continue;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (value === undefined || (
|
|
75
|
-
|
|
96
|
+
const value = valueAt(text, end, match[2] ?? "");
|
|
97
|
+
// An earlier rule already masked this value.
|
|
98
|
+
if (value === undefined || value.startsWith("[redacted")) continue;
|
|
99
|
+
if (kind === "token" && /^[0-9]+$/.test(value)) continue;
|
|
76
100
|
out += `${text.slice(cursor, end)}[redacted]`;
|
|
77
101
|
cursor = end + value.length;
|
|
78
102
|
}
|