-
Notifications
You must be signed in to change notification settings - Fork 167
fix(consume): consume_direct.sh
files contained invalid commands because value after --filter
flag was not enclosed in parenthesis (issue reported by flcl42)
#1987
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,13 +55,26 @@ def _consume_debug_dump( | |
result: subprocess.CompletedProcess, | ||
debug_output_path: Path, | ||
): | ||
consume_direct_call = " ".join(command) | ||
# ensure that the --filter flag value is wrapped in parentheses | ||
consume_direct_call = "" | ||
prev_command_was_filter_flag = False | ||
for s in command: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Afaik, all parameters that contain spaces need to be enclosed in double-quotes, not only the ones after filter, and not only for the nethermind commands. Should we look into pre-processing the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A quick gpt-query yields that we should use import shlex
args = ["my command", "--option", "value with spaces", "file$(rm -rf /)"]
command = " ".join(shlex.quote(arg) for arg in args)
print(command) Output: 'my command' --option 'value with spaces' 'file$(rm -rf /)' And There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have not heard of shlex before, so I think it will be harder to read the code if someone sees We could add pre-processing to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Working on this takes me longer than expected because I can't get logging to work for some reason. Edit: found temporary workaround There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Just for clarification, they are part of the test names, not file names, this is a pytest intrinsic issue.
This will end up in a
That's true, I haven't heard of it before but (a) this is deep into the weeds of the code anyway, I would be more concerned if this was part of a test, and (b) it's really easy to look it up. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah good point with the |
||
if prev_command_was_filter_flag: | ||
if s[0] != '"': | ||
s = '"' + s + '"' | ||
prev_command_was_filter_flag = False | ||
consume_direct_call += s + " " | ||
if s.strip() == "--filter": | ||
prev_command_was_filter_flag = True | ||
consume_direct_call = consume_direct_call.strip() | ||
|
||
consume_direct_script = textwrap.dedent( | ||
f"""\ | ||
#!/bin/bash | ||
{consume_direct_call} | ||
""" | ||
) | ||
|
||
dump_files_to_directory( | ||
str(debug_output_path), | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.