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

NC | remove input from spawn options print and fix exec test #8133

Merged

Conversation

romayalon
Copy link
Contributor

Explain the changes

  1. Omit input from spawn - input contains the master key json
  2. Try fixing unit test that failed inconsistently by first reading stdin to temp file and then check if a file exists -
    The failure was on NC master key manager tests - exec store type › _create_master_keys_exec when master keys exist test and the error was -
 
write EPIPE
130 |         const return_stdout = options.return_stdout;
131 |         const proc = child_process.spawn(command, args, options);
> 132 |         if (options.input) proc.stdin.end(options.input);
|                                       ^
133 |         let stdout = return_stdout ? '' : undefined;
134 |         if (return_stdout) {
135 |             proc.stdout.on('data', data => {

at end (src/util/os_utils.js:132:39)
at Object.spawn (src/util/os_utils.js:125:12)
at NCMasterKeysManager.spawn [as _create_master_keys_exec] (src/manage_nsfs/nc_master_key_manager.js:217:55)
at Object._create_master_keys_exec (src/test/unit_tests/jest_tests/test_nc_master_keys_exec.test.js:120:31)

I couldn't reproduce it locally, the base assumption of this fix, is that on fput script of these tests, when there is already an existing master_keys.json file, we will first check if the file exists and return VERSION_MISMATCH if it exists, else we will write the input into the file. When first returning without reading the input at the beginning we might result with EPIPE, where we didn't have a chance to write the data to stdin.

Issues: Fixed #xxx / Gap #xxx

Testing Instructions:

  • Doc added/updated
  • Tests added

Signed-off-by: Romy <35330373+romayalon@users.noreply.github.com>
Copy link
Member

@guymguym guymguym left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@romayalon This fix is good, but perhaps for such a sensitive input string we better wrap it in SensitiveString so that we don't accidentally print it elsewhere.

@romayalon romayalon merged commit a1a5e58 into noobaa:master Jun 13, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants