github-issue-tower-defence-management 1.148.8 → 1.148.9
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/CHANGELOG.md +7 -0
- package/bin/adapter/repositories/NodeLocalCommandRunner.js +5 -0
- package/bin/adapter/repositories/NodeLocalCommandRunner.js.map +1 -1
- package/package.json +1 -1
- package/src/adapter/repositories/NodeLocalCommandRunner.largeOutput.test.ts +16 -0
- package/src/adapter/repositories/NodeLocalCommandRunner.test.ts +20 -0
- package/src/adapter/repositories/NodeLocalCommandRunner.ts +8 -0
- package/types/adapter/repositories/NodeLocalCommandRunner.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.148.9](https://github.com/HiromiShikata/npm-cli-github-issue-tower-defence-management/compare/v1.148.8...v1.148.9) (2026-08-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **command-runner:** keep command stdout past one mebibyte so security scans are not silently emptied ([#1485](https://github.com/HiromiShikata/npm-cli-github-issue-tower-defence-management/issues/1485)) ([6a78747](https://github.com/HiromiShikata/npm-cli-github-issue-tower-defence-management/commit/6a787479c690e9727d153a5ee6195ebf9d10cb3f))
|
|
7
|
+
|
|
1
8
|
## [1.148.8](https://github.com/HiromiShikata/npm-cli-github-issue-tower-defence-management/compare/v1.148.7...v1.148.8) (2026-08-09)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -4,10 +4,12 @@ exports.NodeLocalCommandRunner = void 0;
|
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
5
|
const util_1 = require("util");
|
|
6
6
|
const execFileAsync = (0, util_1.promisify)(child_process_1.execFile);
|
|
7
|
+
const MAX_COMMAND_OUTPUT_BYTES = 1024 * 1024 * 256;
|
|
7
8
|
class NodeLocalCommandRunner {
|
|
8
9
|
async runCommand(program, args, options) {
|
|
9
10
|
const execOptions = {
|
|
10
11
|
encoding: 'utf8',
|
|
12
|
+
maxBuffer: MAX_COMMAND_OUTPUT_BYTES,
|
|
11
13
|
};
|
|
12
14
|
if (options?.env) {
|
|
13
15
|
execOptions.env = { ...process.env, ...options.env };
|
|
@@ -26,6 +28,9 @@ class NodeLocalCommandRunner {
|
|
|
26
28
|
'stdout' in error &&
|
|
27
29
|
'stderr' in error &&
|
|
28
30
|
'code' in error) {
|
|
31
|
+
if (typeof error.code !== 'number') {
|
|
32
|
+
console.error(`${program} did not exit with a numeric status: ${String(error.code)}`);
|
|
33
|
+
}
|
|
29
34
|
return {
|
|
30
35
|
stdout: String(error.stdout),
|
|
31
36
|
stderr: String(error.stderr),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeLocalCommandRunner.js","sourceRoot":"","sources":["../../../src/adapter/repositories/NodeLocalCommandRunner.ts"],"names":[],"mappings":";;;AAIA,iDAAyC;AACzC,+BAAiC;AAEjC,MAAM,aAAa,GAAG,IAAA,gBAAS,EAAC,wBAAQ,CAAC,CAAC;AAE1C,MAAa,sBAAsB;IACjC,KAAK,CAAC,UAAU,CACd,OAAe,EACf,IAAc,EACd,OAAmC;QAMnC,MAAM,WAAW,GAAwC;YACvD,QAAQ,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"NodeLocalCommandRunner.js","sourceRoot":"","sources":["../../../src/adapter/repositories/NodeLocalCommandRunner.ts"],"names":[],"mappings":";;;AAIA,iDAAyC;AACzC,+BAAiC;AAEjC,MAAM,aAAa,GAAG,IAAA,gBAAS,EAAC,wBAAQ,CAAC,CAAC;AAE1C,MAAM,wBAAwB,GAAG,IAAI,GAAG,IAAI,GAAG,GAAG,CAAC;AAEnD,MAAa,sBAAsB;IACjC,KAAK,CAAC,UAAU,CACd,OAAe,EACf,IAAc,EACd,OAAmC;QAMnC,MAAM,WAAW,GAAwC;YACvD,QAAQ,EAAE,MAAM;YAChB,SAAS,EAAE,wBAAwB;SACpC,CAAC;QACF,IAAI,OAAO,EAAE,GAAG,EAAE,CAAC;YACjB,WAAW,CAAC,GAAG,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QACvD,CAAC;QACD,IAAI,CAAC;YACH,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,aAAa,CAC5C,OAAO,EACP,IAAI,EACJ,WAAW,CACZ,CAAC;YACF,OAAO;gBACL,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;gBACtB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;gBACtB,QAAQ,EAAE,CAAC;aACZ,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IACE,KAAK;gBACL,OAAO,KAAK,KAAK,QAAQ;gBACzB,QAAQ,IAAI,KAAK;gBACjB,QAAQ,IAAI,KAAK;gBACjB,MAAM,IAAI,KAAK,EACf,CAAC;gBACD,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBACnC,OAAO,CAAC,KAAK,CACX,GAAG,OAAO,wCAAwC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CACvE,CAAC;gBACJ,CAAC;gBACD,OAAO;oBACL,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;oBAC5B,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;oBAC5B,QAAQ,EAAE,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;iBAC1D,CAAC;YACJ,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAlDD,wDAkDC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { NodeLocalCommandRunner } from './NodeLocalCommandRunner';
|
|
2
|
+
|
|
3
|
+
describe('NodeLocalCommandRunner large output', () => {
|
|
4
|
+
it('should keep the whole stdout when a command writes more than one mebibyte', async () => {
|
|
5
|
+
const runner = new NodeLocalCommandRunner();
|
|
6
|
+
const outputByteLength = 3 * 1024 * 1024;
|
|
7
|
+
|
|
8
|
+
const result = await runner.runCommand(process.execPath, [
|
|
9
|
+
'-e',
|
|
10
|
+
`process.stdout.write('x'.repeat(${outputByteLength}))`,
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
expect(result.exitCode).toBe(0);
|
|
14
|
+
expect(result.stdout.length).toBe(outputByteLength);
|
|
15
|
+
}, 30000);
|
|
16
|
+
});
|
|
@@ -34,6 +34,7 @@ describe('NodeLocalCommandRunner', () => {
|
|
|
34
34
|
});
|
|
35
35
|
expect(mockExecFileAsync).toHaveBeenCalledWith('echo', ['"test"'], {
|
|
36
36
|
encoding: 'utf8',
|
|
37
|
+
maxBuffer: 1024 * 1024 * 256,
|
|
37
38
|
});
|
|
38
39
|
});
|
|
39
40
|
|
|
@@ -71,6 +72,25 @@ describe('NodeLocalCommandRunner', () => {
|
|
|
71
72
|
});
|
|
72
73
|
});
|
|
73
74
|
|
|
75
|
+
it('should report the reason when the command did not exit with a numeric status', async () => {
|
|
76
|
+
const consoleErrorSpy = jest
|
|
77
|
+
.spyOn(console, 'error')
|
|
78
|
+
.mockImplementation(() => undefined);
|
|
79
|
+
const error = Object.assign(new Error('Command failed'), {
|
|
80
|
+
code: 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER',
|
|
81
|
+
stdout: 'truncated output',
|
|
82
|
+
stderr: '',
|
|
83
|
+
});
|
|
84
|
+
mockExecFileAsync.mockRejectedValue(error);
|
|
85
|
+
|
|
86
|
+
await runner.runCommand('osv-scanner', []);
|
|
87
|
+
|
|
88
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith(
|
|
89
|
+
'osv-scanner did not exit with a numeric status: ERR_CHILD_PROCESS_STDIO_MAXBUFFER',
|
|
90
|
+
);
|
|
91
|
+
consoleErrorSpy.mockRestore();
|
|
92
|
+
});
|
|
93
|
+
|
|
74
94
|
it('should throw error if error format is unexpected', async () => {
|
|
75
95
|
mockExecFileAsync.mockRejectedValue(new Error('Unexpected error'));
|
|
76
96
|
|
|
@@ -7,6 +7,8 @@ import { promisify } from 'util';
|
|
|
7
7
|
|
|
8
8
|
const execFileAsync = promisify(execFile);
|
|
9
9
|
|
|
10
|
+
const MAX_COMMAND_OUTPUT_BYTES = 1024 * 1024 * 256;
|
|
11
|
+
|
|
10
12
|
export class NodeLocalCommandRunner implements LocalCommandRunner {
|
|
11
13
|
async runCommand(
|
|
12
14
|
program: string,
|
|
@@ -19,6 +21,7 @@ export class NodeLocalCommandRunner implements LocalCommandRunner {
|
|
|
19
21
|
}> {
|
|
20
22
|
const execOptions: Parameters<typeof execFileAsync>[2] = {
|
|
21
23
|
encoding: 'utf8',
|
|
24
|
+
maxBuffer: MAX_COMMAND_OUTPUT_BYTES,
|
|
22
25
|
};
|
|
23
26
|
if (options?.env) {
|
|
24
27
|
execOptions.env = { ...process.env, ...options.env };
|
|
@@ -42,6 +45,11 @@ export class NodeLocalCommandRunner implements LocalCommandRunner {
|
|
|
42
45
|
'stderr' in error &&
|
|
43
46
|
'code' in error
|
|
44
47
|
) {
|
|
48
|
+
if (typeof error.code !== 'number') {
|
|
49
|
+
console.error(
|
|
50
|
+
`${program} did not exit with a numeric status: ${String(error.code)}`,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
45
53
|
return {
|
|
46
54
|
stdout: String(error.stdout),
|
|
47
55
|
stderr: String(error.stderr),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeLocalCommandRunner.d.ts","sourceRoot":"","sources":["../../../src/adapter/repositories/NodeLocalCommandRunner.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EAC1B,MAAM,6DAA6D,CAAC;
|
|
1
|
+
{"version":3,"file":"NodeLocalCommandRunner.d.ts","sourceRoot":"","sources":["../../../src/adapter/repositories/NodeLocalCommandRunner.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EAC1B,MAAM,6DAA6D,CAAC;AAQrE,qBAAa,sBAAuB,YAAW,kBAAkB;IACzD,UAAU,CACd,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC;QACT,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CAyCH"}
|