@teamscala/service-boot 0.23.332 → 0.23.333
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/package.json
CHANGED
|
@@ -25,6 +25,13 @@
|
|
|
25
25
|
* WebSocket upgrades are returned untouched (Bun tracks upgrades by Request
|
|
26
26
|
* identity — a clone can never upgrade).
|
|
27
27
|
*/
|
|
28
|
+
/**
|
|
29
|
+
* Preserve useful process attribution without copying arbitrary argv into logs.
|
|
30
|
+
* Arguments routinely contain bearer headers, inline scripts, URLs and secret
|
|
31
|
+
* values. There is no complete flag-name redaction list, so the safe boundary
|
|
32
|
+
* is structural: retain argv[0] and state that arguments were removed.
|
|
33
|
+
*/
|
|
34
|
+
export declare function summariseLocalCommand(cmdline: readonly string[]): string | null;
|
|
28
35
|
/**
|
|
29
36
|
* Return a Request with transport-identity headers stamped, or the original
|
|
30
37
|
* `req` when no stamping is needed/possible. Never throws.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { summariseLocalCommand } from "./stamp-transport-identity.ts";
|
|
3
|
+
|
|
4
|
+
describe("local command attribution", () => {
|
|
5
|
+
test("never copies command arguments into telemetry", () => {
|
|
6
|
+
const token = "operator-token-must-not-appear";
|
|
7
|
+
const summary = summariseLocalCommand([
|
|
8
|
+
"curl",
|
|
9
|
+
"-H",
|
|
10
|
+
`x-operator-spawn-token: ${token}`,
|
|
11
|
+
"http://127.0.0.1:3021/rpc/spawn",
|
|
12
|
+
]);
|
|
13
|
+
expect(summary).toBe("curl [arguments redacted]");
|
|
14
|
+
expect(summary).not.toContain(token);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("keeps a lone executable name", () => {
|
|
18
|
+
expect(summariseLocalCommand(["scala-picker"])).toBe("scala-picker");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test("omits an empty command line", () => {
|
|
22
|
+
expect(summariseLocalCommand([])).toBeNull();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -31,6 +31,18 @@ import { resolveSocketPeer } from "@teamscala/proc-walker/socket-peer";
|
|
|
31
31
|
|
|
32
32
|
const LOOPBACK = new Set(["127.0.0.1", "::1", "::ffff:127.0.0.1"]);
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Preserve useful process attribution without copying arbitrary argv into logs.
|
|
36
|
+
* Arguments routinely contain bearer headers, inline scripts, URLs and secret
|
|
37
|
+
* values. There is no complete flag-name redaction list, so the safe boundary
|
|
38
|
+
* is structural: retain argv[0] and state that arguments were removed.
|
|
39
|
+
*/
|
|
40
|
+
export function summariseLocalCommand(cmdline: readonly string[]): string | null {
|
|
41
|
+
const executable = cmdline[0]?.trim();
|
|
42
|
+
if (!executable) return null;
|
|
43
|
+
return cmdline.length > 1 ? `${executable} [arguments redacted]` : executable;
|
|
44
|
+
}
|
|
45
|
+
|
|
34
46
|
/**
|
|
35
47
|
* Return a Request with transport-identity headers stamped, or the original
|
|
36
48
|
* `req` when no stamping is needed/possible. Never throws.
|
|
@@ -77,8 +89,8 @@ export function stampTransportIdentity(
|
|
|
77
89
|
const owner = resolveSocketPeer(port);
|
|
78
90
|
if (owner) {
|
|
79
91
|
headers.set(CALLER_HEADERS.LOCAL_COMM, owner.comm);
|
|
80
|
-
const cmd = owner.cmdline
|
|
81
|
-
if (cmd) headers.set(CALLER_HEADERS.LOCAL_CMD, cmd
|
|
92
|
+
const cmd = summariseLocalCommand(owner.cmdline);
|
|
93
|
+
if (cmd) headers.set(CALLER_HEADERS.LOCAL_CMD, cmd);
|
|
82
94
|
}
|
|
83
95
|
}
|
|
84
96
|
return new Request(req.url, {
|