Skip to content

feat(sql-server): run the integration test against Azure SQL Database - #13129

Merged
kyle-sexton merged 1 commit into
mainfrom
host-run/9905-azure-target
Nov 4, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
host-run/9905-azure-target

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Refs: #9905

Summary

plugins/sql-server/integration/read-path.mjs could only run against the local container it starts, as sa (#9905's Status comment). It now takes --azure-server <server>.database.windows.net and runs the same S1/S2, S4, S5, S6 and S7 checks against an existing, empty Azure SQL Database named app.

Fix

  • integration/target.mjs holds what differs per target: argument parsing, the fixture batches, the fingerprint query and the expected out-of-scope refusal.
  • Azure mode connects to app with an AzureCliCredential token as the server's Entra admin (no password of the caller's), and creates mcp_reader (db_datareader) and mcp_writer as contained users with passwords generated in-process. The plugin reaches them only through the config's env-variable references, as in local mode.
  • Azure SQL Database refuses every cross-database name, so S5's three-part names are refused by the platform rather than the login, and the fingerprint reads app alone. One database is enough: the allow-list half of S5 refuses other before connecting (src/tools.mjs).
  • Local mode is unchanged in behaviour; sa is now named admin in the code.
  • README and reference/azure-sql-database.md describe the Azure mode; no workflow runs it.

Verification

  • npm test --prefix plugins/sql-server: 216 pass, including 15 new tests for target.mjs (no database needed).
  • node plugins/sql-server/integration/read-path.mjs (local container): PASS for S1/S2, S4, S5, S6 and S7.
  • scripts/check-affected.sh --tests on the committed head: green.
  • Azure SQL Database free tier (AutoPause), on this head c2673381f2: PASS for all five checks, then teardown with az group exists false: feat: ship a safe, general-purpose SQL Server MCP server plugin #5940 (comment)

Remaining on #9905

Related

🤖 Generated with Claude Code

read-path.mjs takes --azure-server <server>.database.windows.net. It
connects to an empty app database with an Azure CLI token as the
server's Entra admin, creates contained read-only and write users with
passwords generated for the run, and runs the same S1/S2, S4, S5, S6
and S7 checks. Azure SQL Database refuses cross-database names, so S5's
three-part names are refused by the platform and no second database is
needed. The per-target SQL lives in integration/target.mjs, tested
without a database.

Refs: #9905

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T07:19:33.672889Z c267338 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

claude-security-review reviewed c2673381f24aa6dd94363fb17ec6a57dcd7bb4cd: read 6 of 6 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #13129 (head c267338)

No security issues found.

I read all 6 changed files in full: the changeset note, README.md, integration/read-path.mjs, the new integration/target.mjs, reference/azure-sql-database.md and test/integration-target.test.mjs. The change adds an optional --azure-server mode to an integration test that a developer runs by hand. The PR adds no workflow, so no CI lane runs this test. It changes no plugin manifest, trust control, token request or merge hold.

What I checked:

  • Injection through --azure-server. parseTarget only accepts an argument that matches /^[a-z0-9-]+\.database\.windows\.net$/i, anchored at both ends, and rejects any extra arguments (target.mjs#L436). The value is only passed to tedious as server. A test confirms that a value with ;Password=x appended is refused.
  • SQL injection in the fixture batches. CREATE USER [...] WITH PASSWORD = N'...' builds its string from the constant names mcp_reader and mcp_writer and from passwords made by newPassword(). Those passwords are 32 hex characters followed by Aa1! (read-path.mjs#L110), so they can contain no quote or bracket.
  • TLS. Azure mode keeps encrypt: true and leaves out the custom ca, so the server certificate is checked against the default trust store. The PR never sets trustServerCertificate.
  • Credential handling. The admin connection uses an AzureCliCredential token, and the script asks for no password of the caller's. The reader and writer passwords reach the plugin only through environment-variable references in the generated config. S6 still checks the config and the registration for leaked passwords. It also scans conf and the sa password in local mode, which is correct because Azure mode creates neither.
  • Leftover state. The contained users remain in the caller's app database with random passwords that are never saved, and the README says to delete the database afterwards. This is a test database the operator owns; I found no route for an attacker to use it.
  • Cost. The script creates no Azure resources. It connects to a database the operator already made, and nothing runs it automatically, so the PR doesn't need a cost hold.

The PR changes no trusted paths. The PR context contains no embedded instructions.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

claude-review reviewed c2673381f24aa6dd94363fb17ec6a57dcd7bb4cd: read 6 of 6 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #13129, run the sql-server integration test against Azure SQL Database

No blocking or advisory findings. I read every hunk of all 6 changed files, and the head version of plugins/sql-server/integration/read-path.mjs in full.

What I checked

  • Refactor of local mode. The removed createFixtures and FINGERPRINT now live in integration/target.mjs as fixtureBatches and fingerprintQuery. For the local target they produce the same statements in the same order, and the same fingerprint columns. startLocal keeps the container setup unchanged: the sa password still goes in through the env, the ca still reaches tedious, and NODE_EXTRA_CA_CERTS is still set for the server. Docker cleanup and the conf and sa-password S6 scans are now gated on local, and the Azure path never creates any of them.
  • Azure path.
    • connectAzure connects to app with an AzureCliCredential through tedious token-credential auth.
    • @azure/identity 4.14.1 and tedious 20.3.8 are already in the plugin's package.json.
    • The fingerprint and itemRows use app.-qualified three-part names, which Azure allows for the current database.
    • Contained users are created with newPassword() output: hex plus Aa1!, so no quote can break the N'…' literal.
    • The reader connects straight to app with SQL auth, and the generated config omits port on Azure so the default 1433 applies.
  • S5 on Azure. OUT_OF_SCOPE_REFUSAL.azure matches the platform's Msg 40515 text for both three-part names the test sends. The PR body and README both say that the login half of S5 is proven by the platform rather than by the login there.
  • Tests. test/integration-target.test.mjs covers argument parsing (including a connection-string injection attempt), the fixture split per target, reader grants, the fingerprint scope and both refusal patterns. That makes the 15 new tests the PR body claims.
  • Path-scoped rules. .claude/rules/cost-claims.md matches plugins/sql-server/reference/azure-sql-database.md. The changed bullet states no price or cost figure, so it passes.
  • Changelog fragment. bump: minor for a new opt-in mode of the integration script is at least the level the change needs.

Not verified

Scope notes

  • Security findings are left to the security lane: REVIEW.md splits them out, and this repo runs pr-review-security-hosted.yml.
  • The PR closes no issue ("Refs: test: verify the SQL Server MCP read tier against an Azure SQL Database free-tier database #9905"), so there are no acceptance criteria to check. The PR context had no embedded instructions.
  • There are no prior findings from this lane (round 0 of 3).
  • Spend: none. No workflow runs the Azure mode, and the script uses a database the operator already created.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 4, 2026
Merged via the queue into main with commit b4268ff Nov 4, 2026
55 checks passed
@kyle-sexton
kyle-sexton deleted the host-run/9905-azure-target branch November 4, 2026 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: verify the SQL Server MCP read tier against an Azure SQL Database free-tier database

1 participant