@canaryai/cli 0.1.5 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,9 +13,17 @@ bun add -g @canaryai/cli
13
13
  ## Login
14
14
 
15
15
  ```bash
16
- canary login
16
+ canary login # production (default)
17
+ canary login --env dev # dev environment
18
+ canary login --env local # local development
17
19
  ```
18
20
 
21
+ Options:
22
+ - `--env <env>` - Environment to login to: `prod`, `dev`, or `local`
23
+ - `--api-url <url>` - Custom API URL (overrides --env)
24
+ - `--app-url <url>` - Custom app URL (overrides --env)
25
+ - `--no-open` - Don't auto-open browser
26
+
19
27
  ## Quickstart (local testing)
20
28
 
21
29
  1) Start your app locally.
@@ -43,6 +51,49 @@ Tools:
43
51
  - `local_run_tests` (port, instructions, title)
44
52
  - `local_wait_for_results` (runId)
45
53
 
54
+ ## PSQL (superadmin only)
55
+
56
+ Execute read-only SQL queries against the production database. Requires superadmin privileges and the `cli.psql.enabled` knob to be enabled.
57
+
58
+ ```bash
59
+ canary psql "SELECT id, status FROM jobs LIMIT 5"
60
+ canary psql "SELECT * FROM jobs WHERE status = 'running'" --json
61
+ ```
62
+
63
+ Options:
64
+ - `--json` - Output results as JSON instead of a table
65
+ - `--query <sql>` - Alternative to positional query argument
66
+
67
+ Limits:
68
+ - Query size: 10KB max (for larger queries, use psql directly)
69
+ - Query timeout: 30s default (configurable via `cli.psql.timeout_ms` knob)
70
+ - Result rows: 10K max (results truncated if exceeded)
71
+
72
+ ### Security Model
73
+
74
+ The read-only PostgreSQL user (`debug_agent`) provides the **primary security layer** - it has SELECT-only privileges enforced at the database level. Any modification attempts will fail at the database regardless of other controls.
75
+
76
+ Keyword validation serves as a **secondary defense-in-depth** measure that:
77
+ 1. Prevents modification attempts from reaching the database
78
+ 2. Triggers Slack alerts and auto-disables the feature on suspicious activity
79
+ 3. Provides an audit trail of attempted misuse
80
+
81
+ Blocked keywords include: INSERT, UPDATE, DELETE, DROP, ALTER, CREATE, TRUNCATE, GRANT, REVOKE, VACUUM, REINDEX, COPY, EXECUTE, CALL, DO, PREPARE, SET, RESET, LOCK, COMMIT, ROLLBACK, LISTEN, NOTIFY.
82
+
83
+ ### Security Controls Summary
84
+
85
+ | Control | Purpose |
86
+ |---------|---------|
87
+ | Superadmin auth | Only trusted operators can access |
88
+ | `cli.psql.enabled` knob | Feature disabled by default, requires explicit enablement |
89
+ | Read-only DB user | Database-level protection against modifications |
90
+ | Keyword detection | Early blocking + alerting on suspicious queries |
91
+ | Auto-disable | Feature self-disables on modification attempts |
92
+ | Slack alerts | Immediate notification to security team |
93
+ | Query timeout | Prevents long-running queries from impacting production |
94
+ | Row limits | Prevents accidental full table dumps |
95
+ | RDS query logging | Infrastructure-level audit logging of all queries
96
+
46
97
  ## Environment variables
47
98
 
48
99
  - `CANARY_API_URL` (default `https://api.trycanary.ai`)