Skip to content

Commit

Permalink
Allow for larger forms to create csv exports
Browse files Browse the repository at this point in the history
  • Loading branch information
lachko committed Oct 9, 2024
1 parent 019f8ac commit f84315d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ function generateCsv(dbName, formId, outputPath, year = '*', month = '*', csvTem
}
cmd = `${cmd} ${csvTemplate ? `"${csvTemplate.headers.join(',')}"` : ''}`
log.debug("generate-csv: " + cmd)
exec(cmd).then(status => {
const maxBuffer = 1024 * 1024 * 100;
exec(cmd, { maxBuffer }).then(status => {

Check failure

Code scanning / CodeQL

Uncontrolled command line Critical

This command line depends on a
user-provided value
.
resolve(status)
}).catch(error => {
log.error("Error when exec-ing generate-csv: " + error)
Expand Down
4 changes: 3 additions & 1 deletion server/src/scripts/generate-csv/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ async function go(state) {
// Run batches.
while (state.complete === false) {
log.debug(`Run batch at skip of ${state.skip} at statePath: ${state.statePath}`)
const response = await exec(`./batch.js '${state.statePath}'`)
const maxBuffer = 1024 * 1024 * 100; // 100MB
const response = await exec(`./batch.js '${state.statePath}'`, { maxBuffer });

if (response.stderr) console.error(response.stderr)
if (process.env.NODE_ENV === 'development') console.log(response)
state = JSON.parse(await readFile(state.statePath))
Expand Down

0 comments on commit f84315d

Please sign in to comment.