Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add ability to set maxBuffer parameter for spawnSync while executing checkov #9

Merged
merged 1 commit into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
}
}
}