Skip to content

Enforce dedicated service account for Cloud Build triggers#110

Open
alex-doudou wants to merge 2 commits intomainfrom
service_account
Open

Enforce dedicated service account for Cloud Build triggers#110
alex-doudou wants to merge 2 commits intomainfrom
service_account

Conversation

@alex-doudou
Copy link
Copy Markdown
Contributor

  • Tests pass
  • Appropriate changes to documentation are included in the PR

This PR:

  • updated how_to_create_cloudbuild_trigger.md to include a mandatory step for creating/using a dedicated service account.
  • explicitly assigned required roles (logging, artifactregistry, developerconnect) to the dedicated SA.
  • mandated passing the dedicated SA email to the create_build_trigger tool.

@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 enhances the security posture for Cloud Build triggers by mandating the use of dedicated service accounts. It ensures that triggers operate with the principle of least privilege, thereby reducing potential security risks. The changes primarily involve updating documentation to guide users through the process of setting up and assigning appropriate roles to these dedicated service accounts, and explicitly requiring their use when creating new triggers.

Highlights

  • Mandatory Dedicated Service Accounts: Enforced the use of dedicated, user-managed service accounts for Cloud Build triggers to adhere to the principle of least privilege, replacing the default Compute Engine service account.
  • Required IAM Roles: Explicitly defined the minimum necessary IAM roles (roles/logging.logWriter, roles/artifactregistry.writer, roles/developerconnect.tokenAccessor) that must be granted to the dedicated service account.
  • Tool Parameter Update: Mandated that the email of the dedicated service account must be provided to the service_account parameter when using the create_build_trigger tool.
  • Documentation Update: Updated the how_to_create_cloudbuild_trigger.md guide to include detailed steps for checking, creating, and configuring the dedicated service account.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 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 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.

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.

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 updates the how_to_create_cloudbuild_trigger.md documentation to include a new section on ensuring a dedicated service account is used for Cloud Build triggers, detailing the creation process and required roles, and emphasizes providing this service account to the create_build_trigger tool. Feedback indicates a critical discrepancy where the create_build_trigger tool does not enforce the use of a dedicated service account, potentially leading to security issues, and suggests modifying the tool to require this parameter. Additionally, a minor markdown formatting issue was noted in a new heading.

## ## Final Step: Creating the Trigger

Once all prerequisites are met, the agent can create the trigger itself using the available tools. No newline at end of file
Once all prerequisites are met, the agent can create the trigger itself using the `create_build_trigger` tool. **You MUST provide the email of the dedicated service account identified or created in Step 4 to the `service_account` parameter.** No newline at end of file
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.

high

This documentation mandates the use of a dedicated service account, which is an important security best practice. However, the implementation of the create_build_trigger tool (in cicd-mcp-server/cloudbuild/cloudbuild.go) doesn't enforce this. The service_account parameter is optional, and if omitted, the tool silently falls back to the default Compute Engine service account. This creates a significant discrepancy between the documentation's requirement and the tool's behavior, potentially leading to the use of an over-privileged service account. To align with the goal of this PR, the create_build_trigger tool should be modified to require the service_account parameter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in the follow-up commit. (will squash after human review is approved)

4. **Check for Repository Link**: Check if a repository link for that specific URI already exists within the Developer Connect connection.
5. **Create Repository Link (if needed)**: If the link does not exist, create it. This link is the resource that the Cloud Build trigger will formally point to.

### ### 4. Ensure Dedicated Service Account Exists
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 markdown for this heading, ### ###, is not standard and will likely not render as intended. For a level 3 heading, a single ### should be used.

Suggested change
### ### 4. Ensure Dedicated Service Account Exists
### 4. Ensure Dedicated Service Account Exists

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Resolved

@alex-doudou
Copy link
Copy Markdown
Contributor Author

Added the follow up commit to enforce the service account behaviour in our go tool as well.

The commit:

  • Modified create_build_trigger to require the service_account parameter.
  • Removed silent fallback to the default Compute Engine service account.
  • Updated unit tests to verify the mandatory behavior and removed obsolete fallback tests.

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