How to Configure OpenHands CockroachDB Audit Log

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up an openhands cockroachdb audit log by turning on table rules. Then you map the AI agent to its own database role. Teams often give coding agents broad admin keys to speed up work. When roles are too broad, an agent can change or delete live data. Good logs help you see every query the agent runs. How the openhands cockroachdb audit log works OpenHands runs as an autonomous coding agent inside its own workspace. It writes code, runs shell commands, and queries databases to finish ta

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You set up an openhands cockroachdb audit log by turning on table rules. Then you map the AI agent to its own database role. Teams often give coding agents broad admin keys to speed up work. When roles are too broad, an agent can change or delete live data. Good logs help you see every query the agent runs.

How the openhands cockroachdb audit log works

OpenHands runs as an autonomous coding agent inside its own workspace. It writes code, runs shell commands, and queries databases to finish tasks. When the agent talks to CockroachDB, it uses a standard database user role. You should create a separate role just for this agent.

CockroachDB tracks activity by watching specific tables or user roles. You turn on logging rules at the table level in the database. When the agent reads or writes to a marked table, the database records it. The engine writes this event to a local file or log sink.

Each log entry holds the time, the user role, and the full query text. Your security team can send these log files to a central log tool. This setup shows which tables the agent touched during a work session. It also splits agent traffic from human developer traffic in your records.

What native logging solves and what it misses

Native database logs are great for looking back after an incident happens. They prove which role ran a query and when that query ran. If a coding agent drops a table, the log shows the exact command. You can use this history to fix the mistake and update role rules.

Still, native setup only checks who logs in at the start. It does not inspect or block bad individual statements while they run. Once the agent has a valid role, the database trusts every command it allows. If the role can read a table, the agent gets all raw rows.

This leaves a big gap when tables hold private user data. A query result might return emails, phone numbers, card numbers, or national IDs. Native audit logs record the query, but they do not hide this data. In fact, the log file itself might store raw values from the query text.

Audit Log Integrity + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Best ways to manage AI agent database roles

Start by giving the OpenHands role the smallest set of permissions possible. Do not let the agent use the same user key as your main app. Block the agent role from changing schema settings or dropping tables in production. Only grant read permissions on the specific tables the agent needs to check.

Next, review your log storage rules to keep log files safe. Database audit logs grow fast when an AI agent runs many test queries. Set up log rotation so your database disk does not fill up. Make sure only your security team can read or delete the stored log files.

Finally, pair your native logs with controls that watch queries in flight. You need a way to pause risky commands before the database runs them. You also need masking that rewrites matched fields in results for sensitive columns. This keeps private data out of agent prompts and log files alike.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.

Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.

Frequently asked questions

Why does OpenHands need a separate CockroachDB user role?

A separate role lets you tell agent queries apart from human queries. If the agent shares a key with an app, all logs look the same. Separate roles also let you limit what the agent can read or write.

Do CockroachDB audit logs stop an agent from deleting data?

No, audit logs only record events after the database runs the command. To stop deletes, you must remove write permissions from the database role. Or you must add an approval step before the query reaches the database.

Can database audit logs leak sensitive customer data?

Yes, audit logs often save the full SQL statement in plain text. If a query includes emails or card numbers, those values end up in logs. You should limit who can read log files and mask sensitive query fields.

The query runs. The emails stay hidden.