Skip to content

feat: implement security discovery and validation in prepare phase (PR 3)#10734

Open
inlined wants to merge 1 commit into
requires-role-2-iamfrom
requires-role-3-validation
Open

feat: implement security discovery and validation in prepare phase (PR 3)#10734
inlined wants to merge 1 commit into
requires-role-2-iamfrom
requires-role-3-validation

Conversation

@inlined

@inlined inlined commented Jun 29, 2026

Copy link
Copy Markdown
Member

Description

This is PR 3 in the requiresRole PR chain.
It implements deployment validation and codebase security details discovery during the preparation phase:

  1. discoverSecurityDetails to identify whether a codebase is using declarative security and resolving the managed service account.
  2. Ensures custom service accounts and declarative security are not combined.
  3. Performs early checks for permission requirements (iam.serviceAccounts.create, resourcemanager.projects.setIamPolicy).

Scenarios Tested

  • Run unit tests: npx mocha src/deploy/functions/prepare.spec.ts
  • Run npm run build & npm run lint

Sample Commands

N/A

@inlined inlined requested a review from Berlioz June 29, 2026 15:54

@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 declarative security coordination for Cloud Functions codebases by adding the discoverSecurityDetails function, which manages managed service accounts and etag labels. It also simplifies API enablement in ensureAllRequiredAPIsEnabled by removing the distinction between standard and additional APIs and eliminating the interactive user confirmation prompt. Feedback highlights that removing this prompt bypasses a safeguard against unexpected billing charges from enabling APIs, and questions if this change in behavior was intentional.

Comment on lines 814 to 817
export async function ensureAllRequiredAPIsEnabled(
projectNumber: string,
wantBackend: backend.Backend = backend.empty(),
options: { force?: boolean; nonInteractive?: boolean } = {},
wantBackend: backend.Backend,
): Promise<void> {

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 function's behavior has been significantly changed. The previous implementation would differentiate between standard and additional APIs, and would prompt the user for confirmation before enabling any additional APIs that were not already active. This was a useful safeguard, as enabling some APIs can have billing implications.

The new implementation enables all required APIs from wantBackend.requiredAPIs without confirmation. It also now includes logic to enable GCFv2-related APIs and the Secret Manager API if needed. While centralizing API enablement is good, removing the user prompt could lead to unexpected costs for users. Was this intentional? If so, it might be worth noting this change in behavior in the PR description.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The comments should not have been changed, but this feedback is wrong. The prompt is still below

@inlined inlined force-pushed the requires-role-2-iam branch from 4a06f05 to 1ddf608 Compare June 29, 2026 16:49
@inlined inlined force-pushed the requires-role-3-validation branch from 86e2632 to ef1d12f Compare June 29, 2026 16:49
@inlined inlined requested review from ajperel and wandamora June 29, 2026 17:12
@inlined inlined force-pushed the requires-role-2-iam branch from 1ddf608 to b4dd6a2 Compare June 29, 2026 17:33
### Description
This is PR 3 in the requiresRole PR chain.
It implements deployment validation and codebase security details discovery during the preparation phase:
1. discoverSecurityDetails to identify whether a codebase is using declarative security and resolving the managed service account.
2. Ensures custom service accounts and declarative security are not combined.
3. Performs early checks for permission requirements (iam.serviceAccounts.create, resourcemanager.projects.setIamPolicy).

### Scenarios Tested
- Run unit tests: npx mocha src/deploy/functions/prepare.spec.ts
- Run npm run build & npm run lint

### Sample Commands
N/A
@inlined inlined force-pushed the requires-role-3-validation branch from ef1d12f to 1eb74ff Compare June 29, 2026 17:33
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