@pinta-ai/mcp-logger 0.4.1 → 0.4.2-dev.1010
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/dist/cli/index.js +1 -1
- package/node_modules/@pinta-ai/core/README.md +180 -0
- package/node_modules/@pinta-ai/core/dist/atomic-write.d.ts +9 -0
- package/node_modules/@pinta-ai/core/dist/atomic-write.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/atomic-write.js +20 -0
- package/node_modules/@pinta-ai/core/dist/atomic-write.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/credential-semantics.d.ts +20 -0
- package/node_modules/@pinta-ai/core/dist/credential-semantics.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/credential-semantics.js +156 -0
- package/node_modules/@pinta-ai/core/dist/credential-semantics.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/env-file.d.ts +17 -0
- package/node_modules/@pinta-ai/core/dist/env-file.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/env-file.js +81 -0
- package/node_modules/@pinta-ai/core/dist/env-file.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/export-mask.d.ts +26 -0
- package/node_modules/@pinta-ai/core/dist/export-mask.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/export-mask.js +202 -0
- package/node_modules/@pinta-ai/core/dist/export-mask.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/guard.d.ts +196 -0
- package/node_modules/@pinta-ai/core/dist/guard.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/guard.js +275 -0
- package/node_modules/@pinta-ai/core/dist/guard.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/index.d.ts +23 -0
- package/node_modules/@pinta-ai/core/dist/index.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/index.js +85 -0
- package/node_modules/@pinta-ai/core/dist/index.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/json-text.d.ts +45 -0
- package/node_modules/@pinta-ai/core/dist/json-text.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/json-text.js +116 -0
- package/node_modules/@pinta-ai/core/dist/json-text.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/lifecycle.d.ts +143 -0
- package/node_modules/@pinta-ai/core/dist/lifecycle.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/lifecycle.js +20 -0
- package/node_modules/@pinta-ai/core/dist/lifecycle.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/matches.d.ts +24 -0
- package/node_modules/@pinta-ai/core/dist/matches.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/matches.js +39 -0
- package/node_modules/@pinta-ai/core/dist/matches.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/mysql-password.d.ts +15 -0
- package/node_modules/@pinta-ai/core/dist/mysql-password.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/mysql-password.js +375 -0
- package/node_modules/@pinta-ai/core/dist/mysql-password.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/otlp-types.d.ts +41 -0
- package/node_modules/@pinta-ai/core/dist/otlp-types.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/otlp-types.js +7 -0
- package/node_modules/@pinta-ai/core/dist/otlp-types.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/otlp.d.ts +142 -0
- package/node_modules/@pinta-ai/core/dist/otlp.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/otlp.js +638 -0
- package/node_modules/@pinta-ai/core/dist/otlp.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/output-denial.d.ts +69 -0
- package/node_modules/@pinta-ai/core/dist/output-denial.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/output-denial.js +105 -0
- package/node_modules/@pinta-ai/core/dist/output-denial.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/redact.d.ts +65 -0
- package/node_modules/@pinta-ai/core/dist/redact.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/redact.js +193 -0
- package/node_modules/@pinta-ai/core/dist/redact.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/retry-queue.d.ts +47 -0
- package/node_modules/@pinta-ai/core/dist/retry-queue.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/retry-queue.js +177 -0
- package/node_modules/@pinta-ai/core/dist/retry-queue.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/secret-shapes.d.ts +47 -0
- package/node_modules/@pinta-ai/core/dist/secret-shapes.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/secret-shapes.js +377 -0
- package/node_modules/@pinta-ai/core/dist/secret-shapes.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/session-trace.d.ts +50 -0
- package/node_modules/@pinta-ai/core/dist/session-trace.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/session-trace.js +103 -0
- package/node_modules/@pinta-ai/core/dist/session-trace.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/shape-rules.d.ts +117 -0
- package/node_modules/@pinta-ai/core/dist/shape-rules.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/shape-rules.js +592 -0
- package/node_modules/@pinta-ai/core/dist/shape-rules.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/trace.d.ts +17 -0
- package/node_modules/@pinta-ai/core/dist/trace.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/trace.js +78 -0
- package/node_modules/@pinta-ai/core/dist/trace.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/transport.d.ts +75 -0
- package/node_modules/@pinta-ai/core/dist/transport.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/transport.js +260 -0
- package/node_modules/@pinta-ai/core/dist/transport.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/value-copies.d.ts +46 -0
- package/node_modules/@pinta-ai/core/dist/value-copies.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/value-copies.js +279 -0
- package/node_modules/@pinta-ai/core/dist/value-copies.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/value-masking.d.ts +22 -0
- package/node_modules/@pinta-ai/core/dist/value-masking.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/value-masking.js +243 -0
- package/node_modules/@pinta-ai/core/dist/value-masking.js.map +1 -0
- package/node_modules/@pinta-ai/core/package.json +50 -0
- package/package.json +3 -1
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.MemoryRetryQueue = exports.DiskRetryQueue = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const atomic_write_js_1 = require("./atomic-write.js");
|
|
10
|
+
const MAX_ENTRIES = 1000;
|
|
11
|
+
const LOCK_TIMEOUT_MS = 50;
|
|
12
|
+
const LOCK_POLL_MS = 5;
|
|
13
|
+
/**
|
|
14
|
+
* Disk-backed retry queue used by the short-lived hook adapters
|
|
15
|
+
* (cc/codex/copilot/gemini). Each hook process is spawned per event, so failed
|
|
16
|
+
* OTLP payloads must persist to a JSONL file and be flushed by a later hook.
|
|
17
|
+
*
|
|
18
|
+
* `logPrefix` is the adapter tag printed on stderr diagnostics, e.g. "pinta-cc".
|
|
19
|
+
*/
|
|
20
|
+
class DiskRetryQueue {
|
|
21
|
+
filePath;
|
|
22
|
+
lockPath;
|
|
23
|
+
logPrefix;
|
|
24
|
+
constructor(pluginData, logPrefix) {
|
|
25
|
+
this.filePath = path_1.default.join(pluginData, "failed-spans.jsonl");
|
|
26
|
+
this.lockPath = this.filePath + ".lock";
|
|
27
|
+
this.logPrefix = logPrefix;
|
|
28
|
+
}
|
|
29
|
+
/** Append a single payload. Best-effort: any IO error is swallowed (logged to stderr). */
|
|
30
|
+
enqueue(payload) {
|
|
31
|
+
try {
|
|
32
|
+
fs_1.default.mkdirSync(path_1.default.dirname(this.filePath), { recursive: true });
|
|
33
|
+
const line = JSON.stringify({ savedAt: new Date().toISOString(), payload }) + "\n";
|
|
34
|
+
fs_1.default.appendFileSync(this.filePath, line);
|
|
35
|
+
this.trim();
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
process.stderr.write(`[${this.logPrefix}] retry-queue enqueue failed: ${err}\n`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Read all entries oldest-first. Returns [] if the file does not exist or is unreadable.
|
|
43
|
+
* Does NOT delete the file — callers handle persistence via `rewrite`.
|
|
44
|
+
*/
|
|
45
|
+
readAll() {
|
|
46
|
+
try {
|
|
47
|
+
const raw = fs_1.default.readFileSync(this.filePath, "utf-8");
|
|
48
|
+
const out = [];
|
|
49
|
+
for (const line of raw.split("\n")) {
|
|
50
|
+
if (!line.trim())
|
|
51
|
+
continue;
|
|
52
|
+
try {
|
|
53
|
+
const parsed = JSON.parse(line);
|
|
54
|
+
// Shape-validate: a truncated/corrupt line may parse as valid JSON
|
|
55
|
+
// (e.g. `null`, `123`, `{}`) yet lack `payload.resourceSpans`, which
|
|
56
|
+
// would later make `mergeBatch` throw `undefined is not iterable`.
|
|
57
|
+
// Skip anything that is not a well-formed QueueEntry.
|
|
58
|
+
if (Array.isArray(parsed?.payload?.resourceSpans)) {
|
|
59
|
+
out.push(parsed);
|
|
60
|
+
}
|
|
61
|
+
// else: skip shape-invalid line
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// skip malformed line
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/** Replace the queue with the given entries (or delete the file when empty). */
|
|
74
|
+
rewrite(entries) {
|
|
75
|
+
try {
|
|
76
|
+
if (entries.length === 0) {
|
|
77
|
+
if (fs_1.default.existsSync(this.filePath))
|
|
78
|
+
fs_1.default.unlinkSync(this.filePath);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
fs_1.default.mkdirSync(path_1.default.dirname(this.filePath), { recursive: true });
|
|
82
|
+
(0, atomic_write_js_1.atomicWriteFileSync)(this.filePath, entries.map((e) => JSON.stringify(e)).join("\n") + "\n");
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
process.stderr.write(`[${this.logPrefix}] retry-queue rewrite failed: ${err}\n`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Try to acquire the lock for ~LOCK_TIMEOUT_MS. Returns true on success.
|
|
90
|
+
* Caller MUST call `release()` if true is returned.
|
|
91
|
+
*/
|
|
92
|
+
tryAcquireLock() {
|
|
93
|
+
const start = Date.now();
|
|
94
|
+
// Never throw: an unwritable/read-only FS (EACCES/ENOSPC/EROFS) here must
|
|
95
|
+
// degrade to "lock not acquired", not propagate out of flush().
|
|
96
|
+
try {
|
|
97
|
+
fs_1.default.mkdirSync(path_1.default.dirname(this.lockPath), { recursive: true });
|
|
98
|
+
}
|
|
99
|
+
catch (err) {
|
|
100
|
+
process.stderr.write(`[${this.logPrefix}] retry-queue lock mkdir failed: ${err}\n`);
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
while (Date.now() - start < LOCK_TIMEOUT_MS) {
|
|
104
|
+
try {
|
|
105
|
+
const fd = fs_1.default.openSync(this.lockPath, "wx");
|
|
106
|
+
fs_1.default.writeSync(fd, String(process.pid));
|
|
107
|
+
fs_1.default.closeSync(fd);
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
if (err?.code !== "EEXIST") {
|
|
112
|
+
process.stderr.write(`[${this.logPrefix}] retry-queue lock open failed: ${err}\n`);
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
// Stale lock detection: if mtime is older than 30s, drop it.
|
|
116
|
+
try {
|
|
117
|
+
const st = fs_1.default.statSync(this.lockPath);
|
|
118
|
+
if (Date.now() - st.mtimeMs > 30_000) {
|
|
119
|
+
fs_1.default.unlinkSync(this.lockPath);
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
/* ignore */
|
|
125
|
+
}
|
|
126
|
+
const wait = LOCK_POLL_MS;
|
|
127
|
+
const end = Date.now() + wait;
|
|
128
|
+
while (Date.now() < end) {
|
|
129
|
+
/* spin briefly; sync only because hooks are short-lived */
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
release() {
|
|
136
|
+
try {
|
|
137
|
+
fs_1.default.unlinkSync(this.lockPath);
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
/* already gone */
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
trim() {
|
|
144
|
+
const entries = this.readAll();
|
|
145
|
+
if (entries.length <= MAX_ENTRIES)
|
|
146
|
+
return;
|
|
147
|
+
const drop = entries.length - MAX_ENTRIES;
|
|
148
|
+
process.stderr.write(`[${this.logPrefix}] retry-queue full, dropping ${drop} oldest entries\n`);
|
|
149
|
+
this.rewrite(entries.slice(drop));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
exports.DiskRetryQueue = DiskRetryQueue;
|
|
153
|
+
/**
|
|
154
|
+
* In-memory retry buffer for the long-lived opencode plugin. The plugin is a
|
|
155
|
+
* long-lived in-process module, so failed OTLP payloads are buffered in memory
|
|
156
|
+
* and flushed on the next event. Oldest entries are dropped past the cap.
|
|
157
|
+
*/
|
|
158
|
+
class MemoryRetryQueue {
|
|
159
|
+
entries = [];
|
|
160
|
+
enqueue(payload) {
|
|
161
|
+
this.entries.push(payload);
|
|
162
|
+
if (this.entries.length > MAX_ENTRIES) {
|
|
163
|
+
this.entries.splice(0, this.entries.length - MAX_ENTRIES);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/** Remove and return all buffered payloads. */
|
|
167
|
+
drain() {
|
|
168
|
+
const out = this.entries;
|
|
169
|
+
this.entries = [];
|
|
170
|
+
return out;
|
|
171
|
+
}
|
|
172
|
+
get size() {
|
|
173
|
+
return this.entries.length;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
exports.MemoryRetryQueue = MemoryRetryQueue;
|
|
177
|
+
//# sourceMappingURL=retry-queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry-queue.js","sourceRoot":"","sources":["../src/retry-queue.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAExB,uDAAwD;AAExD,MAAM,WAAW,GAAG,IAAI,CAAC;AACzB,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,YAAY,GAAG,CAAC,CAAC;AAOvB;;;;;;GAMG;AACH,MAAa,cAAc;IACjB,QAAQ,CAAS;IACjB,QAAQ,CAAS;IACjB,SAAS,CAAS;IAE1B,YAAY,UAAkB,EAAE,SAAiB;QAC/C,IAAI,CAAC,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,oBAAoB,CAAC,CAAC;QAC5D,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,0FAA0F;IAC1F,OAAO,CAAC,OAAoB;QAC1B,IAAI,CAAC;YACH,YAAE,CAAC,SAAS,CAAC,cAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC/D,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,IAAI,IAAI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,EAAE,CAAC;QAC/B,IAAI,OAAO,CAAC,MAAM,IAAI,WAAW;YAAE,OAAO;QAC1C,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,WAAW,CAAC;QAC1C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,SAAS,gCAAgC,IAAI,mBAAmB,CAAC,CAAC;QAChG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IACpC,CAAC;CACF;AA/HD,wCA+HC;AAED;;;;GAIG;AACH,MAAa,gBAAgB;IACnB,OAAO,GAAkB,EAAE,CAAC;IAEpC,OAAO,CAAC,OAAoB;QAC1B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3B,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,WAAW,EAAE,CAAC;YACtC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,WAAW,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,+CAA+C;IAC/C,KAAK;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,OAAO,GAAG,CAAC;IACb,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;CACF;AApBD,4CAoBC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Three shapes of secret that the single-regex patterns in `redact.ts` cannot
|
|
3
|
+
* read (PTA-735), and only these three:
|
|
4
|
+
*
|
|
5
|
+
* 1. a value inside quotes: `--password="a b"`, `DB_PASSWORD='x'`, `password: "x"`
|
|
6
|
+
* 2. a value on the line after its key: `Authorization:\n <value>`,
|
|
7
|
+
* `api_key: |\n <value>`, `- name: DB_PASSWORD\n value: <value>`
|
|
8
|
+
* 3. a value after a shell line continuation: `--password \<newline> <value>`,
|
|
9
|
+
* `DB_PASSWORD=part1\<newline>part2`
|
|
10
|
+
*
|
|
11
|
+
* A bare (unquoted) value on the same line as its key is not one of them: the
|
|
12
|
+
* patterns of `redact.ts` read those, and a wider net would take command words
|
|
13
|
+
* and prose for values.
|
|
14
|
+
*
|
|
15
|
+
* A regex that reaches across lines, quotes and continuations either
|
|
16
|
+
* backtracks without bound on hostile input or reads past the value, so this is
|
|
17
|
+
* a scanner: a global regex finds the key, then plain code reads the value
|
|
18
|
+
* forward over a bounded stretch. The work per key is bounded (a value is
|
|
19
|
+
* first read only as far as `BARE_PROBE` characters to decide whether it is a
|
|
20
|
+
* credential, and a value that is refused is never read to its end), and
|
|
21
|
+
* scanning resumes after each value taken, so the work is linear in the input
|
|
22
|
+
* however many keys it holds and whatever follows them.
|
|
23
|
+
*
|
|
24
|
+
* A value found is kept only where it is a value (`ShapeText.evalShape`, design
|
|
25
|
+
* contract 4 ①-④): the shell would not run it, the text around it agrees.
|
|
26
|
+
*
|
|
27
|
+
* It returns the range of the VALUE only (never the key, the quotes or the
|
|
28
|
+
* separator), in the text it was given. Callers that scan decoded JSON strings
|
|
29
|
+
* map the range back to the original text.
|
|
30
|
+
*/
|
|
31
|
+
import type { ShapeText } from "./shape-rules.js";
|
|
32
|
+
export interface ShapeMatch {
|
|
33
|
+
nonstandardFetchMode?: true;
|
|
34
|
+
/** Start of the value in the scanned text. */
|
|
35
|
+
start: number;
|
|
36
|
+
/** End (exclusive) of the value. */
|
|
37
|
+
end: number;
|
|
38
|
+
/** Token type printed inside `[REDACTED:<type>]`. */
|
|
39
|
+
type: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The secrets of the three shapes in `text`. `shape` answers where each value
|
|
43
|
+
* stands (see `ShapeText`); only a value that stands in one of the shapes
|
|
44
|
+
* without breaking ①-④ is returned.
|
|
45
|
+
*/
|
|
46
|
+
export declare function scanSecretShapes(text: string, shape: ShapeText): ShapeMatch[];
|
|
47
|
+
//# sourceMappingURL=secret-shapes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret-shapes.d.ts","sourceRoot":"","sources":["../src/secret-shapes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGlD,MAAM,WAAW,UAAU;IACzB,oBAAoB,CAAC,EAAE,IAAI,CAAC;IAC5B,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;CACd;AAoTD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,UAAU,EAAE,CA6E7E"}
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.scanSecretShapes = scanSecretShapes;
|
|
4
|
+
const credential_semantics_js_1 = require("./credential-semantics.js");
|
|
5
|
+
/** Longest quoted value read. A longer one is not a password. */
|
|
6
|
+
const MAX_QUOTED = 256;
|
|
7
|
+
/**
|
|
8
|
+
* How far a bare (unquoted) value is read to decide whether it is a credential.
|
|
9
|
+
* A refused value costs at most this much, so a long run of keys that are
|
|
10
|
+
* followed by refused values cannot make the scan quadratic. A value that is
|
|
11
|
+
* accepted is then read to its real end.
|
|
12
|
+
*/
|
|
13
|
+
const BARE_PROBE = 256;
|
|
14
|
+
/** Longest run of separators/continuations skipped between a key and its value. */
|
|
15
|
+
const MAX_GAP = 512;
|
|
16
|
+
/** Blank lines allowed between a key and a value on a later line. */
|
|
17
|
+
const MAX_BLANK_LINES = 2;
|
|
18
|
+
const CREDENTIAL_WORDS = "pass(?:word|wd|phrase)|secret|token|api[_-]?key|apikey|authorization|credentials?|private[_-]?key|access[_-]?key";
|
|
19
|
+
const FLAG = /--(?:password|pass|pwd)(?:=|(?=\s))/g;
|
|
20
|
+
// Same name rule as `env_var_secret` in redact.ts; only the position rule moves
|
|
21
|
+
// from "line start" to "starts a word", so `FOO=1 DB_PASSWORD="x" ./run` reads.
|
|
22
|
+
// The name is read whole and then tested for a credential word, instead of
|
|
23
|
+
// `[A-Z0-9_]*(?:KEY|...)[A-Z0-9_]*` in one regex, whose nested stars backtrack
|
|
24
|
+
// quadratically inside one long upper-case word.
|
|
25
|
+
const ENV_NAME = /(?<![A-Za-z0-9_])([A-Z][A-Z0-9_]*)[ \t]*=/g;
|
|
26
|
+
/** A credential word anywhere after the first letter of the name (as `env_var_secret` in redact.ts). */
|
|
27
|
+
const ENV_CREDENTIAL_WORD = /KEY|SECRET|TOKEN|PASSWORD|PASSWD|PWD/;
|
|
28
|
+
const FIELD = new RegExp(`(?<![A-Za-z0-9_.-])[A-Za-z0-9_.-]{0,40}(?:${CREDENTIAL_WORDS})[ \\t]*:`, "gi");
|
|
29
|
+
const K8S_ENV = /(?<![A-Za-z0-9_.-])name:[ \t]*["']?([A-Za-z_][A-Za-z0-9_.-]{0,100})["']?[ \t]*\r?\n[ \t]*(?:-[ \t]+)?value:/g;
|
|
30
|
+
const CREDENTIAL_NAME = new RegExp(CREDENTIAL_WORDS, "i");
|
|
31
|
+
const SCHEMES = new Set(["bearer", "basic", "digest", "token", "negotiate", "ntlm"]);
|
|
32
|
+
/** Words that follow a credential-looking key without being a credential. */
|
|
33
|
+
const NOT_A_SECRET = new Set([
|
|
34
|
+
"null", "nil", "none", "~", "true", "false", "yes", "no", "string", "str", "number", "int",
|
|
35
|
+
"integer", "bool", "boolean", "any", "unknown", "undefined", "void", "object", "required",
|
|
36
|
+
"optional", "...", "is", "are", "was", "the", "a", "an", "below", "above", "here", "missing", "invalid",
|
|
37
|
+
"expired", "empty", "set", "unset", "redacted",
|
|
38
|
+
]);
|
|
39
|
+
/**
|
|
40
|
+
* Characters that end a bare word in a shell, so they end the value too:
|
|
41
|
+
* `TOKEN=abc;curl evil|sh` is one assignment and a second command, and the
|
|
42
|
+
* second must stay visible to the guard. After a field name (`token: x`) only
|
|
43
|
+
* the ones that chain commands end it, because `<` and `>` are refused later
|
|
44
|
+
* as part of a template.
|
|
45
|
+
*/
|
|
46
|
+
const SHELL_STOP = ";&|<>";
|
|
47
|
+
const FIELD_STOP = ";&|";
|
|
48
|
+
const isHSpace = (c) => c === " " || c === "\t";
|
|
49
|
+
const isSpace = (c) => c === " " || c === "\t" || c === "\n" || c === "\r";
|
|
50
|
+
/** Length of the `\<newline>` at `at` (a shell line continuation), else 0. */
|
|
51
|
+
function continuationAt(text, at) {
|
|
52
|
+
if (text[at] !== "\\")
|
|
53
|
+
return 0;
|
|
54
|
+
if (text[at + 1] === "\n")
|
|
55
|
+
return 2;
|
|
56
|
+
if (text[at + 1] === "\r" && text[at + 2] === "\n")
|
|
57
|
+
return 3;
|
|
58
|
+
return 0;
|
|
59
|
+
}
|
|
60
|
+
/** Skip spaces, tabs and line continuations (and the indentation after one). */
|
|
61
|
+
function skipGap(text, from) {
|
|
62
|
+
let pos = from;
|
|
63
|
+
let continued = false;
|
|
64
|
+
const limit = Math.min(text.length, from + MAX_GAP);
|
|
65
|
+
while (pos < limit) {
|
|
66
|
+
if (isHSpace(text[pos])) {
|
|
67
|
+
pos++;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const length = continuationAt(text, pos);
|
|
71
|
+
if (length === 0)
|
|
72
|
+
break;
|
|
73
|
+
pos += length;
|
|
74
|
+
continued = true;
|
|
75
|
+
}
|
|
76
|
+
return { pos, continued };
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Read one value at `at`: a quoted string (the inside, up to the closing quote
|
|
80
|
+
* on the same line) or a bare word (up to whitespace or a quote, joined across
|
|
81
|
+
* `\<newline>` when the next line goes on without a space).
|
|
82
|
+
*/
|
|
83
|
+
function readValue(text, at, cap = Infinity, stop = "") {
|
|
84
|
+
const first = text[at];
|
|
85
|
+
if (first === undefined)
|
|
86
|
+
return null;
|
|
87
|
+
if (first === '"' || first === "'") {
|
|
88
|
+
const limit = Math.min(text.length, at + 1 + MAX_QUOTED);
|
|
89
|
+
for (let i = at + 1; i < limit; i++) {
|
|
90
|
+
const c = text[i];
|
|
91
|
+
if (c === first)
|
|
92
|
+
return i === at + 1 ? null : { start: at + 1, end: i, next: i + 1, quoted: true };
|
|
93
|
+
if (c === "\\") {
|
|
94
|
+
const length = continuationAt(text, i);
|
|
95
|
+
if (length > 0)
|
|
96
|
+
i += length - 1;
|
|
97
|
+
else if (first === '"')
|
|
98
|
+
i++; // an escaped character; in single quotes a backslash is a letter
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (c === "\n")
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
let i = at;
|
|
107
|
+
const limit = cap === Infinity ? text.length : Math.min(text.length, at + cap);
|
|
108
|
+
while (i < limit) {
|
|
109
|
+
const c = text[i];
|
|
110
|
+
if (isSpace(c) || c === '"' || c === "'" || stop.includes(c))
|
|
111
|
+
break;
|
|
112
|
+
if (c === "\\") {
|
|
113
|
+
const length = continuationAt(text, i);
|
|
114
|
+
if (length > 0) {
|
|
115
|
+
const after = text[i + length];
|
|
116
|
+
if (after === undefined || isSpace(after) || after === '"' || after === "'" || stop.includes(after))
|
|
117
|
+
break;
|
|
118
|
+
i += length;
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
i++;
|
|
123
|
+
}
|
|
124
|
+
if (i === at)
|
|
125
|
+
return null;
|
|
126
|
+
return { start: at, end: i, next: i, quoted: false, stop, ...(i >= limit && i < text.length ? { truncated: true } : {}) };
|
|
127
|
+
}
|
|
128
|
+
/** Finish a probe read: a bare value that was cut at the cap is read to its end. */
|
|
129
|
+
function whole(text, read) {
|
|
130
|
+
return read.truncated ? (readValue(text, read.start, Infinity, read.stop) ?? read) : read;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The value at `at`, read only as far as it takes to decide. A bare value that
|
|
134
|
+
* starts with one of `refused` is turned away without being read at all.
|
|
135
|
+
*/
|
|
136
|
+
function probe(text, at, refused, stop) {
|
|
137
|
+
const c = text[at];
|
|
138
|
+
if (c !== undefined && refused.includes(c))
|
|
139
|
+
return null;
|
|
140
|
+
return readValue(text, at, BARE_PROBE, stop);
|
|
141
|
+
}
|
|
142
|
+
/** First characters of a bare value that is a variable, a template or a placeholder. */
|
|
143
|
+
const REFERENCE_START = "$`<{[(#%";
|
|
144
|
+
/** A bare value that is a variable, a template, a type name or a placeholder. */
|
|
145
|
+
function bareNotASecret(text, read) {
|
|
146
|
+
const first = text[read.start];
|
|
147
|
+
if (first !== undefined && REFERENCE_START.includes(first))
|
|
148
|
+
return true;
|
|
149
|
+
const word = text.slice(read.start, read.end).replace(/[,;}\])]+$/, "").toLowerCase();
|
|
150
|
+
return word.length === 0 || NOT_A_SECRET.has(word) || /[\[\](){}<>]/.test(word) || /\$\(|`/.test(word);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* The pieces of a bare value: it is cut at each `\<newline>` it holds, and the
|
|
154
|
+
* pieces after a cut stand after a line continuation (the first one only when
|
|
155
|
+
* the value itself starts after one). Trailing punctuation that belongs to the
|
|
156
|
+
* surrounding syntax is left out of the last piece.
|
|
157
|
+
*/
|
|
158
|
+
function barePieces(text, read) {
|
|
159
|
+
const pieces = [];
|
|
160
|
+
let from = read.start;
|
|
161
|
+
for (let i = read.start; i < read.end; i++) {
|
|
162
|
+
if (text[i] !== "\\")
|
|
163
|
+
continue;
|
|
164
|
+
const length = continuationAt(text, i);
|
|
165
|
+
if (length === 0)
|
|
166
|
+
continue;
|
|
167
|
+
if (i > from)
|
|
168
|
+
pieces.push({ start: from, end: i });
|
|
169
|
+
i += length - 1;
|
|
170
|
+
from = i + 1;
|
|
171
|
+
}
|
|
172
|
+
let end = read.end;
|
|
173
|
+
while (end > from && ",;}])".includes(text[end - 1]))
|
|
174
|
+
end--;
|
|
175
|
+
if (end > from)
|
|
176
|
+
pieces.push({ start: from, end });
|
|
177
|
+
return pieces;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* A bare value on the key's own line is what redact.ts reads, so it is not new. When the value
|
|
181
|
+
* goes on after a line continuation, though, the head is one secret cut in two: it is masked
|
|
182
|
+
* with the rest (mcp-logger does the same), and only stays out when the value is one piece.
|
|
183
|
+
*/
|
|
184
|
+
function joinedHead(pieces) {
|
|
185
|
+
return pieces.length > 1 ? [{ ...pieces[0], joined: true }, ...pieces.slice(1)] : [];
|
|
186
|
+
}
|
|
187
|
+
const wasRefused = (taken) => typeof taken === "object" && taken !== null && "refusedTo" in taken;
|
|
188
|
+
/** A quoted or continued value after `=` or a flag. A bare value on the same line is not read. */
|
|
189
|
+
function assignedValue(text, from) {
|
|
190
|
+
const gap = skipGap(text, from);
|
|
191
|
+
let read = probe(text, gap.pos, "$`", SHELL_STOP);
|
|
192
|
+
if (!read)
|
|
193
|
+
return null;
|
|
194
|
+
if (read.quoted) {
|
|
195
|
+
if (/^\$\{?[A-Za-z_][A-Za-z0-9_]*\}?$/.test(text.slice(read.start, read.end)))
|
|
196
|
+
return null;
|
|
197
|
+
return { ranges: [{ start: read.start, end: read.end }], next: read.next };
|
|
198
|
+
}
|
|
199
|
+
if (/\$\(|`/.test(text.slice(read.start, read.end)))
|
|
200
|
+
return null;
|
|
201
|
+
read = whole(text, read);
|
|
202
|
+
if (/\$\(|`/.test(text.slice(read.start, read.end)))
|
|
203
|
+
return { refusedTo: read.end };
|
|
204
|
+
const pieces = barePieces(text, read);
|
|
205
|
+
// A bare value on the key's own line is what the patterns of redact.ts read;
|
|
206
|
+
// only what stands after a continuation is new.
|
|
207
|
+
const after = gap.continued ? pieces : joinedHead(pieces);
|
|
208
|
+
return { ranges: after, next: read.next };
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* The value after `key:` in YAML or a header. Same line: a quoted value. Later
|
|
212
|
+
* line (after a block-scalar marker, or when the key ends its line): the next
|
|
213
|
+
* indented line, quoted or bare. A word that is a
|
|
214
|
+
* scheme (`Bearer`, `Basic`) is skipped to the credential after it.
|
|
215
|
+
*/
|
|
216
|
+
function valueAfterColon(text, from) {
|
|
217
|
+
const gap = skipGap(text, from);
|
|
218
|
+
let pos = gap.pos;
|
|
219
|
+
// Past a line continuation the value is a new line's, as after a line break.
|
|
220
|
+
let crossedLine = gap.continued;
|
|
221
|
+
const block = /^[|>][+-]?[0-9]?[+-]?[ \t]*(?:#[^\n]*)?(?=\r?\n)/.exec(text.slice(pos, pos + 64));
|
|
222
|
+
if (block)
|
|
223
|
+
pos += block[0].length;
|
|
224
|
+
if (block || text[pos] === "\n" || (text[pos] === "\r" && text[pos + 1] === "\n")) {
|
|
225
|
+
let line = pos;
|
|
226
|
+
let blanks = 0;
|
|
227
|
+
for (;;) {
|
|
228
|
+
if (text[line] === "\r")
|
|
229
|
+
line++;
|
|
230
|
+
if (text[line] !== "\n")
|
|
231
|
+
return null;
|
|
232
|
+
line++;
|
|
233
|
+
const indent = line;
|
|
234
|
+
while (isHSpace(text[line]))
|
|
235
|
+
line++;
|
|
236
|
+
if (text[line] === "\n" || text[line] === "\r") {
|
|
237
|
+
if (++blanks > MAX_BLANK_LINES)
|
|
238
|
+
return null;
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
// A value on its own line is indented; a line at the margin is the next key.
|
|
242
|
+
if (line === indent)
|
|
243
|
+
return null;
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
pos = line;
|
|
247
|
+
crossedLine = true;
|
|
248
|
+
// A YAML list item (`token:\n - value`): the value is the item.
|
|
249
|
+
if (text[pos] === "-" && isHSpace(text[pos + 1])) {
|
|
250
|
+
pos++;
|
|
251
|
+
while (isHSpace(text[pos]))
|
|
252
|
+
pos++;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
let read = probe(text, pos, REFERENCE_START, FIELD_STOP);
|
|
256
|
+
if (!read)
|
|
257
|
+
return null;
|
|
258
|
+
if (read.quoted) {
|
|
259
|
+
if (/^\$\{?[A-Za-z_][A-Za-z0-9_]*\}?$/.test(text.slice(read.start, read.end)))
|
|
260
|
+
return null;
|
|
261
|
+
return { ranges: [{ start: read.start, end: read.end }], next: read.next };
|
|
262
|
+
}
|
|
263
|
+
if (!read.quoted && SCHEMES.has(text.slice(read.start, read.end).toLowerCase())) {
|
|
264
|
+
// `Bearer <value>`: the credential is the word after the scheme.
|
|
265
|
+
const after = skipGap(text, read.end);
|
|
266
|
+
if (after.pos === read.end)
|
|
267
|
+
return null;
|
|
268
|
+
crossedLine = after.continued;
|
|
269
|
+
read = probe(text, after.pos, REFERENCE_START, FIELD_STOP);
|
|
270
|
+
if (!read)
|
|
271
|
+
return null;
|
|
272
|
+
if (read.quoted) {
|
|
273
|
+
if (/^\$\{?[A-Za-z_][A-Za-z0-9_]*\}?$/.test(text.slice(read.start, read.end)))
|
|
274
|
+
return null;
|
|
275
|
+
return { ranges: [{ start: read.start, end: read.end }], next: read.next };
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
if (bareNotASecret(text, read))
|
|
279
|
+
return null;
|
|
280
|
+
read = whole(text, read);
|
|
281
|
+
// Refused only after reading it all: the scan goes on after it, not inside it.
|
|
282
|
+
if (/\$\(|`/.test(text.slice(read.start, read.end)))
|
|
283
|
+
return { refusedTo: read.end };
|
|
284
|
+
// `password:\n user: x` — the next line is a nested key, not the secret.
|
|
285
|
+
if (!read.quoted && text[read.end - 1] === ":")
|
|
286
|
+
return null;
|
|
287
|
+
// A bare value on the key's own line is what the patterns of redact.ts read; only what stands on a
|
|
288
|
+
// later line, or after a line continuation inside the value, is new.
|
|
289
|
+
const pieces = barePieces(text, read);
|
|
290
|
+
return { ranges: crossedLine ? pieces : joinedHead(pieces), next: read.next };
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* The secrets of the three shapes in `text`. `shape` answers where each value
|
|
294
|
+
* stands (see `ShapeText`); only a value that stands in one of the shapes
|
|
295
|
+
* without breaking ①-④ is returned.
|
|
296
|
+
*/
|
|
297
|
+
function scanSecretShapes(text, shape) {
|
|
298
|
+
const out = [];
|
|
299
|
+
const take = (ranges, type) => {
|
|
300
|
+
for (const range of ranges) {
|
|
301
|
+
if (range.joined) {
|
|
302
|
+
if (shape.copyAllowed(range.start, range.end))
|
|
303
|
+
out.push({ start: range.start, end: range.end, type });
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
const placed = shape.evalShape(range.start, range.end);
|
|
307
|
+
if (placed.shape !== null && placed.violation === null)
|
|
308
|
+
out.push({ start: range.start, end: range.end, type });
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
// Quoted or continued value after --password / --pass / --pwd.
|
|
312
|
+
FLAG.lastIndex = 0;
|
|
313
|
+
for (let m = FLAG.exec(text); m !== null; m = FLAG.exec(text)) {
|
|
314
|
+
const found = assignedValue(text, FLAG.lastIndex);
|
|
315
|
+
if (!found)
|
|
316
|
+
continue;
|
|
317
|
+
if (wasRefused(found)) {
|
|
318
|
+
FLAG.lastIndex = Math.max(FLAG.lastIndex, found.refusedTo);
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
FLAG.lastIndex = Math.max(FLAG.lastIndex, found.next);
|
|
322
|
+
take(found.ranges, "cli_password_flag");
|
|
323
|
+
}
|
|
324
|
+
// NAME=value where NAME looks like a credential, anywhere on the line.
|
|
325
|
+
ENV_NAME.lastIndex = 0;
|
|
326
|
+
for (let m = ENV_NAME.exec(text); m !== null; m = ENV_NAME.exec(text)) {
|
|
327
|
+
if (!ENV_CREDENTIAL_WORD.test(m[1].slice(1)))
|
|
328
|
+
continue;
|
|
329
|
+
const found = assignedValue(text, ENV_NAME.lastIndex);
|
|
330
|
+
if (!found)
|
|
331
|
+
continue;
|
|
332
|
+
if (wasRefused(found)) {
|
|
333
|
+
ENV_NAME.lastIndex = Math.max(ENV_NAME.lastIndex, found.refusedTo);
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
ENV_NAME.lastIndex = Math.max(ENV_NAME.lastIndex, found.next);
|
|
337
|
+
take(found.ranges, "env_var_secret");
|
|
338
|
+
}
|
|
339
|
+
// key: value in headers and YAML, the value possibly on a later line.
|
|
340
|
+
FIELD.lastIndex = 0;
|
|
341
|
+
for (let m = FIELD.exec(text); m !== null; m = FIELD.exec(text)) {
|
|
342
|
+
const found = valueAfterColon(text, FIELD.lastIndex);
|
|
343
|
+
if (!found)
|
|
344
|
+
continue;
|
|
345
|
+
if (wasRefused(found)) {
|
|
346
|
+
FIELD.lastIndex = Math.max(FIELD.lastIndex, found.refusedTo);
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
FIELD.lastIndex = Math.max(FIELD.lastIndex, found.next);
|
|
350
|
+
take(found.ranges, "credential_field");
|
|
351
|
+
}
|
|
352
|
+
// Kubernetes-style `- name: DB_PASSWORD` / `value: <secret>` pairs.
|
|
353
|
+
K8S_ENV.lastIndex = 0;
|
|
354
|
+
for (let m = K8S_ENV.exec(text); m !== null; m = K8S_ENV.exec(text)) {
|
|
355
|
+
if (!CREDENTIAL_NAME.test(m[1]))
|
|
356
|
+
continue;
|
|
357
|
+
const found = valueAfterColon(text, K8S_ENV.lastIndex);
|
|
358
|
+
if (!found)
|
|
359
|
+
continue;
|
|
360
|
+
if (wasRefused(found)) {
|
|
361
|
+
K8S_ENV.lastIndex = Math.max(K8S_ENV.lastIndex, found.refusedTo);
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
K8S_ENV.lastIndex = Math.max(K8S_ENV.lastIndex, found.next);
|
|
365
|
+
take(found.ranges, "env_var_secret");
|
|
366
|
+
}
|
|
367
|
+
if (!out.some((hit) => hit.type === "credential_field") || !/\bcredentials\b/.test(text) || !/\bfetch\b/.test(text))
|
|
368
|
+
return out;
|
|
369
|
+
const roles = (0, credential_semantics_js_1.inspectCredentialSemantics)(text);
|
|
370
|
+
const modes = new Set(roles.options
|
|
371
|
+
.filter((option) => option.valueEvidence === "standard_mode")
|
|
372
|
+
.map((option) => `${option.start}:${option.end}`));
|
|
373
|
+
return out.filter((hit) => hit.type !== "credential_field" || !modes.has(`${hit.start}:${hit.end}`))
|
|
374
|
+
.map((hit) => hit.type === "credential_field" && roles.options.some((option) => option.start === hit.start && option.end === hit.end && option.valueEvidence === "other")
|
|
375
|
+
? { ...hit, nonstandardFetchMode: true } : hit);
|
|
376
|
+
}
|
|
377
|
+
//# sourceMappingURL=secret-shapes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret-shapes.js","sourceRoot":"","sources":["../src/secret-shapes.ts"],"names":[],"mappings":";;AAkWA,4CA6EC;AAhZD,uEAAuE;AAYvE,iEAAiE;AACjE,MAAM,UAAU,GAAG,GAAG,CAAC;AACvB;;;;;GAKG;AACH,MAAM,UAAU,GAAG,GAAG,CAAC;AACvB,mFAAmF;AACnF,MAAM,OAAO,GAAG,GAAG,CAAC;AACpB,qEAAqE;AACrE,MAAM,eAAe,GAAG,CAAC,CAAC;AAE1B,MAAM,gBAAgB,GACpB,kHAAkH,CAAC;AAErH,MAAM,IAAI,GAAG,sCAAsC,CAAC;AACpD,gFAAgF;AAChF,gFAAgF;AAChF,2EAA2E;AAC3E,+EAA+E;AAC/E,iDAAiD;AACjD,MAAM,QAAQ,GAAG,4CAA4C,CAAC;AAC9D,wGAAwG;AACxG,MAAM,mBAAmB,GAAG,sCAAsC,CAAC;AACnE,MAAM,KAAK,GAAG,IAAI,MAAM,CACtB,6CAA6C,gBAAgB,WAAW,EACxE,IAAI,CACL,CAAC;AACF,MAAM,OAAO,GAAG,8GAA8G,CAAC;AAC/H,MAAM,eAAe,GAAG,IAAI,MAAM,CAAC,gBAAgB,EAAE,G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