Conversation
## Because
- CodeQL flagged four `execAsync` calls in `bulk-mailer.in.spec.ts`. Each one builds a shell command from a `__dirname`-derived path.
- A path with characters the shell treats specially can change what the command does.
## This pull request
- Replaces `promisify(cp.exec)` with `promisify(cp.execFile)` and adds a `runScript(args)` helper. The script and its options go through as an argument array, so no value reaches a shell.
- Captures the `dump-users` output from stdout and writes `user_dump.json` with `fs`. `execFile` has no shell, so the old `>` redirect is gone. The dump is parsed before it is written, so a short read fails in `beforeAll` instead of confusing a later test.
- Raises `maxBuffer` to 10 MB, because script output now comes back through a pipe instead of going straight to disk.
- Passes the real `USER_DUMP_PATH` in the two `--method` tests. They used single quotes, so the script got the literal text `${USER_DUMP_PATH}` as its input path. Both still fail for the reason their names give.
## Issue that this pull request solves
Closes: https://mozilla-hub.atlassian.net/browse/FXA-13670
Contributor
There was a problem hiding this comment.
Pull request overview
Replaces shell-based bulk-mailer test execution with argument-safe execFile calls.
Changes:
- Adds a shared shell-free script runner.
- Captures, validates, and writes the user dump explicitly.
- Corrects test arguments to use the actual dump path.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Because
execAsynccalls inbulk-mailer.in.spec.ts. Each one builds a shell command from a__dirname-derived path.This pull request
promisify(cp.exec)withpromisify(cp.execFile)and adds arunScript(args)helper. The script and its options go through as an argument array, so no value reaches a shell.dump-usersoutput from stdout and writesuser_dump.jsonwithfs.execFilehas no shell, so the old>redirect is gone. The dump is parsed before it is written, so a short read fails inbeforeAllinstead of confusing a later test.maxBufferto 10 MB, because script output now comes back through a pipe instead of going straight to disk.USER_DUMP_PATHin the two--methodtests. They used single quotes, so the script got the literal text${USER_DUMP_PATH}as its input path. Both still fail for the reason their names give.Issue that this pull request solves
Closes: https://mozilla-hub.atlassian.net/browse/FXA-13670
Checklist
Put an
xin the boxes that applyHow to review (Optional)
packages/fxa-auth-server/test/scripts/bulk-mailer.in.spec.ts.runScripthelper, thenbeforeAll, then the six call sites.beforeAlldump. It is the only site that lost a shell redirect. Check thatuser_dump.jsonstill lands before the tests that read it.Screenshots (Optional)
None. There is no user interface change.
Other information (Optional)
scriptsJest project matchestest/scripts/**/*.in.spec.ts, and CircleCI runs thetest-scriptstarget.npx nx lint fxa-auth-serverexits 0.fxa-auth-serverunit suite reports 3758 passed and 13 failed. The same 13 fail on a pristine tree, inlib/routes/account.spec.tsandconfig/index.spec.ts. The unit Jest project ignores*.in.spec.ts, so it never loads the changed file.