You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary
Adds an optional write_mode configuration to the BigQuery source,
enhancing security by controlling the types of SQL statements that can
be executed to prevent unauthorized data modification.
Key Changes
Added writeMode Configuration: A new write_mode field is added to the
BigQuery source, supporting three modes:
allowed (Default): Permits all SQL statements.
blocked: Allows only SELECT queries.
protected: Enables session-based execution, restricting write operations
(like CREATE TABLE) to the session's temporary dataset, thus protecting
permanent datasets. Note: at the moment, this won't work with
useClientOAuth, will fix this in the future.
These restrictions primarily apply to the bigquery-execute-sql tool and
the session may be used in other tools.
Copy file name to clipboardExpand all lines: docs/en/resources/sources/bigquery.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -119,6 +119,7 @@ sources:
119
119
kind: "bigquery"
120
120
project: "my-project-id"
121
121
# location: "US" # Optional: Specifies the location for query jobs.
122
+
# writeMode: "allowed" # One of: allowed, blocked, protected. Defaults to "allowed".
122
123
# allowedDatasets: # Optional: Restricts tool access to a specific list of datasets.
123
124
# - "my_dataset_1"
124
125
# - "other_project.my_dataset_2"
@@ -133,6 +134,7 @@ sources:
133
134
project: "my-project-id"
134
135
useClientOAuth: true
135
136
# location: "US" # Optional: Specifies the location for query jobs.
137
+
# writeMode: "allowed" # One of: allowed, blocked, protected. Defaults to "allowed".
136
138
# allowedDatasets: # Optional: Restricts tool access to a specific list of datasets.
137
139
# - "my_dataset_1"
138
140
# - "other_project.my_dataset_2"
@@ -145,5 +147,6 @@ sources:
145
147
| kind | string | true | Must be "bigquery". |
146
148
| project | string | true | Id of the Google Cloud project to use for billing and as the default project for BigQuery resources. |
147
149
| location | string | false | Specifies the location (e.g., 'us', 'asia-northeast1') in which to run the query job. This location must match the location of any tables referenced in the query. Defaults to the table's location or 'US' if the location cannot be determined. [Learn More](https://cloud.google.com/bigquery/docs/locations)|
150
+
| writeMode | string | false | Controls the write behavior for tools. `allowed` (default): All queries are permitted. `blocked`: Only `SELECT` statements are allowed for the `bigquery-execute-sql` tool. `protected`: Enables session-based execution where all tools associated with this source instance share the same [BigQuery session](https://cloud.google.com/bigquery/docs/sessions-intro). This allows for stateful operations using temporary tables (e.g., `CREATE TEMP TABLE`). For `bigquery-execute-sql`, `SELECT` statements can be used on all tables, but write operations are restricted to the session's temporary dataset. For tools like `bigquery-sql`, `bigquery-forecast`, and `bigquery-analyze-contribution`, the `writeMode` restrictions do not apply, but they will operate within the shared session. **Note:** The `protected` mode cannot be used with `useClientOAuth: true`. It is also not recommended for multi-user server environments, as all users would share the same session. A session is terminated automatically after 24 hours of inactivity or after 7 days, whichever comes first. A new session is created on the next request, and any temporary data from the previous session will be lost. |
148
151
| allowedDatasets |[]string | false | An optional list of dataset IDs that tools using this source are allowed to access. If provided, any tool operation attempting to access a dataset not in this list will be rejected. To enforce this, two types of operations are also disallowed: 1) Dataset-level operations (e.g., `CREATE SCHEMA`), and 2) operations where table access cannot be statically analyzed (e.g., `EXECUTE IMMEDIATE`, `CREATE PROCEDURE`). If a single dataset is provided, it will be treated as the default for prebuilt tools. |
149
-
| useClientOAuth | bool | false | If true, forwards the client's OAuth access token from the "Authorization" header to downstream queries. |
152
+
| useClientOAuth | bool | false | If true, forwards the client's OAuth access token from the "Authorization" header to downstream queries. **Note:** This cannot be used with `writeMode: protected`.|
Copy file name to clipboardExpand all lines: docs/en/resources/tools/bigquery/bigquery-execute-sql.md
+10-1Lines changed: 10 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,8 +20,15 @@ It's compatible with the following sources:
20
20
-**`dry_run`** (optional): If set to `true`, the query is validated but not run,
21
21
returning information about the execution instead. Defaults to `false`.
22
22
23
+
The behavior of this tool is influenced by the `writeMode` setting on its `bigquery` source:
24
+
25
+
-**`allowed` (default):** All SQL statements are permitted.
26
+
-**`blocked`:** Only `SELECT` statements are allowed. Any other type of statement (e.g., `INSERT`, `UPDATE`, `CREATE`) will be rejected.
27
+
-**`protected`:** This mode enables session-based execution. `SELECT` statements can be used on all tables, while write operations are allowed only for the session's temporary dataset (e.g., `CREATE TEMP TABLE ...`). This prevents modifications to permanent datasets while allowing stateful, multi-step operations within a secure session.
28
+
23
29
The tool's behavior is influenced by the `allowedDatasets` restriction on the
24
-
`bigquery` source:
30
+
`bigquery` source. Similar to `writeMode`, this setting provides an additional layer of security by controlling which datasets can be accessed:
31
+
25
32
-**Without `allowedDatasets` restriction:** The tool can execute any valid GoogleSQL
26
33
query.
27
34
-**With `allowedDatasets` restriction:** Before execution, the tool performs a dry run
@@ -33,6 +40,8 @@ The tool's behavior is influenced by the `allowedDatasets` restriction on the
33
40
-**Unanalyzable operations** where the accessed tables cannot be determined
Copy file name to clipboardExpand all lines: docs/en/resources/tools/bigquery/bigquery-sql.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,11 @@ the following sources:
15
15
16
16
-[bigquery](../../sources/bigquery.md)
17
17
18
+
The behavior of this tool is influenced by the `writeMode` setting on its `bigquery` source:
19
+
20
+
-**`allowed` (default) and `blocked`:** These modes do not impose any restrictions on the `bigquery-sql` tool. The pre-defined SQL statement will be executed as-is.
21
+
-**`protected`:** This mode enables session-based execution. The tool will operate within the same BigQuery session as other tools using the same source, allowing it to interact with temporary resources like `TEMP` tables created within that session.
22
+
18
23
### GoogleSQL
19
24
20
25
BigQuery uses [GoogleSQL][bigquery-googlesql] for querying data. The integration
0 commit comments