-
Notifications
You must be signed in to change notification settings - Fork 95
Dev: ui_resource: Refactor do_trace function #1709
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
Dev: ui_resource: Refactor do_trace function #1709
Conversation
0246fa5 to
6f149cd
Compare
511b29e to
5bf8df2
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
c80ba6f to
ee920d1
Compare
crmsh/utils.py
Outdated
| """ | ||
| source a script and get the value of a variable | ||
| """ | ||
| cmd = f"source {script_path} && echo ${var_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.
DANGEROUS:
- Sourcing a script is vulnerable to shell injection.
script_pathandvar_nameis not quoted.
Although it is safe when sourcing trusted code, this should not be defined as a common utility function.
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.
How about:
| cmd = f"source {script_path} && echo ${var_name}" | |
| cmd = ['/bin/bash', '-c', f'source {script_path} && echo ${var_name}'] | |
| rc, out, _ = ShellUtils().get_stdout_stderr(cmd, shell=False) |
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 agree Nicholas for the security risk, and not to source the script. Instead, it is safe for the use case to directly use python re to parse {HA_VARLIB:=/var/lib/heartbeat}.
If "rpm -ql resource-agents" is not available, then crmsh falls back to the hard code of /usr/lib/ocf/lib/heartbeat/ocf-directories.
ee920d1 to
71d0bdb
Compare
71d0bdb to
b1cd65f
Compare
b1cd65f to
320b795
Compare
Ensure the trace directory is specified either through the argument or by using the value of the heartbeat_dir option. Eliminate any inconsistencies that might arise from heartbeat_dir (from etc/crm/crm.conf) or from HA_VARLIB (from /usr/lib/ocf/heartbeat/ocf-directories).
320b795 to
7b8e201
Compare
Ensure the trace directory is specified either through the argument or by using the value of the heartbeat_dir option. Eliminate any inconsistencies that might arise from heartbeat_dir (from etc/crm/crm.conf) or from HA_VARLIB (from /usr/lib/ocf/heartbeat/ocf-directories).