@sayknow-cli/utils 0.7.24 → 0.7.26
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/types/env.d.ts +1 -1
- package/dist/types/shell-config.d.ts +6 -5
- package/dist/types/spawn-env.d.ts +2 -0
- package/package.json +2 -2
- package/src/env.ts +1 -1
- package/src/shell-config.ts +10 -7
- package/src/spawn-env.ts +15 -2
package/dist/types/env.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { filterProcessEnv, isSafeEnvName, isSafeEnvValue } from "./spawn-env";
|
|
1
|
+
export { filterProcessEnv, isMacOSMallocStackLoggingEnvName, isSafeEnvName, isSafeEnvValue } from "./spawn-env";
|
|
2
2
|
export { isValidEnvName, parseEnvFile, parseShellEnvFile } from "./env-file";
|
|
3
3
|
/** Project dotenv as it was when this module loaded, before a later `chdir` or file delete. */
|
|
4
4
|
export declare function startupProjectEnvSnapshot(): {
|
|
@@ -5,13 +5,14 @@ export interface ShellConfig {
|
|
|
5
5
|
prefix: string | undefined;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
|
-
* Strip
|
|
8
|
+
* Strip macOS malloc-stack-logging vars (every `MallocStackLogging*` name) from
|
|
9
|
+
* `process.env` in place.
|
|
9
10
|
*
|
|
10
11
|
* macOS leaves `MallocStackLogging=0` (or similar) inherited by debug-attached
|
|
11
|
-
* shells.
|
|
12
|
-
* malloc stack logging because it was not enabled.` to stderr
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* shells. Every child forked from such a process prints `MallocStackLogging:
|
|
13
|
+
* can't turn off malloc stack logging because it was not enabled.` to stderr.
|
|
14
|
+
* Scrubbing once at startup keeps the vars out of `process.env` for code that
|
|
15
|
+
* reads it directly.
|
|
15
16
|
*/
|
|
16
17
|
export declare function scrubProcessEnv(): void;
|
|
17
18
|
/**
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** True for every env var name that turns on macOS malloc stack logging. */
|
|
2
|
+
export declare function isMacOSMallocStackLoggingEnvName(name: string): boolean;
|
|
1
3
|
export declare function isSafeEnvName(name: string): boolean;
|
|
2
4
|
export declare function isSafeEnvValue(value: string): boolean;
|
|
3
5
|
export declare function shouldForwardSpawnEnvName(name: string): boolean;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@sayknow-cli/utils",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.26",
|
|
5
5
|
"description": "Shared utilities for pi packages",
|
|
6
6
|
"homepage": "https://sayknow-cli.com",
|
|
7
7
|
"author": "jaybeyond",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"fmt": "biome format --write ."
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@sayknow-cli/natives": "0.7.
|
|
34
|
+
"@sayknow-cli/natives": "0.7.26",
|
|
35
35
|
"beautiful-mermaid": "^1.1.3",
|
|
36
36
|
"handlebars": "^4.7.9",
|
|
37
37
|
"winston": "^3.19.0",
|
package/src/env.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as path from "node:path";
|
|
|
4
4
|
import { canonicalEnvKey, getAgentDir, getConfigRootDir, getTrustedHomeDir, pathIdentityKey } from "./dirs";
|
|
5
5
|
import { isSafeEnvName, isSafeEnvValue } from "./spawn-env";
|
|
6
6
|
|
|
7
|
-
export { filterProcessEnv, isSafeEnvName, isSafeEnvValue } from "./spawn-env";
|
|
7
|
+
export { filterProcessEnv, isMacOSMallocStackLoggingEnvName, isSafeEnvName, isSafeEnvValue } from "./spawn-env";
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
10
|
parseEnvFile,
|
package/src/shell-config.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
$pickCredentialEnv,
|
|
8
8
|
$pickflag,
|
|
9
9
|
filterProcessEnv,
|
|
10
|
+
isMacOSMallocStackLoggingEnvName,
|
|
10
11
|
startupProjectEnvSnapshot,
|
|
11
12
|
} from "./env";
|
|
12
13
|
import { $which } from "./which";
|
|
@@ -20,17 +21,19 @@ export interface ShellConfig {
|
|
|
20
21
|
let cachedShellConfig: ShellConfig | null = null;
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
|
-
* Strip
|
|
24
|
+
* Strip macOS malloc-stack-logging vars (every `MallocStackLogging*` name) from
|
|
25
|
+
* `process.env` in place.
|
|
24
26
|
*
|
|
25
27
|
* macOS leaves `MallocStackLogging=0` (or similar) inherited by debug-attached
|
|
26
|
-
* shells.
|
|
27
|
-
* malloc stack logging because it was not enabled.` to stderr
|
|
28
|
-
*
|
|
29
|
-
*
|
|
28
|
+
* shells. Every child forked from such a process prints `MallocStackLogging:
|
|
29
|
+
* can't turn off malloc stack logging because it was not enabled.` to stderr.
|
|
30
|
+
* Scrubbing once at startup keeps the vars out of `process.env` for code that
|
|
31
|
+
* reads it directly.
|
|
30
32
|
*/
|
|
31
33
|
export function scrubProcessEnv(): void {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
for (const name of Object.keys(process.env)) {
|
|
35
|
+
if (isMacOSMallocStackLoggingEnvName(name)) delete process.env[name];
|
|
36
|
+
}
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
/**
|
package/src/spawn-env.ts
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* macOS libmalloc enables malloc stack logging for every environment variable
|
|
3
|
+
* with this prefix — not only `MallocStackLogging` / `MallocStackLoggingNoCompact`
|
|
4
|
+
* but also e.g. `MallocStackLoggingLite` and `MallocStackLoggingDirectory`.
|
|
5
|
+
* A process started with any of them makes each forked child print
|
|
6
|
+
* `MallocStackLogging: can't turn off malloc stack logging because it was not
|
|
7
|
+
* enabled.` to the inherited stderr.
|
|
8
|
+
*/
|
|
9
|
+
const MACOS_MALLOC_STACK_LOGGING_ENV_PREFIX = "MallocStackLogging";
|
|
10
|
+
|
|
11
|
+
/** True for every env var name that turns on macOS malloc stack logging. */
|
|
12
|
+
export function isMacOSMallocStackLoggingEnvName(name: string): boolean {
|
|
13
|
+
return name.startsWith(MACOS_MALLOC_STACK_LOGGING_ENV_PREFIX);
|
|
14
|
+
}
|
|
2
15
|
|
|
3
16
|
export function isSafeEnvName(name: string): boolean {
|
|
4
17
|
return name.length > 0 && !name.includes("=") && !name.includes("\0");
|
|
@@ -9,7 +22,7 @@ export function isSafeEnvValue(value: string): boolean {
|
|
|
9
22
|
}
|
|
10
23
|
|
|
11
24
|
export function shouldForwardSpawnEnvName(name: string): boolean {
|
|
12
|
-
return isSafeEnvName(name) && !
|
|
25
|
+
return isSafeEnvName(name) && !isMacOSMallocStackLoggingEnvName(name);
|
|
13
26
|
}
|
|
14
27
|
|
|
15
28
|
export function filterProcessEnv(env: Record<string, string | undefined>): Record<string, string> {
|