@pinta-ai/pinta-codex 1.12.4-rc.1 → 1.12.4-rc.3
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/.codex-plugin/plugin.json +1 -1
- package/README.md +2 -0
- package/dist/index.js +32 -66
- package/dist/index.mjs +32 -66
- package/package.json +2 -3
- package/tools/test-redact.ts +0 -289
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pinta-ai/pinta-codex",
|
|
3
|
-
"version": "1.12.4-rc.
|
|
3
|
+
"version": "1.12.4-rc.3",
|
|
4
4
|
"description": "Generic OTLP forwarder for Codex hook events",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -42,7 +42,6 @@
|
|
|
42
42
|
"uninstall-hooks": "npx tsx tools/uninstall-hooks.ts",
|
|
43
43
|
"mock-server": "npx tsx tools/mock-server.ts",
|
|
44
44
|
"test:otlp": "npx tsx tools/test-otlp.ts",
|
|
45
|
-
"test:redact": "npx tsx tools/test-redact.ts",
|
|
46
45
|
"test": "vitest run",
|
|
47
46
|
"test:watch": "vitest",
|
|
48
47
|
"smoke:import": "node scripts/smoke-import.mjs",
|
|
@@ -50,7 +49,7 @@
|
|
|
50
49
|
"prepublishOnly": "npm run build"
|
|
51
50
|
},
|
|
52
51
|
"devDependencies": {
|
|
53
|
-
"@pinta-ai/core": "0.
|
|
52
|
+
"@pinta-ai/core": "0.13.0-rc.1",
|
|
54
53
|
"@types/node": "^22.0.0",
|
|
55
54
|
"esbuild": "^0.24.0",
|
|
56
55
|
"typescript": "^5.7.0",
|
package/tools/test-redact.ts
DELETED
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
import { strict as assert } from "node:assert";
|
|
2
|
-
import {
|
|
3
|
-
truncate,
|
|
4
|
-
redact,
|
|
5
|
-
MAX_BYTES,
|
|
6
|
-
PATTERNS,
|
|
7
|
-
collectMatches,
|
|
8
|
-
resolveOverlaps,
|
|
9
|
-
applyMatches,
|
|
10
|
-
} from "../src/core/redact.js";
|
|
11
|
-
|
|
12
|
-
let failures = 0;
|
|
13
|
-
function check(name: string, fn: () => void): void {
|
|
14
|
-
try {
|
|
15
|
-
fn();
|
|
16
|
-
process.stdout.write(` ok ${name}\n`);
|
|
17
|
-
} catch (err) {
|
|
18
|
-
failures++;
|
|
19
|
-
process.stdout.write(` FAIL ${name}\n ${err instanceof Error ? err.message : err}\n`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// --- truncate ---
|
|
24
|
-
check("truncate: short input passes through", () => {
|
|
25
|
-
assert.equal(truncate("hello"), "hello");
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
check("truncate: long input is cut and tagged", () => {
|
|
29
|
-
const input = "a".repeat(MAX_BYTES + 100);
|
|
30
|
-
const out = truncate(input);
|
|
31
|
-
assert.equal(out.startsWith("a".repeat(MAX_BYTES)), true);
|
|
32
|
-
const headBytes = Buffer.from(out.split("…[TRUNCATED:")[0], "utf-8").length;
|
|
33
|
-
assert.equal(headBytes, MAX_BYTES, `head should be exactly MAX_BYTES, got ${headBytes}`);
|
|
34
|
-
assert.match(out, new RegExp(`…\\[TRUNCATED:${MAX_BYTES + 100}\\]$`));
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
check("truncate: input exactly at cap passes through", () => {
|
|
38
|
-
const input = "a".repeat(MAX_BYTES);
|
|
39
|
-
assert.equal(truncate(input), input);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
check("truncate: counts bytes not codepoints (multibyte char)", () => {
|
|
43
|
-
// "한" is 3 bytes UTF-8. With a tiny synthetic cap we can't override MAX_BYTES,
|
|
44
|
-
// so verify the byte-aware byte count by ensuring a 100KB+ multibyte string
|
|
45
|
-
// is truncated and the original byte length appears in the tag.
|
|
46
|
-
const oneChar = "한"; // 3 bytes
|
|
47
|
-
const charsToExceed = Math.ceil(MAX_BYTES / 3) + 10;
|
|
48
|
-
const input = oneChar.repeat(charsToExceed);
|
|
49
|
-
const origBytes = Buffer.from(input, "utf-8").length;
|
|
50
|
-
const out = truncate(input);
|
|
51
|
-
const headBytes = Buffer.from(out.split("…[TRUNCATED:")[0], "utf-8").length;
|
|
52
|
-
// After slicing on a byte boundary, toString("utf-8") replaces any partial
|
|
53
|
-
// codepoint at the tail with U+FFFD (3 bytes), so headBytes may be up to
|
|
54
|
-
// MAX_BYTES + 2 when the boundary lands mid-codepoint. Allow for that.
|
|
55
|
-
assert.ok(headBytes <= MAX_BYTES + 2, `head exceeds MAX_BYTES+2: ${headBytes}`);
|
|
56
|
-
assert.match(out, new RegExp(`…\\[TRUNCATED:${origBytes}\\]$`));
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
interface PatternCase {
|
|
60
|
-
type: string;
|
|
61
|
-
input: string;
|
|
62
|
-
/** Substring(s) the *output* must contain. */
|
|
63
|
-
expectContains: string[];
|
|
64
|
-
/** Substring(s) the *output* must NOT contain (typically the original secret). */
|
|
65
|
-
expectMissing?: string[];
|
|
66
|
-
context?: "bash";
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function applySinglePattern(input: string, type: string): string {
|
|
70
|
-
// Direct application of a single pattern's matches via the same algorithm
|
|
71
|
-
// redact() will use. We re-run regex here without the full pipeline so a
|
|
72
|
-
// pattern test fails when the regex is wrong, not when resolution is wrong.
|
|
73
|
-
const pattern = PATTERNS.find((x) => x.type === type);
|
|
74
|
-
if (!pattern) throw new Error(`no PATTERN with type=${type}`);
|
|
75
|
-
const re = new RegExp(pattern.regex.source, pattern.regex.flags);
|
|
76
|
-
let out = "";
|
|
77
|
-
let last = 0;
|
|
78
|
-
let m: RegExpExecArray | null;
|
|
79
|
-
while ((m = re.exec(input)) !== null) {
|
|
80
|
-
const cg = pattern.captureGroup ?? 0;
|
|
81
|
-
const captured = m[cg];
|
|
82
|
-
if (captured === undefined) continue;
|
|
83
|
-
const captureStart = m.index + m[0].indexOf(captured);
|
|
84
|
-
const captureEnd = captureStart + captured.length;
|
|
85
|
-
out += input.slice(last, captureStart) + `[REDACTED:${pattern.type}]`;
|
|
86
|
-
last = captureEnd;
|
|
87
|
-
if (m.index === re.lastIndex) re.lastIndex++; // zero-length guard
|
|
88
|
-
}
|
|
89
|
-
out += input.slice(last);
|
|
90
|
-
return out;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const PATTERN_CASES: PatternCase[] = [
|
|
94
|
-
{
|
|
95
|
-
type: "aws_access_key",
|
|
96
|
-
input: "key=AKIAIOSFODNN7EXAMPLE end",
|
|
97
|
-
expectContains: ["[REDACTED:aws_access_key]"],
|
|
98
|
-
expectMissing: ["AKIAIOSFODNN7EXAMPLE"],
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
type: "aws_secret_key",
|
|
102
|
-
input: "AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
|
|
103
|
-
expectContains: ["[REDACTED:aws_secret_key]"],
|
|
104
|
-
expectMissing: ["wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"],
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
type: "gcp_service_account",
|
|
108
|
-
input: '{"type":"service_account","project_id":"foo","private_key":"-----BEGIN PRIVATE KEY-----\\nABC\\n-----END PRIVATE KEY-----"}',
|
|
109
|
-
expectContains: ["[REDACTED:gcp_service_account]"],
|
|
110
|
-
expectMissing: ['"project_id":"foo"', "BEGIN PRIVATE KEY"],
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
type: "github_token",
|
|
114
|
-
input: "token=ghp_abcdefghijklmnopqrstuvwxyz0123456789AB end",
|
|
115
|
-
expectContains: ["[REDACTED:github_token]"],
|
|
116
|
-
expectMissing: ["ghp_abcdefghijklmnopqrstuvwxyz0123456789AB"],
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
type: "gitlab_token",
|
|
120
|
-
input: "GitLab: glpat-abcdefghijklmno12345",
|
|
121
|
-
expectContains: ["[REDACTED:gitlab_token]"],
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
type: "slack_token",
|
|
125
|
-
input: "xoxb-1234567890-abcdef0123456789",
|
|
126
|
-
expectContains: ["[REDACTED:slack_token]"],
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
type: "openai_key",
|
|
130
|
-
input: "OpenAI: sk-proj-abcdefghij0123456789ABCDEFGHIJ0123456789klmn",
|
|
131
|
-
expectContains: ["[REDACTED:openai_key]"],
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
type: "anthropic_key",
|
|
135
|
-
input: "Key: sk-ant-api03-abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKL_-",
|
|
136
|
-
expectContains: ["[REDACTED:anthropic_key]"],
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
type: "stripe_key",
|
|
140
|
-
input: "stripe sk_live_abcdefghijklmnop0123456789",
|
|
141
|
-
expectContains: ["[REDACTED:stripe_key]"],
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
type: "jwt",
|
|
145
|
-
input: "Token eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJqb2huIn0.abc123def456ghi789jkl",
|
|
146
|
-
expectContains: ["[REDACTED:jwt]"],
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
type: "private_key_block",
|
|
150
|
-
input: "-----BEGIN RSA PRIVATE KEY-----\nMIIBOgIBAAJBAKj34GkxF...\n-----END RSA PRIVATE KEY-----",
|
|
151
|
-
expectContains: ["[REDACTED:private_key_block]"],
|
|
152
|
-
expectMissing: ["MIIBOgIBAAJBAKj34GkxF"],
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
type: "bearer_token",
|
|
156
|
-
input: "Authorization: Bearer abc123def456ghi789",
|
|
157
|
-
expectContains: ["Bearer [REDACTED:bearer_token]"],
|
|
158
|
-
expectMissing: ["abc123def456ghi789"],
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
type: "basic_auth",
|
|
162
|
-
input: "Authorization: Basic dXNlcjpwYXNzd29yZA==",
|
|
163
|
-
expectContains: ["Basic [REDACTED:basic_auth]"],
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
type: "db_url_password",
|
|
167
|
-
input: "DATABASE_URL=postgres://app:s3cret!@db:5432/foo",
|
|
168
|
-
expectContains: ["postgres://app:[REDACTED:db_url_password]@db:5432/foo"],
|
|
169
|
-
expectMissing: ["s3cret!"],
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
type: "cli_password_flag",
|
|
173
|
-
input: "mysql --password=hunter2 mydb",
|
|
174
|
-
expectContains: ["[REDACTED:cli_password_flag]"],
|
|
175
|
-
expectMissing: ["hunter2"],
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
type: "cli_password_short",
|
|
179
|
-
input: "mysql -phunter2 mydb",
|
|
180
|
-
expectContains: ["[REDACTED:cli_password_short]"],
|
|
181
|
-
expectMissing: ["hunter2"],
|
|
182
|
-
context: "bash",
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
type: "env_var_secret",
|
|
186
|
-
input: "OPENAI_API_KEY=sk-abc123def456",
|
|
187
|
-
expectContains: ["OPENAI_API_KEY=[REDACTED:env_var_secret]"],
|
|
188
|
-
expectMissing: ["sk-abc123def456"],
|
|
189
|
-
},
|
|
190
|
-
];
|
|
191
|
-
|
|
192
|
-
for (const tc of PATTERN_CASES) {
|
|
193
|
-
check(`pattern ${tc.type}`, () => {
|
|
194
|
-
const out = applySinglePattern(tc.input, tc.type);
|
|
195
|
-
for (const c of tc.expectContains) {
|
|
196
|
-
assert.ok(out.includes(c), `expected output to contain "${c}"; got: ${out}`);
|
|
197
|
-
}
|
|
198
|
-
for (const m of tc.expectMissing ?? []) {
|
|
199
|
-
assert.ok(!out.includes(m), `expected output to NOT contain "${m}"; got: ${out}`);
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
function pipeline(input: string, opts: { context?: "bash" } = {}): string {
|
|
205
|
-
const all = collectMatches(input, opts);
|
|
206
|
-
const kept = resolveOverlaps(all);
|
|
207
|
-
return applyMatches(input, kept);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
check("overlap: the specific github_token wins over the generic bearer envelope", () => {
|
|
211
|
-
// core >= 0.9.3 keeps the more specific finding when a generic envelope
|
|
212
|
-
// (bearer_token) and a vendor token overlap (pinta-core #16, "preserve
|
|
213
|
-
// envelope findings"), so the value is named for what it is.
|
|
214
|
-
const input = "Authorization: Bearer ghp_abcdefghijklmnopqrstuvwxyz0123456789AB";
|
|
215
|
-
const out = pipeline(input);
|
|
216
|
-
assert.ok(out.includes("Bearer [REDACTED:github_token]"), out);
|
|
217
|
-
assert.ok(!out.includes("ghp_"), out);
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
check("overlap: the specific openai_key wins over the generic env_var_secret", () => {
|
|
221
|
-
// Same rule as above: the generic KEY=value capture and the vendor key
|
|
222
|
-
// overlap on the value, and the vendor type is kept (core >= 0.9.3).
|
|
223
|
-
const input = "OPENAI_API_KEY=sk-proj-abcdefghij0123456789ABCDEFGHIJ0123456789klmn";
|
|
224
|
-
const out = pipeline(input);
|
|
225
|
-
assert.ok(out.includes("OPENAI_API_KEY=[REDACTED:openai_key]"), out);
|
|
226
|
-
assert.ok(!out.includes("sk-proj-"), out);
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
check("ordering: independent matches both applied", () => {
|
|
230
|
-
const input = "first AKIAIOSFODNN7EXAMPLE then ghp_abcdefghijklmnopqrstuvwxyz0123456789AB";
|
|
231
|
-
const out = pipeline(input);
|
|
232
|
-
assert.ok(out.includes("[REDACTED:aws_access_key]"), out);
|
|
233
|
-
assert.ok(out.includes("[REDACTED:github_token]"), out);
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
check("context guard: cli_password_short ignored without context", () => {
|
|
237
|
-
const input = "mysql -phunter2 mydb";
|
|
238
|
-
const out = pipeline(input); // no context
|
|
239
|
-
assert.equal(out.includes("[REDACTED:cli_password_short]"), false);
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
check("context guard: cli_password_short applied with bash context", () => {
|
|
243
|
-
const input = "mysql -phunter2 mydb";
|
|
244
|
-
const out = pipeline(input, { context: "bash" });
|
|
245
|
-
assert.ok(out.includes("[REDACTED:cli_password_short]"), out);
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
check("redact: empty string passes through", () => {
|
|
249
|
-
assert.equal(redact("", {}), "");
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
check("redact: combines multiple secrets", () => {
|
|
253
|
-
const input = "AKIAIOSFODNN7EXAMPLE and ghp_abcdefghijklmnopqrstuvwxyz0123456789AB";
|
|
254
|
-
const out = redact(input);
|
|
255
|
-
assert.ok(out.includes("[REDACTED:aws_access_key]"), out);
|
|
256
|
-
assert.ok(out.includes("[REDACTED:github_token]"), out);
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
// --- negative (false-positive guards) ---
|
|
260
|
-
check("negative: 40-byte commit SHA ignored", () => {
|
|
261
|
-
const input = "commit 0123456789abcdef0123456789abcdef01234567 by alice";
|
|
262
|
-
assert.equal(redact(input), input);
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
check("negative: UUID ignored", () => {
|
|
266
|
-
const input = "uuid=550e8400-e29b-41d4-a716-446655440000 done";
|
|
267
|
-
assert.equal(redact(input), input);
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
check("negative: random base64 thumbnail not masked (no context)", () => {
|
|
271
|
-
const input = "thumb=YWJjZGVmZ2hpamtsbW5vcA== loaded";
|
|
272
|
-
assert.equal(redact(input), input);
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
check("negative: 40-char base64 alone (no aws_secret context) ignored", () => {
|
|
276
|
-
const input = "blob=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY end";
|
|
277
|
-
assert.equal(redact(input), input);
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
check("negative: dash-p in normal text without bash context ignored", () => {
|
|
281
|
-
const input = "see also -pretty option";
|
|
282
|
-
assert.equal(redact(input), input);
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
if (failures > 0) {
|
|
286
|
-
process.stdout.write(`\n${failures} failure(s)\n`);
|
|
287
|
-
process.exit(1);
|
|
288
|
-
}
|
|
289
|
-
process.stdout.write("\nOK\n");
|