Skip to content

feat(cloudsqlpg): add native read-only session locking#3619

Open
anubhav756 wants to merge 4 commits into
anubhav-readonly-corefrom
anubhav-readonly-cloudsqlpg
Open

feat(cloudsqlpg): add native read-only session locking#3619
anubhav756 wants to merge 4 commits into
anubhav-readonly-corefrom
anubhav-readonly-cloudsqlpg

Conversation

@anubhav756

@anubhav756 anubhav756 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Overview

This PR implements native read-only session locking for Cloud SQL PostgreSQL.

Changes

  • Updates the connection logic to automatically inject options='-c cloudsql_session_read_only=locked' into the DSN for read-only sources.
  • Includes a new vulnerability test verifying that the underlying database kernel intercepts and blocks any destructive queries, even if an AI agent maliciously attempts to bypass the AST parser.

@anubhav756 anubhav756 self-assigned this Jul 14, 2026

@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 read-only support for Cloud SQL Postgres by adding a CLOUDSQL_PG_READONLY configuration, a new execute_sql_readonly tool, and enforcing the cloudsql_session_read_only=locked option in the connection string. An integration test is also added to verify that write operations are rejected in read-only mode. The feedback suggests improving the integration test's robustness by making the error message assertion case-insensitive.

Comment thread tests/cloudsqlpg/cloud_sql_pg_integration_test.go Outdated
@anubhav756 anubhav756 force-pushed the anubhav-readonly-core branch 2 times, most recently from a975dc7 to efeaaa2 Compare July 14, 2026 07:31
@anubhav756 anubhav756 force-pushed the anubhav-readonly-cloudsqlpg branch from cff807b to 0c67add Compare July 14, 2026 07:32
@anubhav756 anubhav756 force-pushed the anubhav-readonly-core branch from efeaaa2 to c638838 Compare July 14, 2026 07:36
@anubhav756 anubhav756 force-pushed the anubhav-readonly-cloudsqlpg branch from 0c67add to d641571 Compare July 14, 2026 08:13
@anubhav756

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 a read-only mode for the Cloud SQL Postgres source, adding configuration options, a read-only execution tool, and DSN-level enforcement using cloudsql_session_read_only=locked. It also includes an integration test to verify that write operations are rejected under this mode. The reviewer feedback suggests improving the integration test by constructing the configuration map directly in Go rather than parsing a raw YAML template string, which also allows removing the unused gopkg.in/yaml.v3 import.

Comment thread tests/cloudsqlpg/cloud_sql_pg_integration_test.go Outdated
Comment thread tests/cloudsqlpg/cloud_sql_pg_integration_test.go Outdated
@anubhav756 anubhav756 marked this pull request as ready for review July 14, 2026 13:29
@anubhav756 anubhav756 requested review from a team as code owners July 14, 2026 13:29
@anubhav756 anubhav756 assigned Yuan325 and unassigned anubhav756 Jul 14, 2026
@anubhav756 anubhav756 force-pushed the anubhav-readonly-cloudsqlpg branch from 83a69ab to adfe355 Compare July 15, 2026 07:56
@anubhav756 anubhav756 force-pushed the anubhav-readonly-cloudsqlpg branch from adfe355 to 7a43fcc Compare July 15, 2026 08:08
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