-
Notifications
You must be signed in to change notification settings - Fork 689
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
Service validator vul #3717
base: master
Are you sure you want to change the base?
Service validator vul #3717
Conversation
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
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.
LGTM
def _service_restart(svc_name): | ||
rc = os.system(f"systemctl restart {svc_name}") | ||
rc = run_command(['systemctl', 'restart', svc_name]) |
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.
I think simply replace os.system
with subprocess.call
, as suggested in python doc https://docs.python.org/3/library/subprocess.html#replacing-os-system, no need to introduce new function run_command
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.
Yes, Done!
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
43c0b2d
to
59956dc
Compare
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
LGTM |
What I did
"os.system()" uses shell invocation to execute command which is dangerous. without a static string that can lead to command injection.
How I did it
pass use list of strings to subprocess() - use shell=False instead.
How to verify it
pass UT
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)