🔒 Fix argument injection vulnerability in get_pr_status#368
Conversation
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds validation to ensure PR IDs passed to get_pr_status are strictly numeric before invoking the gh CLI, and introduces a unit test to cover invalid PR ID behavior and error messaging. Sequence diagram for validated get_pr_status invocationsequenceDiagram
actor Developer
participant get_pr_status
participant GhCLI
Developer->>get_pr_status: get_pr_status(pr_id)
get_pr_status->>get_pr_status: [pr_id]
alt [pr_id is numeric]
get_pr_status->>GhCLI: gh pr view pr_id --json state,reviewDecision,statusCheckRollup
else [pr_id is not numeric]
get_pr_status->>get_pr_status: print(Error: Invalid PR ID format. Must be numeric.)
get_pr_status-->>Developer: sys.exit(1)
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Warning Review limit reached
Next review available in: 49 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe script now rejects non-numeric optional PR IDs with an error and exit code 1. A test verifies the exit status and stderr message. ChangesPR ID validation
Estimated code review effort: 1 (Trivial) | ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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.
Hey - I've left some high level feedback:
- Using
str(pr_id).isdigit()will reject some potentially valid inputs (e.g., strings with surrounding whitespace or non-decimal numeric formats); consider normalizing the input (strip whitespace, explicit type check) before validating to avoid surprising failures. - Since
get_pr_statusis a callable function rather than just a CLI entrypoint, it may be more flexible to raise a specific exception instead of callingsys.exit(1), letting callers decide how to handle invalid PR IDs.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Using `str(pr_id).isdigit()` will reject some potentially valid inputs (e.g., strings with surrounding whitespace or non-decimal numeric formats); consider normalizing the input (strip whitespace, explicit type check) before validating to avoid surprising failures.
- Since `get_pr_status` is a callable function rather than just a CLI entrypoint, it may be more flexible to raise a specific exception instead of calling `sys.exit(1)`, letting callers decide how to handle invalid PR IDs.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
f2d2d0f to
a68f56b
Compare
Co-authored-by: sheepdestroyer <1377479+sheepdestroyer@users.noreply.github.com>
a68f56b to
fa2f081
Compare
🎯 What: Fixed an argument injection vulnerability in scripts/get_pr_status.py when passing the pr_id argument to the gh CLI.\n⚠️ Risk: An attacker could execute arbitrary flags on the gh CLI if an invalid input was passed to the get_pr_status function.\n🛡️ Solution: Added a .isdigit() check to pr_id to explicitly verify that the PR ID format is numeric before appending it to the gh command arguments, otherwise it will exit with an error. Added unit tests for this case.
PR created automatically by Jules for task 7664865179964863263 started by @sheepdestroyer
Summary by Sourcery
Validate PR ID format in get_pr_status before invoking gh CLI to prevent unsafe argument injection.
Bug Fixes:
Tests:
Summary by CodeRabbit