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
`gws` is a Rust CLI that dynamically generates commands from Google Discovery Documents at runtime. It does NOT use generated Rust crates (`google-drive3`, etc.) for API interaction. Do not suggest adding API-specific crates to `Cargo.toml`.
6
+
7
+
## Security: Trusted vs Untrusted Inputs
8
+
9
+
This CLI is frequently invoked by AI/LLM agents. CLI arguments may be adversarial.
10
+
11
+
-**CLI arguments (untrusted)** — Must validate paths against traversal (`../../`), reject control characters, percent-encode URL path segments, and use `reqwest .query()` for query parameters. Validators: `validate_safe_output_dir()`, `validate_safe_dir_path()`, `encode_path_segment()`, `validate_resource_name()`.
12
+
-**Environment variables (trusted)** — Set by the user in their shell profile, `.env` file, or deployment config. Do NOT flag missing path validation on environment variable values. This is consistent with `XDG_CONFIG_HOME`, `CARGO_HOME`, etc.
13
+
14
+
## Test Coverage
15
+
16
+
The `codecov/patch` check requires new/modified lines to be covered by tests. Prefer extracting testable helper functions over embedding logic in `main`/`run`. Tests should cover both happy paths and rejection paths (e.g., pass `../../.ssh` and assert `Err`).
17
+
18
+
## Changesets
19
+
20
+
Every PR must include a `.changeset/<name>.md` file. Use `patch` for fixes/chores, `minor` for features, `major` for breaking changes.
21
+
22
+
## Code Style
23
+
24
+
- Rust: `cargo clippy -- -D warnings` must pass. `cargo fmt` enforced via pre-commit hook.
25
+
- Node.js: Use `pnpm` not `npm`.
26
+
- OAuth scope strings in test code will trigger "restricted/sensitive scope" warnings — these are expected and should be ignored.
Copy file name to clipboardExpand all lines: AGENTS.md
+40-4Lines changed: 40 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,6 +84,9 @@ ASCII art title cards live in `art/`. The `scripts/show-art.sh` helper clears th
84
84
> [!IMPORTANT]
85
85
> This CLI is frequently invoked by AI/LLM agents. Always assume inputs can be adversarial — validate paths against traversal (`../../.ssh`), restrict format strings to allowlists, reject control characters, and encode user values before embedding them in URLs.
86
86
87
+
> [!NOTE]
88
+
> **Environment variables are trusted inputs.** The validation rules above apply to **CLI arguments** that may be passed by untrusted AI agents. Environment variables (e.g. `GOOGLE_WORKSPACE_CLI_CONFIG_DIR`) are set by the user themselves — in their shell profile, `.env` file, or deployment config — and are not subject to path traversal validation. This is consistent with standard conventions like `XDG_CONFIG_HOME`, `CARGO_HOME`, etc.
89
+
87
90
### Path Safety (`src/validate.rs`)
88
91
89
92
When adding new helpers or CLI flags that accept file paths, **always validate** using the shared helpers:
@@ -165,7 +168,40 @@ Use these labels to categorize pull requests and issues:
-`GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE` — Path to OAuth credentials JSON (no default; if unset, falls back to credentials secured by the OS Keyring and encrypted in `~/.config/gws/`)
170
-
-`GOOGLE_WORKSPACE_CLI_ACCOUNT` — Default account email for multi-account usage (overridden by `--account` flag)
|`GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE`| Path to OAuth credentials JSON (no default; if unset, falls back to credentials secured by the OS Keyring and encrypted in `~/.config/gws/`) |
177
+
|`GOOGLE_WORKSPACE_CLI_ACCOUNT`| Default account email for multi-account usage (overridden by `--account` flag) |
178
+
|`GOOGLE_WORKSPACE_CLI_IMPERSONATED_USER`| Email of user to impersonate with Domain-Wide Delegation (service accounts only) |
179
+
|`GOOGLE_APPLICATION_CREDENTIALS`| Standard Google ADC path; used as fallback when no gws-specific credentials are configured |
180
+
181
+
### Configuration
182
+
183
+
| Variable | Description |
184
+
|---|---|
185
+
|`GOOGLE_WORKSPACE_CLI_CONFIG_DIR`| Override the config directory (default: `~/.config/gws`) |
186
+
187
+
### OAuth Client
188
+
189
+
| Variable | Description |
190
+
|---|---|
191
+
|`GOOGLE_WORKSPACE_CLI_CLIENT_ID`| OAuth client ID (for `gws auth login` when no `client_secret.json` is saved) |
192
+
|`GOOGLE_WORKSPACE_CLI_CLIENT_SECRET`| OAuth client secret (paired with `CLIENT_ID` above) |
193
+
194
+
### Sanitization (Model Armor)
195
+
196
+
| Variable | Description |
197
+
|---|---|
198
+
|`GOOGLE_WORKSPACE_CLI_SANITIZE_TEMPLATE`| Default Model Armor template (overridden by `--sanitize` flag) |
199
+
|`GOOGLE_WORKSPACE_CLI_SANITIZE_MODE`|`warn` (default) or `block`|
200
+
201
+
### Helpers
202
+
203
+
| Variable | Description |
204
+
|---|---|
205
+
|`GOOGLE_WORKSPACE_PROJECT_ID`| GCP project ID fallback for `gmail watch` and `events subscribe` helpers (overridden by `--project` flag) |
206
+
207
+
All variables can also live in a `.env` file (loaded via `dotenvy`).
0 commit comments