@f5xc-salesdemos/pi-utils 19.48.0 → 19.49.0
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 +2 -2
- package/src/xcsh-env-names.ts +20 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@f5xc-salesdemos/pi-utils",
|
|
4
|
-
"version": "19.
|
|
4
|
+
"version": "19.49.0",
|
|
5
5
|
"description": "Shared utilities for pi packages",
|
|
6
6
|
"homepage": "https://github.com/f5xc-salesdemos/xcsh",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/bun": "^1.3",
|
|
42
|
-
"@f5xc-salesdemos/pi-natives": "19.
|
|
42
|
+
"@f5xc-salesdemos/pi-natives": "19.49.0"
|
|
43
43
|
},
|
|
44
44
|
"engines": {
|
|
45
45
|
"bun": ">=1.3.7"
|
package/src/xcsh-env-names.ts
CHANGED
|
@@ -47,3 +47,23 @@ export const SECRET_ENV_PATTERNS = /(?:KEY|SECRET|TOKEN|PASSWORD|PASS|AUTH|CREDE
|
|
|
47
47
|
export function isSensitiveEnvKey(key: string): boolean {
|
|
48
48
|
return SECRET_ENV_PATTERNS.test(key);
|
|
49
49
|
}
|
|
50
|
+
|
|
51
|
+
/** Prefix that namespaces every context-owned environment variable. */
|
|
52
|
+
export const XCSH_ENV_PREFIX = "XCSH_";
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* True iff a context's `env` entry may be injected into a spawned subprocess.
|
|
56
|
+
*
|
|
57
|
+
* This is an allowlist (default-deny): only `XCSH_`-namespaced, non-reserved keys
|
|
58
|
+
* are injectable. A project-local `.xcsh/contexts/*.json` is untrusted input, so a
|
|
59
|
+
* denylist of "dangerous" names is unsafe — it is impossible to enumerate every
|
|
60
|
+
* process/interpreter-hijacking variable (LD_PRELOAD, DYLD_INSERT_LIBRARIES,
|
|
61
|
+
* NODE_OPTIONS, NODE_PATH, PATH, PYTHONHOME, JAVA_TOOL_OPTIONS, CLASSPATH, …).
|
|
62
|
+
* Restricting injection to the `XCSH_` namespace blocks all of them by
|
|
63
|
+
* construction, since none are `XCSH_`-prefixed. Reserved keys (XCSH_API_URL,
|
|
64
|
+
* XCSH_API_TOKEN, XCSH_NAMESPACE, XCSH_TENANT, XCSH_CONTEXT_NAME) are excluded too —
|
|
65
|
+
* the host sets those itself from the context's typed fields.
|
|
66
|
+
*/
|
|
67
|
+
export function isInjectableContextEnvKey(key: string): boolean {
|
|
68
|
+
return key.startsWith(XCSH_ENV_PREFIX) && !RESERVED_ENV_KEYS.has(key);
|
|
69
|
+
}
|