From f0748c45d2bf8a8182d2f6894e6b81e038e9e25c Mon Sep 17 00:00:00 2001 From: Andriy Romanov Date: Sun, 8 Oct 2023 15:13:05 -0700 Subject: [PATCH] feat: Add ability to set maxBuffer parameter for spawnSync while executing checkov (#9) Co-authored-by: Andriy Romanov --- README.md | 4 ++++ src/utils.ts | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f89c4ea..2a9bec1 100644 --- a/README.md +++ b/README.md @@ -89,3 +89,7 @@ new CheckovValidator({ skipCheck: ['CKV_AWS_18', 'CKV_AWS_21'], }); ``` + +### Troubleshooting + +If you are getting `Error: spawnSync checkov ENOBUFS` error, please try to set `CHECKOV_MAX_BUFFER_SIZE_MB` environment variable to numeric value above 1. It's setting `maxBuffer` parameter for `spawnSync` [function](https://nodejs.org/api/child_process.html#child_processspawnsynccommand-args-options) under the hood. diff --git a/src/utils.ts b/src/utils.ts index cf05740..083719c 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -12,6 +12,7 @@ export function exec(commandLine: string[], options: { cwd?: string; json?: bool ...options.env, }, cwd: options.cwd, + maxBuffer: 1024 * 1024 * (parseInt(process.env['CHECKOV_MAX_BUFFER_SIZE_MB']) || 1), }); if (proc.error) { throw proc.error; } @@ -37,4 +38,4 @@ export function exec(commandLine: string[], options: { cwd?: string; json?: bool console.error('Not JSON: ' + output); throw new Error('Command output is not JSON'); } -} \ No newline at end of file +}