-
Notifications
You must be signed in to change notification settings - Fork 259
virttest/staging/lv_utils: ignore warnings #4273
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: master
Are you sure you want to change the base?
Conversation
WalkthroughThe function Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
virttest/staging/lv_utils.py(2 hunks)
🧰 Additional context used
🪛 GitHub Actions: CI
virttest/staging/lv_utils.py
[error] 463-463: Black formatting would reformat /home/runner/work/avocado-vt/avocado-vt/virttest/staging/lv_utils.py. Run 'black' to format the file.
🪛 Ruff (0.14.5)
virttest/staging/lv_utils.py
453-453: Function call with shell=True parameter identified, security issue
(S604)
🔇 Additional comments (2)
virttest/staging/lv_utils.py (2)
51-51: LGTM!The import is necessary for the refactored
get_vg_mapped_blk_targetfunction.
452-453: Shell usage is safe here.The static analysis warning about
shell=Trueis a false positive in this case, as the command is hardcoded with no user-controlled input.
ff3db62 to
36a0fa5
Compare
|
The following test case failed due to the given description with "ERROR: list index out of range" but passes now with this change: |
36a0fa5 to
488e04d
Compare
The current implementation filters the data through grep. However, in some cases a warning message might be displayed, such as """ File descriptor 3 (/dev/z90crypt) leaked on pvs invocation. Parent PID 5118: -bash """ While this is a valuable piece of information, the test case shouldn't break on it if the command succeeds and the necessary information is found in the output; the function focuses on identifying the blk target. So, instead, read the pvs output and identify error conditions (command failure, empty output). If these are not given, identify the relevant parts as before from those output lines, that is the code does the filtering, not grep. Signed-off-by: Sebastian Mitterle <smitterl@redhat.com>
488e04d to
7d61c4d
Compare
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.
Actionable comments posted: 0
♻️ Duplicate comments (1)
virttest/staging/lv_utils.py (1)
451-477: Tighten VG matching and device-name regex to avoid incorrect blk target resolution.The overall restructuring (status check, empty-output handling, line‑by‑line parsing) is a solid improvement, but two details can still cause subtle bugs:
if vg_name in line:can match unintended VGs (e.g. searching forrhelwill also matchrhel-test).re.findall(r"[a-z]+", ...)only matches lowercase letters and may fail or misbehave for mixed/uppercase device names.You can make this more robust by matching the VG column exactly and broadening the regex, e.g.:
- for line in lines[1:]: - if vg_name in line: - parts = line.split() - if parts: - pv_name = parts[0] - try: - blk_target = re.findall(r"[a-z]+", pv_name.split("/dev/")[1])[0] - break - except (IndexError, AttributeError): - continue + for line in lines[1:]: + parts = line.split() + # Expect columns like: PV VG Fmt Attr PSize PFree + if len(parts) >= 2 and parts[1] == vg_name: + pv_name = parts[0] + try: + blk_target = re.findall(r"[a-zA-Z]+", pv_name.split("/dev/")[1])[0] + break + except (IndexError, AttributeError): + continueThis keeps the new parsing approach but avoids false positives and case-related issues when resolving the block target.
🧹 Nitpick comments (1)
virttest/staging/lv_utils.py (1)
451-453: Ruff S604 onshell=True: safe here but worth documenting/guarding.
utils_misc.cmd_status_output(cmd, shell=True, session=session)is invoked with a constantcmd = "pvs", so command injection risk is effectively nil, but Ruff still reports S604 forshell=True.If you expect
cmdto stay a fixed literal, I'd either:
- Keep this as‑is and add a short comment explaining that
cmdis constant (or annotate with the project’s preferred “ignore S604” mechanism), or- Refactor later to pass an argument list with
shell=Falseifutils_miscsupports it.This is low priority but will help future readers and static analysis if
cmdever becomes parameterized.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
spell.ignore(1 hunks)virttest/staging/lv_utils.py(2 hunks)
🧰 Additional context used
🪛 Ruff (0.14.6)
virttest/staging/lv_utils.py
452-452: Function call with shell=True parameter identified, security issue
(S604)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Static checks
🔇 Additional comments (2)
spell.ignore (1)
59-60: LVM column names correctly added to spell-ignore list.Adding
PFreeandPSizehere matchespvscolumn headers and avoids false positives in spell checking; no further changes needed.virttest/staging/lv_utils.py (1)
50-50: Import ofutils_miscis appropriate and required.The added
utils_miscimport is correctly scoped and used byget_vg_mapped_blk_target; no issues here.
The current implementation filters the data through grep. However, in some cases a warning message might be displayed, such as
"""
File descriptor 3 (/dev/z90crypt) leaked on pvs invocation. Parent PID 5118: -bash """
While this is a valuable piece of information, the test case shouldn't break on it if the command succeeds and the necessary information is found in the output; the function focuses on identifying the blk target.
So, instead, read the pvs output and identify error conditions (command failure, empty output). If these are not given, identify the relevant parts as before from those output lines, that is the code does the filtering, not grep.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.