How to Configure GitHub Copilot SQL Server Sandbox

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a github copilot sql server sandbox with an isolated database and a read-only user. This setup lets the coding agent test queries without breaking live tables. Many teams start by linking their local code editor directly to a shared test instance. When developers use broad roles for speed, a bad query can wipe out test data. Giving an agent owner rights in a shared space puts every table at risk. How a github copilot sql server sandbox works with native roles In SQL Server, a datab

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 a github copilot sql server sandbox with an isolated database and a read-only user. This setup lets the coding agent test queries without breaking live tables. Many teams start by linking their local code editor directly to a shared test instance. When developers use broad roles for speed, a bad query can wipe out test data. Giving an agent owner rights in a shared space puts every table at risk.

How a github copilot sql server sandbox works with native roles

In SQL Server, a database user is the identity of a login inside a database. Microsoft offers thirteen types of database users for different needs. When someone needs to reach many databases on one server, a master login is common. For a single test database, a contained database user is a cleaner choice. This user has its own password and does not need a login in the master database. An admin must first turn on contained databases at the server and database levels.

Once the user exists, you control its reach through fixed database roles. You cannot change the built-in permissions assigned to these fixed roles. Every role in the database starts with the basic right to connect. If you assign the owner role, the agent can change settings and even drop the database. Instead, teams use the data reader role so the agent can only read user tables and views.

You can also add the deny data writer role for extra safety. That role blocks the user from adding, changing, or deleting any rows. If the coding agent needs to test data changes, you grant the data writer role on a scratch database. You can also block specific tables with the deny data reader role. This role stops the user from reading data or metadata from user tables and views.

How the coding agent runs queries in your workspace

GitHub Copilot works inside your code editor to help write and test database logic. When the agent runs in your workspace, it uses local tools or shell commands to reach the database. It reads the database string stored in your local app files or environment settings. Then it sends SQL statements to the server using that database user identity. The database checks the role of that user before running each statement.

Developers often build a local or cloud test database just for these agent tasks. They load sample rows into the tables so the agent can check query results. When the agent writes a new join or filter, it runs the query against the test instance. If the query fails, the agent reads the error message and tries a new statement. This loop helps the developer build working queries much faster.

Kubernetes API Server Access + GitHub Actions Security: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native database roles solve and what they miss

Native SQL Server roles do a great job of controlling who can log in. They also draw hard lines between reading tables and changing data. By pairing a contained user with a read-only role, you stop accidental table drops. You also keep the agent trapped inside one database rather than the whole server.

Still, static roles only check permissions at the table and view level. The data reader role lets the user read every column in every user table by default. If your test database holds copied production rows, the agent can read all of them. Native roles do not rewrite sensitive fields like emails, phone numbers, or card numbers in query results. They also cannot pause a single risky command in flight while allowing safe ones. Also, storing database passwords in local workspace files leaves those keys exposed on disk. Teams still need a way to inspect individual queries and mask sensitive fields in real time.

Govern SQL Server queries and responses in flight

Table grants decide which SQL Server objects a caller may touch. They do not check query intent or rewrite sensitive values in results across every client and agent. By design, hoop.dev sits inline in the TDS wire protocol next to SQL Server as a sidecar for your SQL Server. On every production batch from an engineer or AI agent, hoop.dev decides to pass, mask, block, or hold it for approval.

With hoop.dev guardrails and hoop.dev data masking, banned statements are refused or held for review, matched sensitive fields in supported result columns are masked in memory, and each decision is logged. Check out the code on GitHub.

Frequently asked questions

Should I use a master login or a contained user for a sandbox?

Use a contained database user when the agent only needs one test database. This keeps the user tied to that single database instead of the whole server instance. Remember that an admin must enable contained databases on the server and database first.

Why is the data reader role not enough for copied test data?

Members of the data reader role can read all data from all user tables and views. If your test tables include real emails, phone numbers, or national IDs, the agent reads them all. You must either scrub the test data first or rewrite matched fields in query results.

How can I stop an agent from changing data in a read-only sandbox?

Put the sandbox user in the data reader role and add the deny data writer role. The deny data writer role stops the user from adding, changing, or deleting any table data. Avoid the owner role because it lets the user change settings and drop the database.

The query runs. The emails stay hidden.