-
Notifications
You must be signed in to change notification settings - Fork 666
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
[show][mlnx] replace shell=True, replace xml #2700
Conversation
Signed-off-by: maipbui <maibui@microsoft.com>
show/plugins/mlnx.py
Outdated
@@ -46,9 +46,9 @@ def run_command(command, display_cmd=False, ignore_error=False, print_to_console | |||
"""Run bash command and print output to stdout | |||
""" | |||
if display_cmd == True: | |||
click.echo(click.style("Running command: ", fg='cyan') + click.style(command, fg='green')) | |||
click.echo(click.style("Running command: ", fg='cyan') + click.style(' '.join(command), fg='green')) |
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.
Signed-off-by: maipbui <maibui@microsoft.com>
/azp run Azure.sonic-utilities |
Azure Pipelines successfully started running 1 pipeline(s). |
@stepanblyschak @dprital Could you help review? |
@stepanblyschak @dprital could you help review? |
/azp run Azure.sonic-utilities |
Azure Pipelines successfully started running 1 pipeline(s). |
@keboliu could you help review? |
could you please also provide the test result of command "show platform mlnx sniffer"? |
I added in the PR description
|
@keboliu could you check PR description and review PR? |
Signed-off-by: maipbui <maibui@microsoft.com> #### What I did `subprocess()` - when using with `shell=True` is dangerous. Using subprocess function without a static string can lead to command injection. #### How I did it `subprocess()` - use `shell=False` instead, use list of strings Ref: [https://semgrep.dev/docs/cheat-sheets/python-command-injection/#mitigation](https://semgrep.dev/docs/cheat-sheets/python-command-injection/#mitigation) #### How to verify it Add UT Manual test ``` admin@***:~$ show platform mlnx issu ISSU is enabled admin@***:~$ show platform mlnx sniffer sdk sniffer is disabled ```
Signed-off-by: maipbui maibui@microsoft.com
What I did
subprocess()
- when using withshell=True
is dangerous. Using subprocess function without a static string can lead to command injection.How I did it
subprocess()
- useshell=False
instead, use list of strings Ref: https://semgrep.dev/docs/cheat-sheets/python-command-injection/#mitigationHow to verify it
Add UT
Manual test
Previous command output (if the output of a command-line utility has changed)
New command output (if the output of a command-line utility has changed)