Skip to content

Auto approve access request to Hellosource and Helloaggregate - #87

Open
iambibhas wants to merge 3 commits into
mainfrom
hello-access-requests
Open

Auto approve access request to Hellosource and Helloaggregate#87
iambibhas wants to merge 3 commits into
mainfrom
hello-access-requests

Conversation

@iambibhas

Copy link
Copy Markdown
Collaborator

Description

Brief description of what this PR does.

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🔧 Refactoring (no functional changes)
  • ⚡ Performance improvement
  • 🧪 Test addition or improvement
  • 🔨 Build/CI changes

Related Issues

Fixes #(issue number)

Testing

  • Unit tests pass (make test)
  • Linting passes (make lint)
  • Manual testing completed
  • Coverage maintained or improved

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 a new automated validation rule for access requests in the helloaggregate and hellosource data products. The goal is to streamline the approval process by automatically validating the consistency between file paths and YAML content, while ensuring that any non-compliant or unrelated changes in a pull request are correctly flagged for manual review. This change improves development velocity while maintaining strict security and governance standards.

Highlights

  • New Validation Rule: Implemented a new hello_access_request rule to automate the approval process for access requests within the helloaggregate and hellosource data products.
  • Configuration Updates: Updated rules.yaml to include the new rule and registered it in the rule registry to ensure it is correctly invoked during pull request validation.
  • Comprehensive Testing: Added extensive E2E test scenarios to verify auto-approval logic, handle name/path mismatches, and ensure manual review is triggered for invalid or uncovered files.
  • Documentation: Added a new skill guide for creating Naysayer rules to assist future development and maintenance.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the 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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. 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.


A rule for the access is set, To check all the YAMLs we get. If names match the path, We avoid manual wrath, And approve with no need to fret.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Signed-off-by: Bibhas Debnath <bdebnath@redhat.com>
@iambibhas
iambibhas force-pushed the hello-access-requests branch from a0cb1f6 to d71fd84 Compare May 21, 2026 08:36

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

Copy link
Copy Markdown
Contributor

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 introduces the hello_access_request rule to the Naysayer validation engine, enabling auto-approval for specific access request YAML files associated with the helloaggregate and hellosource data products. The changes include the core rule logic, registry integration, configuration updates in rules.yaml, a comprehensive suite of E2E test scenarios, and a new Cursor skill for rule creation. Feedback from the review highlights a security concern regarding file renames, suggesting that both source and destination paths be validated. Other recommendations include using case-insensitive comparisons for usernames, optimizing performance by caching MR context checks to avoid $O(N^2)$ complexity, and adopting a more generic category name in the registry for better consistency.

Comment on lines +150 to +161
for _, change := range mrCtx.Changes {
path := change.NewPath
if path == "" {
path = change.OldPath
}
if path == "" {
continue
}
if !r.isAccessRequestFile(path) {
return "MR contains files outside allowed access-request paths: " + path
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

security-high high

The current logic only checks either NewPath or OldPath (preferring NewPath). In the case of a file rename or move, this could allow a sensitive file to be moved into an access-request path and thus be deleted from its original location without manual review. To ensure the MR contains only access requests, both the source and destination paths of every change must be validated. Additionally, validation functions should collect all errors instead of returning early on the first failure.

Suggested change
for _, change := range mrCtx.Changes {
path := change.NewPath
if path == "" {
path = change.OldPath
}
if path == "" {
continue
}
if !r.isAccessRequestFile(path) {
return "MR contains files outside allowed access-request paths: " + path
}
}
var errs []string
for _, change := range mrCtx.Changes {
if change.OldPath != "" && !r.isAccessRequestFile(change.OldPath) {
errs = append(errs, "MR contains files outside allowed access-request paths: "+change.OldPath)
}
if change.NewPath != "" && !r.isAccessRequestFile(change.NewPath) {
errs = append(errs, "MR contains files outside allowed access-request paths: "+change.NewPath)
}
}
if len(errs) > 0 {
return strings.Join(errs, ", ")
}
References
  1. Validation functions should run all checks and collect all errors instead of returning early on the first failure.

Comment thread internal/rules/access_request/rule.go Outdated
return r.CreateManualReviewResult("Could not derive expected name from filename")
}

if doc.Name != expectedName {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The check doc.Name != expectedName is case-sensitive. If the filename is User.yaml but the YAML content is name: user, validation will fail. If the system treats usernames as case-insensitive, consider using strings.EqualFold to avoid unnecessary manual reviews for casing mismatches.

Suggested change
if doc.Name != expectedName {
if !strings.EqualFold(doc.Name, expectedName) {

return access_request.NewRule()
},
Enabled: true,
Category: "hello_access_request",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The category hello_access_request is very specific compared to other categories in the registry (e.g., auto_approval, service_account). Consider using a more generic category like access_request to group similar future rules and maintain consistency with the existing category naming convention.

Suggested change
Category: "hello_access_request",
Category: "access_request",

}
}

func (r *Rule) validateMRContainsOnlyAccessRequests() string {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

validateMRContainsOnlyAccessRequests iterates over all changes in the MR every time ValidateLines is called for a file. For MRs with many files, this results in $O(N^2)$ complexity. Since the MR context is constant for a given evaluation, consider caching the result of this check in the Rule struct after the first execution.

Signed-off-by: Bibhas Debnath <bdebnath@redhat.com>
@iambibhas
iambibhas force-pushed the hello-access-requests branch from 7129e1c to b854c9a Compare May 21, 2026 08:43
Signed-off-by: Bibhas Debnath <bdebnath@redhat.com>
@iambibhas
iambibhas force-pushed the hello-access-requests branch from 34d99f3 to 9198b42 Compare May 21, 2026 09:21
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.

1 participant