Skip to content

[change_lister] Validate inputs and handle rev-parse error#478

Merged
sai-miduthuri merged 4 commits intomainfrom
sai-miduthuri/fix/prevent-git-flag-injection
Apr 1, 2026
Merged

[change_lister] Validate inputs and handle rev-parse error#478
sai-miduthuri merged 4 commits intomainfrom
sai-miduthuri/fix/prevent-git-flag-injection

Conversation

@sai-miduthuri
Copy link
Copy Markdown
Contributor

Issue

change_lister doesn't verify remote and branch inputs

Fix

  • Add new constructor helper function to handle input validation
  • Handle the error from git rev-parse --is-shallow-repository instead of silently discarding it, so environment misconfigurations surface clearly.

sai-miduthuri and others added 2 commits April 1, 2026 10:24
Add validation that Remote and BaseBranch don't start with "-" to
prevent potential git flag injection. Handle the error from
`git rev-parse --is-shallow-repository` instead of silently discarding
it, so environment misconfigurations surface clearly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ruct

Move GitChangeLister to unexported gitChangeLister with a
newGitChangeLister constructor that validates inputs using regex
allowlists: remote and baseBranch must match [a-zA-Z0-9._/-], commit
must be a 4-40 character hex hash. This prevents git flag injection
via crafted branch names or commit values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the GitChangeLister into an unexported gitChangeLister struct and introduces a newGitChangeLister constructor that validates the remote, base branch, and commit hash using regular expressions. It also adds error handling for the shallow repository check and updates associated tests. Feedback was provided to change the variable declaration of the lister in main.go from a concrete pointer to the ChangeLister interface to avoid "typed nil" interface issues, which can lead to unexpected behavior when checking for nil.

Comment thread raycicmd/main.go Outdated
sai-miduthuri and others added 2 commits April 1, 2026 11:44
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Sai Miduthuri <sai.miduthuri@anyscale.com>
Copy link
Copy Markdown
Contributor

@andrew-anyscale andrew-anyscale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were you encountering errors somewhere?

@sai-miduthuri
Copy link
Copy Markdown
Contributor Author

No, I wasn't encountering any errors outside of the ones fixed by your previous PR. I realized that there were some non-urgent bugs in the code as a part of my review there.

@sai-miduthuri sai-miduthuri merged commit c6680a8 into main Apr 1, 2026
2 checks passed
@sai-miduthuri sai-miduthuri deleted the sai-miduthuri/fix/prevent-git-flag-injection branch April 1, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants