Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/fosslight_dependency/package_manager/Go.py`:
- Around line 74-79: In run_plugin(), the block that captures `ret_cmd_tree =
subprocess.check_output(cmd_tree, shell=True, text=True, encoding='utf-8')`
incorrectly checks `if ret_cmd_tree != 0:` and swallows subprocess failures;
change the condition to check for a non-empty string (e.g., `if ret_cmd_tree:`)
and call `self.parse_dependency_tree(ret_cmd_tree)` only then, and additionally
catch subprocess.CalledProcessError (or set `ret = False` in the except block)
so that when `subprocess.check_output` fails the method records failure instead
of leaving `ret` unchanged; update the exception logging in run_plugin() to
include the exception details and ensure `ret` is set to False when
parse/command execution fails so callers see the correct failure state.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: dd74e3eb-2f99-42a7-a753-e55bf0fade22
📒 Files selected for processing (1)
src/fosslight_dependency/package_manager/Go.py
| try: | ||
| ret_cmd_tree = subprocess.check_output(cmd_tree, shell=True, text=True, encoding='utf-8') | ||
| if ret_cmd_tree != 0: | ||
| self.parse_dependency_tree(ret_cmd_tree) | ||
| except Exception as e: | ||
| logger.warning(f"Failed to run '{cmd_tree}': {e}") |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
According to Python documentation, what does subprocess.check_output return when text=True, and what exception is raised when the command exits with a non-zero status?
💡 Result:
According to the Python documentation, subprocess.check_output with text=True returns the stdout of the executed command as a string if the command exits with a zero status. If the command exits with a non-zero status, it raises subprocess.CalledProcessError.
Citations:
- 1: https://docs.python.org/3/library/subprocess.html
- 2: https://docs.python.org/3.12/library/subprocess.html
- 3: https://docs.python.org/release/3.10.10/library/subprocess.html
- 4: https://docs.python.org/3.13/library/subprocess.html
- 5: https://docs.python.org/library/subprocess.html
- 6: https://github.com/python/cpython/blob/main/Doc/library/subprocess.rst
Fix go mod graph failure handling in run_plugin().
At line 76, ret_cmd_tree is a string returned by subprocess.check_output(..., text=True), so the condition if ret_cmd_tree != 0: is incorrect and should check for a non-empty string instead.
At line 79, when an exception occurs, the code only logs a warning and leaves ret unchanged. Since subprocess.check_output() raises CalledProcessError on non-zero exit, the failure is silently ignored and the function still returns success.
Proposed fix
cmd_tree = "go mod graph"
try:
ret_cmd_tree = subprocess.check_output(cmd_tree, shell=True, text=True, encoding='utf-8')
- if ret_cmd_tree != 0:
+ if ret_cmd_tree:
self.parse_dependency_tree(ret_cmd_tree)
- except Exception as e:
+ except subprocess.CalledProcessError as e:
+ logger.error(f"Failed to run '{cmd_tree}': {e}")
+ ret = False
+ except Exception as e:
logger.error(f"Failed to run '{cmd_tree}': {e}")
+ ret = False🧰 Tools
🪛 Ruff (0.15.9)
[error] 75-75: subprocess call with shell=True identified, security issue
(S602)
[warning] 78-78: Do not catch blind exception: Exception
(BLE001)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/fosslight_dependency/package_manager/Go.py` around lines 74 - 79, In
run_plugin(), the block that captures `ret_cmd_tree =
subprocess.check_output(cmd_tree, shell=True, text=True, encoding='utf-8')`
incorrectly checks `if ret_cmd_tree != 0:` and swallows subprocess failures;
change the condition to check for a non-empty string (e.g., `if ret_cmd_tree:`)
and call `self.parse_dependency_tree(ret_cmd_tree)` only then, and additionally
catch subprocess.CalledProcessError (or set `ret = False` in the except block)
so that when `subprocess.check_output` fails the method records failure instead
of leaving `ret` unchanged; update the exception logging in run_plugin() to
include the exception details and ensure `ret` is set to False when
parse/command execution fails so callers see the correct failure state.
…talled Signed-off-by: woocheol <jayden6659@gmail.com>
Description
Show fail message when manifest is found but go is not installed
Summary by CodeRabbit