Skip to content

Commit

Permalink
feat: Add ability to set maxBuffer parameter for spawnSync while exec…
Browse files Browse the repository at this point in the history
…uting checkov (#9)

Co-authored-by: Andriy Romanov <aromanov@diligent.com>
  • Loading branch information
Andriy Romanov and Andriy Romanov committed Oct 8, 2023
1 parent d328357 commit f0748c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
3 changes: 2 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -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');
}
}
}

0 comments on commit f0748c4

Please sign in to comment.