fix(github): validate repo URL path for scoping#2514
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces enhanced validation for repository URLs, specifically targeting GitHub repositories. The primary goal is to enforce a consistent Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
🔍 PR Lint Feedback
|
There was a problem hiding this comment.
Code Review
This pull request introduces validation for GitHub repository URLs to ensure they follow the org/repo format, applied in the admission webhook and during GitHub token scoping. While the webhook validation is well-designed, the implementation in pkg/provider/github/scope.go is overly strict, leading to a Denial of Service (DoS) vulnerability. This allows a single malformed or non-GitHub repository to break CI/CD pipelines for all GitHub repositories in a shared namespace. To prevent regressions in multi-Git provider environments and mitigate the DoS risk, it is recommended to modify the logic to skip non-conforming repositories during the scoping process instead of returning a terminal error.
ee6f8bd to
7c6069c
Compare
54d2be1 to
15b4238
Compare
f36aa55 to
4563b52
Compare
|
|
4563b52 to
2be49fd
Compare
2be49fd to
1c6db5f
Compare
|
/gemini review |
Reject Repository CRs with malformed GitHub URLs that include extra path segments (e.g., https://github.com/org/repo/extra). These URLs previously passed admission and were truncated during token scoping, allowing bypass of namespace guards. Add GitHub Enterprise detection to accurately validate repository URLs. Detects GHE via Server header and /api/v3/meta endpoint, then enforces org/repo format without additional path segments. This prevents malformed URLs during admission and token scoping. Fixes: tektoncd#2395 Jira: https://issues.redhat.com/browse/SRVKP-10943 Signed-off-by: Akshay Pant <akpant@redhat.com>
ee25de6 to
3aceb05
Compare
|
/lgtm |
There was a problem hiding this comment.
Congrats @theakshaypant your PR Has been approved 🎉
✅ Pull Request Approved
Approval Status:
- Required Approvals: 1
- Current Approvals: 1
👥 Reviewers Who Approved:
| Reviewer | Permission Level | Approval Status |
|---|---|---|
| @zakisk | write |
✅ |
📝 Next Steps
- Ensure all required checks pass
- Comply with branch protection rules
- Request a maintainer to merge using the
/mergecommand (or merge it
directly if you have repository permission).
Automated by the PAC Boussole 🧭
📝 Description of the Change
Reject Repository CRs with malformed GitHub URLs that include extra
path segments (e.g., https://github.com/org/repo/extra). These URLs
previously passed admission and were truncated during token scoping,
allowing bypass of namespace guards.
Add GitHub Enterprise detection to accurately validate repository
URLs. Detects GHE via Server header and /api/v3/meta endpoint,
then enforces org/repo format without additional path segments.
This prevents malformed URLs during admission and token scoping.
👨🏻 Linked Jira
Jira: https://issues.redhat.com/browse/SRVKP-10943
🔗 Linked GitHub Issue
Fixes #2395
🚀 Type of Change
fix:)feat:)feat!:,fix!:)docs:)chore:)refactor:)enhance:)deps:)🧪 Testing Strategy
🤖 AI Assistance
If you have used AI assistance, please provide the following details:
Which LLM was used?
Extent of AI Assistance:
Important
If the majority of the code in this PR was generated by an AI, please add a
Co-authored-bytrailer to your commit message.For example:
Co-authored-by: Gemini gemini@google.com
Co-authored-by: ChatGPT noreply@chatgpt.com
Co-authored-by: Claude noreply@anthropic.com
Co-authored-by: Cursor noreply@cursor.com
Co-authored-by: Copilot Copilot@users.noreply.github.com
**💡You can use the script
./hack/add-llm-coauthor.shto automatically addthese co-author trailers to your commits.
✅ Submitter Checklist
fix:,feat:) matches the "Type of Change" I selected above.make testandmake lintlocally to check for and fix anyissues. For an efficient workflow, I have considered installing
pre-commit and running
pre-commit installtoautomate these checks.