diff --git a/charts/dbshield/Chart.yaml b/charts/dbshield/Chart.yaml index c45d4c7..abe1c56 100644 --- a/charts/dbshield/Chart.yaml +++ b/charts/dbshield/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: dbshield description: Enterprise Database Wire Proxy, AI Safety Guardrail & Prometheus Metrics Exporter type: application -version: 0.2.0 -appVersion: "0.2.0" +version: 0.2.1 +appVersion: "0.2.1" keywords: - database - postgres diff --git a/charts/dbshield/values.yaml b/charts/dbshield/values.yaml index d1654dd..f39b353 100644 --- a/charts/dbshield/values.yaml +++ b/charts/dbshield/values.yaml @@ -7,7 +7,7 @@ image: repository: ghcr.io/ritualdev-lab/dbshield pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. - tag: "0.2.0" + tag: "0.2.1" imagePullSecrets: [] nameOverride: "" diff --git a/crates/dbshield-core/Cargo.toml b/crates/dbshield-core/Cargo.toml index c2b19a1..4c1d5b2 100644 --- a/crates/dbshield-core/Cargo.toml +++ b/crates/dbshield-core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dbshield-core" -version = "0.2.0" +version = "0.2.1" edition = "2021" authors = ["RitualDev Studio "] description = "High-performance zero-GC wire protocol proxy engine, connection pooling, and virtual shadow database for DBShield." diff --git a/package.json b/package.json index c69a6dc..d37e96e 100644 --- a/package.json +++ b/package.json @@ -65,19 +65,20 @@ }, "homepage": "https://ritualdev.in/dbshield/", "dependencies": { - "@modelcontextprotocol/sdk": "^1.6.1", + "@modelcontextprotocol/sdk": "^1.32.2", "node-sql-parser": "^5.3.7", "pg": "^8.23.1", "zod": "^4.6.7" }, "devDependencies": { - "@biomejs/biome": "^1.9.4", - "@types/node": "^26.6.6", + "@biomejs/biome": "1.9.4", + "@types/node": "22.20.5", "@types/pg": "^8.23.1", - "tsx": "^4.19.3", - "typescript": "^7.0.2" + "tsx": "4.23.15", + "typescript": "5.9.3" }, "pnpm": { + "onlyBuiltDependencies": ["@biomejs/biome", "esbuild"], "overrides": { "@hono/node-server": "^2.1.8", "hono": "^4.13.16", @@ -99,5 +100,6 @@ }, "engines": { "node": ">=20.0.0" - } + }, + "onlyBuiltDependencies": ["@biomejs/biome", "esbuild"] } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 462a453..6948340 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: dependencies: '@modelcontextprotocol/sdk': - specifier: ^1.6.1 - version: 1.32.1(zod@4.6.7) + specifier: ^1.32.2 + version: 1.32.2(zod@4.6.7) node-sql-parser: specifier: ^5.3.7 version: 5.4.0 @@ -22,20 +22,20 @@ importers: version: 4.6.7 devDependencies: '@biomejs/biome': - specifier: ^1.9.4 + specifier: 1.9.4 version: 1.9.4 '@types/node': - specifier: ^26.6.6 - version: 26.6.6 + specifier: 22.20.5 + version: 22.20.5 '@types/pg': specifier: ^8.23.1 version: 8.23.1 tsx: - specifier: ^4.19.3 + specifier: 4.23.15 version: 4.23.15 typescript: - specifier: ^7.0.2 - version: 7.0.2 + specifier: 5.9.3 + version: 5.9.3 packages: @@ -258,8 +258,8 @@ packages: peerDependencies: hono: ^4 || ^5.0.0-0 - '@modelcontextprotocol/sdk@1.32.1': - resolution: {integrity: sha512-2DdE+SJDtzLEEWzY1ZjY7Q+VcPhcV1KisD3zI4u0XZyktsjHum1mwbMI+JaulUBi2OZk+KJAi2uPXzxichPkdw==} + '@modelcontextprotocol/sdk@1.32.2': + resolution: {integrity: sha512-SWsVtH/0vULSQStoZ6xxH2K09Li8fXYTMC64ZeogCdpZ3XSi1eCPOByV1OpuJxuI3OcmHhosDWYyii07tpPsLw==} engines: {node: '>=18'} peerDependencies: '@cfworker/json-schema': ^4.1.1 @@ -268,6 +268,9 @@ packages: '@cfworker/json-schema': optional: true + '@types/node@22.20.5': + resolution: {integrity: sha512-U2+DNr+wSjpsTS/wZGYHq7GcwfuSmKiKvoPvK22zwTlRhU91yOniN4qRR5KhIjvif7ysw/dz/hKmfDH0Ris4aA==} + '@types/node@26.6.6': resolution: {integrity: sha512-MzQj+8Kx3XI40OmUAE6Qoh58ZMNstNNMwn2nfd3qWsfe7nDNSqJNzes4njhz6AHwrSHOffSLwXU6yb474Q4aog==} @@ -277,126 +280,6 @@ packages: '@types/pg@8.23.1': resolution: {integrity: sha512-fKVHpikPdg4GKks3JuLEhvwSyvwzF23hnabPy6DD8ljVbC7+6J5dQzdv4arV6jqq57djnMgs1HKBxX4P8aBI3A==} - '@typescript/typescript-aix-ppc64@7.0.2': - resolution: {integrity: sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ==} - engines: {node: '>=16.20.0'} - cpu: [ppc64] - os: [aix] - - '@typescript/typescript-darwin-arm64@7.0.2': - resolution: {integrity: sha512-gowzar9MwS/aRWp6f3a4KUqzRjAZjOsmGNCM6LcTgXum+dBfgsBVMN+AgvOCCbguXyick6LJhpBszxMebJ8syA==} - engines: {node: '>=16.20.0'} - cpu: [arm64] - os: [darwin] - - '@typescript/typescript-darwin-x64@7.0.2': - resolution: {integrity: sha512-SZ9xZInqApNlNGc9s0W1VSsktYSOe9cFqNOIqmN1Gs8SmkjKZYFt017G4VwPxASInODuAdbTW7sXiFUf893RgA==} - engines: {node: '>=16.20.0'} - cpu: [x64] - os: [darwin] - - '@typescript/typescript-freebsd-arm64@7.0.2': - resolution: {integrity: sha512-W5NH4y/J0plIIS5b2xvTEkU7JFxyqdMAOgf+Ilhl0vHQXKO5dZoxd+C/jEtq56c4F3wk71RB4BMRQ2XdI+bwYQ==} - engines: {node: '>=16.20.0'} - cpu: [arm64] - os: [freebsd] - - '@typescript/typescript-freebsd-x64@7.0.2': - resolution: {integrity: sha512-UMGDx5sTpzNw3WiPebH7l90IWfJggEd+egHt/q6p7/Cm3zqoV7VxkGXt+3DxPIw8CcmvAB0j3sVVfbhX+M4Tpw==} - engines: {node: '>=16.20.0'} - cpu: [x64] - os: [freebsd] - - '@typescript/typescript-linux-arm64@7.0.2': - resolution: {integrity: sha512-Qh4eU4/y3yDjnfjjyPYihMj5/ODIlmt+Bzu17OI+fiSRDW57QmU5SiN63exPRNJPKUzcc1INa1NXdrJ+MqHjUQ==} - engines: {node: '>=16.20.0'} - cpu: [arm64] - os: [linux] - - '@typescript/typescript-linux-arm@7.0.2': - resolution: {integrity: sha512-gffT3xPz9sR7j/YJExkyPntrI0P2EP9XbOyWzth2/Gs0RstK+90RBcO0ncXoXy/beYll1SXw846Nf2zdnEz0QQ==} - engines: {node: '>=16.20.0'} - cpu: [arm] - os: [linux] - - '@typescript/typescript-linux-loong64@7.0.2': - resolution: {integrity: sha512-uEHck9i8hoAzXPiYRib1O7miOnz23SxIeVl6F4LXox+qov1K35jHcEW6VHKvZI+pyvl7fZEP4MCU5LYvIq1GuQ==} - engines: {node: '>=16.20.0'} - cpu: [loong64] - os: [linux] - - '@typescript/typescript-linux-mips64el@7.0.2': - resolution: {integrity: sha512-R4KvAMnE43W5Qeqb0Ly56O3mWMWIAgsMyz36DCaycd5nbg/9kzm0liw3JocfRqyJY0KPmzFjbswozXyW0DnIYA==} - engines: {node: '>=16.20.0'} - cpu: [mips64el] - os: [linux] - - '@typescript/typescript-linux-ppc64@7.0.2': - resolution: {integrity: sha512-DORx5b3sd/4S7eayxm4FQv+A7CrkUIGRaHiwI8oiHTAI1fAPWhF4J0vAlkC8biAlHSVVwxMQ3tjZ2/DVbnQiiA==} - engines: {node: '>=16.20.0'} - cpu: [ppc64] - os: [linux] - - '@typescript/typescript-linux-riscv64@7.0.2': - resolution: {integrity: sha512-wf0jqEDOjrPRnKwYRyyJDRo11KMbvMFrU+q4zqKyChODBzvlkbhNQfKvLxQCcwTpdDaXSHZTVuh0JoCrKCUMHQ==} - engines: {node: '>=16.20.0'} - cpu: [riscv64] - os: [linux] - - '@typescript/typescript-linux-s390x@7.0.2': - resolution: {integrity: sha512-IkwJc3L7yhytWd/ewjyxNDfOmswCm9GWMJT/ue/dU4aZNbwZeYAetq42VyLmsmSjvoX7z74X6ZaYCtzAr0EuGw==} - engines: {node: '>=16.20.0'} - cpu: [s390x] - os: [linux] - - '@typescript/typescript-linux-x64@7.0.2': - resolution: {integrity: sha512-EYdf2cNg7rgCWJnxCdJ+F3V39O8ihb37eHAu1LK8oAFizgTQbPOK7zHHXbPt8rX24COqODXeI3sIf0fCXG7H/A==} - engines: {node: '>=16.20.0'} - cpu: [x64] - os: [linux] - - '@typescript/typescript-netbsd-arm64@7.0.2': - resolution: {integrity: sha512-+polYF4MF04aPpO5FTkHran9yUQDSXqy5GiSDKpsll5jy3l3+g9QLhpf39T+ePtefhXLOGrLl0QIjkQP6VnelA==} - engines: {node: '>=16.20.0'} - cpu: [arm64] - os: [netbsd] - - '@typescript/typescript-netbsd-x64@7.0.2': - resolution: {integrity: sha512-8YIT0EHM/3dq10ZOVF/A7pc/YSMtbcecct4rWtexrnSCHOPcpC2KTLXfTCR6vDpnSiY12heNb1GiN/wu+T/FyA==} - engines: {node: '>=16.20.0'} - cpu: [x64] - os: [netbsd] - - '@typescript/typescript-openbsd-arm64@7.0.2': - resolution: {integrity: sha512-APT8+ClYnuYm1u9+kgGXoMj2VzWzcymwh2gNSQVySHfkRDGOTVkoWLjCmOQSaO+PoqQ57B0flRp9SA+7GnnkzQ==} - engines: {node: '>=16.20.0'} - cpu: [arm64] - os: [openbsd] - - '@typescript/typescript-openbsd-x64@7.0.2': - resolution: {integrity: sha512-yX7s+Q0Dln0Dt9tEzZsAjXXR/+ytBM7AlglaqyeMPxQszJ1JhlJdZ6jLA+IzldHtflX81em7lDao1xXu+aRRkg==} - engines: {node: '>=16.20.0'} - cpu: [x64] - os: [openbsd] - - '@typescript/typescript-sunos-x64@7.0.2': - resolution: {integrity: sha512-dLJDGaLZ1D4HPQn62u1n8mBDkJREwMsAkCdkwd4Ieqw+x3TUyTsqY0YiBCtE6H6OzzgGk3iuZ3vFWRS+E8/d1g==} - engines: {node: '>=16.20.0'} - cpu: [x64] - os: [sunos] - - '@typescript/typescript-win32-arm64@7.0.2': - resolution: {integrity: sha512-Gyl1Vy6OsWesLzmq+EP0Fb7b4Nid5232AvcA2SFcdYreldpNtYFFofPjnt62y9hQy7VTaZp65ICJjuAQRaVcIQ==} - engines: {node: '>=16.20.0'} - cpu: [arm64] - os: [win32] - - '@typescript/typescript-win32-x64@7.0.2': - resolution: {integrity: sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g==} - engines: {node: '>=16.20.0'} - cpu: [x64] - os: [win32] - accepts@2.0.0: resolution: {integrity: sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==} engines: {node: '>= 0.6'} @@ -804,11 +687,14 @@ packages: resolution: {integrity: sha512-faYHw0anBbc/kWF3zFTEnxSFOAGUX9GFbOBthvDdLsIlEoWOFOtS0zgCiQYwIskL9iGXZL3kAXD8OoZ4GmMATA==} engines: {node: '>= 18'} - typescript@7.0.2: - resolution: {integrity: sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA==} - engines: {node: '>=16.20.0'} + typescript@5.9.3: + resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==} + engines: {node: '>=14.17'} hasBin: true + undici-types@6.21.0: + resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==} + undici-types@8.9.0: resolution: {integrity: sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg==} @@ -959,7 +845,7 @@ snapshots: dependencies: hono: 4.13.18 - '@modelcontextprotocol/sdk@1.32.1(zod@4.6.7)': + '@modelcontextprotocol/sdk@1.32.2(zod@4.6.7)': dependencies: '@hono/node-server': 2.1.8(hono@4.13.18) ajv: 8.20.0 @@ -981,6 +867,10 @@ snapshots: transitivePeerDependencies: - supports-color + '@types/node@22.20.5': + dependencies: + undici-types: 6.21.0 + '@types/node@26.6.6': dependencies: undici-types: 8.9.0 @@ -993,66 +883,6 @@ snapshots: pg-protocol: 1.16.1 pg-types: 2.2.0 - '@typescript/typescript-aix-ppc64@7.0.2': - optional: true - - '@typescript/typescript-darwin-arm64@7.0.2': - optional: true - - '@typescript/typescript-darwin-x64@7.0.2': - optional: true - - '@typescript/typescript-freebsd-arm64@7.0.2': - optional: true - - '@typescript/typescript-freebsd-x64@7.0.2': - optional: true - - '@typescript/typescript-linux-arm64@7.0.2': - optional: true - - '@typescript/typescript-linux-arm@7.0.2': - optional: true - - '@typescript/typescript-linux-loong64@7.0.2': - optional: true - - '@typescript/typescript-linux-mips64el@7.0.2': - optional: true - - '@typescript/typescript-linux-ppc64@7.0.2': - optional: true - - '@typescript/typescript-linux-riscv64@7.0.2': - optional: true - - '@typescript/typescript-linux-s390x@7.0.2': - optional: true - - '@typescript/typescript-linux-x64@7.0.2': - optional: true - - '@typescript/typescript-netbsd-arm64@7.0.2': - optional: true - - '@typescript/typescript-netbsd-x64@7.0.2': - optional: true - - '@typescript/typescript-openbsd-arm64@7.0.2': - optional: true - - '@typescript/typescript-openbsd-x64@7.0.2': - optional: true - - '@typescript/typescript-sunos-x64@7.0.2': - optional: true - - '@typescript/typescript-win32-arm64@7.0.2': - optional: true - - '@typescript/typescript-win32-x64@7.0.2': - optional: true - accepts@2.0.0: dependencies: mime-types: 3.0.2 @@ -1502,28 +1332,9 @@ snapshots: media-typer: 1.1.1 mime-types: 3.0.2 - typescript@7.0.2: - optionalDependencies: - '@typescript/typescript-aix-ppc64': 7.0.2 - '@typescript/typescript-darwin-arm64': 7.0.2 - '@typescript/typescript-darwin-x64': 7.0.2 - '@typescript/typescript-freebsd-arm64': 7.0.2 - '@typescript/typescript-freebsd-x64': 7.0.2 - '@typescript/typescript-linux-arm': 7.0.2 - '@typescript/typescript-linux-arm64': 7.0.2 - '@typescript/typescript-linux-loong64': 7.0.2 - '@typescript/typescript-linux-mips64el': 7.0.2 - '@typescript/typescript-linux-ppc64': 7.0.2 - '@typescript/typescript-linux-riscv64': 7.0.2 - '@typescript/typescript-linux-s390x': 7.0.2 - '@typescript/typescript-linux-x64': 7.0.2 - '@typescript/typescript-netbsd-arm64': 7.0.2 - '@typescript/typescript-netbsd-x64': 7.0.2 - '@typescript/typescript-openbsd-arm64': 7.0.2 - '@typescript/typescript-openbsd-x64': 7.0.2 - '@typescript/typescript-sunos-x64': 7.0.2 - '@typescript/typescript-win32-arm64': 7.0.2 - '@typescript/typescript-win32-x64': 7.0.2 + typescript@5.9.3: {} + + undici-types@6.21.0: {} undici-types@8.9.0: {} diff --git a/src/cli.ts b/src/cli.ts index f7f960f..554f019 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -11,11 +11,12 @@ import { installWindsurf, } from "./configurator/index.js"; import { DashboardServer } from "./dashboard/index.js"; +import { SqlGuardEngine } from "./guard/engine.js"; import { PostgresWireProxy } from "./proxy/index.js"; import { createMcpServer } from "./server/index.js"; import { runTopMonitor } from "./top-monitor.js"; -const VERSION = "0.2.0"; +const VERSION = "0.2.1"; const HELP_TEXT = ` 🛡️ DBShield - Database Guardrail & Sandboxing MCP Server v${VERSION} @@ -35,7 +36,7 @@ const HELP_TEXT = ` status Inspect database connection and active security parameters benchmark Run sub-millisecond wire-proxy latency benchmark badge Generate "Secured by DBShield" verified sponsor badge markdown / SVG - upgrade [--tier] Upgrade to Team ($29/mo) or Enterprise Hub ($99/mo) via Dodo Payments + upgrade [--tier] View Team and Enterprise licensing & integration guide init Generate a default dbshield.config.json in the current directory install-claude Automatically configure Claude Desktop to use DBShield install-cursor Automatically configure Cursor (.cursor/mcp.json) to use DBShield @@ -56,7 +57,7 @@ const HELP_TEXT = ` --upstream-host Upstream PostgreSQL host (default: 127.0.0.1) --upstream-port Upstream PostgreSQL port (default: 5432) --metrics-port Prometheus metrics exporter port (default: 9090) - --metrics-host Prometheus metrics listen host (default: 0.0.0.0) + --metrics-host Prometheus metrics listen host (default: 127.0.0.1) --no-metrics Disable Prometheus metrics exporter --once Run monitor or check once without interactive loop --json Output results in JSON format @@ -219,11 +220,22 @@ Security Score: ${report.score}/100 [${report.passed ? "PASSED" : "FAILED"}] ─────────────────────────────────────────────── Simulating 1,000 queries through DBShield AST Safety & PII Masking Pipeline... `); + const config = await loadConfig(); + const guardEngine = new SqlGuardEngine(config); const start = performance.now(); const count = 1000; + const testQueries = [ + "SELECT id, email, ssn FROM users WHERE tenant_id = 42 LIMIT 10;", + "UPDATE accounts SET balance = balance - 100 WHERE id = 101;", + "SELECT order_id, customer_name, total FROM orders WHERE created_at > '2026-01-01' LIMIT 50;", + "INSERT INTO audit_logs (event, user_id) VALUES ('login', 123);", + ]; for (let i = 0; i < count; i++) { - const q = "SELECT id, email, ssn FROM users WHERE tenant_id = 42 LIMIT 10;"; - if (q.includes("DROP")) throw new Error(); + const q = testQueries[i % testQueries.length]; + const evalResult = guardEngine.evaluate(q); + if (!evalResult.allowed) { + throw new Error(`Benchmark query unexpectedly blocked: ${q}`); + } } const durationMs = performance.now() - start; const perQueryMs = (durationMs / count).toFixed(3); @@ -276,18 +288,14 @@ HTML (for websites/docs): const tierArg = tierIdx !== -1 && args[tierIdx + 1] ? args[tierIdx + 1] : "team"; const isHub = tierArg === "hub" || tierArg === "enterprise" || tierArg === "99"; const planName = isHub - ? "DBShield Team + Shared Redis Governance ($99/mo)" - : "DBShield Team Approval Relay ($29/mo)"; - const planPrice = isHub ? "$99/mo" : "$29/mo"; - const checkoutUrl = isHub - ? "https://checkout.dodopayments.com/buy/pdt_0NrFSmrXT8zU2u5BKGJ7y?quantity=1&metadata_tier=dbshield_team_99&redirect_url=https%3A%2F%2Fritualdev.in%2Fpricing%2Fsuccess%2F%3Fproduct%3Ddbshield_team_99" - : "https://checkout.dodopayments.com/buy/pdt_0NpjONGugY5QkrFDUaPva?quantity=1&paymentAmount=29&amount=29&paymentCurrency=USD¤cy=USD&metadata_tier=dbshield_team_29&redirect_url=https%3A%2F%2Fritualdev.in%2Fpricing%2Fsuccess%2F%3Fproduct%3Ddbshield_team_29"; + ? "DBShield Team + Shared Redis Governance" + : "DBShield Team Approval Relay"; console.log(` -💳 DBShield Commercial Upgrade (Powered by Dodo Payments) +🛡️ DBShield Enterprise Features & Documentation ───────────────────────────────────────────────────────────── Plan: ${planName} -Billing: ${planPrice} (Tax deductible corporate invoice) +Information: https://ritualdev.in/dbshield/enterprise Enterprise Features Included: ✅ Interactive Slack #db-approvals & Teams mutation webhook relay @@ -295,9 +303,8 @@ Enterprise Features Included: ✅ SOC 2 Type II & ISO 27001 automated compliance evidence exports ✅ Multi-agent fleet central audit logging & tamper-evident ledger -Merchant of Record: Dodo Payments (Global Tax, GST, VAT, Cards, UPI, Apple Pay) -Direct Checkout: ${checkoutUrl} -Portal: https://ritualdev.in/pricing +Documentation & Plans: https://ritualdev.in/dbshield/enterprise +Support & Inquiries: support@ritualdev.in ───────────────────────────────────────────────────────────── `); process.exit(0); @@ -347,7 +354,7 @@ Portal: https://ritualdev.in/pricing const metricsHost = mHostIdx !== -1 && args[mHostIdx + 1] ? args[mHostIdx + 1] - : config.metricsHost || "0.0.0.0"; + : config.metricsHost || "127.0.0.1"; const enableMetrics = !args.includes("--no-metrics") && config.enableMetrics !== false; diff --git a/src/config/index.ts b/src/config/index.ts index 75c07b9..7afc1e8 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -68,7 +68,7 @@ export const ConfigSchema = z.object({ readReplicaHost: z.string().optional(), readReplicaPort: z.number().int().positive().optional(), metricsPort: z.number().int().positive().default(9090), - metricsHost: z.string().default("0.0.0.0"), + metricsHost: z.string().default("127.0.0.1"), enableMetrics: z.boolean().default(true), enableVirtualSchema: z.boolean().default(false), virtualSchema: z @@ -91,7 +91,7 @@ export const ConfigSchema = z.object({ .optional(), enableDashboard: z.boolean().default(false), dashboardPort: z.number().int().positive().default(3100), - dashboardHost: z.string().default("0.0.0.0"), + dashboardHost: z.string().default("127.0.0.1"), requireApprovalForMutations: z.boolean().default(false), }); @@ -133,12 +133,12 @@ export const DEFAULT_CONFIG: DBShieldConfig = { connectionTimeoutMillis: 5000, enableReadReplicaRouting: false, metricsPort: 9090, - metricsHost: "0.0.0.0", + metricsHost: "127.0.0.1", enableMetrics: true, enableVirtualSchema: false, enableDashboard: false, dashboardPort: 3100, - dashboardHost: "0.0.0.0", + dashboardHost: "127.0.0.1", requireApprovalForMutations: false, }; diff --git a/src/dashboard/server.ts b/src/dashboard/server.ts index 9e8b8e7..8cc115b 100644 --- a/src/dashboard/server.ts +++ b/src/dashboard/server.ts @@ -74,7 +74,7 @@ export class DashboardServer { return this.listenPort; } - public async start(port?: number, host = "0.0.0.0"): Promise { + public async start(port?: number, host = "127.0.0.1"): Promise { const targetPort = port ?? this.listenPort; return new Promise((resolve, reject) => { @@ -149,6 +149,18 @@ export class DashboardServer { private authenticateUser(req: http.IncomingMessage): { authenticated: boolean; user?: SsoUser } { if (!this.ssoAuthenticator || !this.ssoAuthenticator.isEnabled()) { + // Local developer mode: restrict unauthenticated admin approval actions strictly to loopback interface + const clientIp = req.socket.remoteAddress; + const isLoopback = + !clientIp || + clientIp === "127.0.0.1" || + clientIp === "::1" || + clientIp === "::ffff:127.0.0.1"; + + if (!isLoopback) { + return { authenticated: false }; + } + return { authenticated: true, user: { diff --git a/src/metrics/server.ts b/src/metrics/server.ts index 5c7ace9..64e85bf 100644 --- a/src/metrics/server.ts +++ b/src/metrics/server.ts @@ -25,9 +25,9 @@ export class MetricsServer { constructor(options: MetricsServerOptions = {}) { this.port = options.port ?? 9090; - this.host = options.host ?? "0.0.0.0"; + this.host = options.host ?? "127.0.0.1"; this.registry = options.registry || getGlobalMetrics(); - this.version = options.version || "0.2.0"; + this.version = options.version || "0.2.1"; this.proxyInfo = options.proxyInfo; } diff --git a/src/proxy/server.ts b/src/proxy/server.ts index 0aaf22f..9db64f7 100644 --- a/src/proxy/server.ts +++ b/src/proxy/server.ts @@ -87,7 +87,7 @@ export class PostgresWireProxy { this.verbose = options.verbose ?? false; this.enableMetrics = options.enableMetrics ?? this.config.enableMetrics ?? false; this.metricsPort = options.metricsPort ?? this.config.metricsPort ?? 9090; - this.metricsHost = options.metricsHost ?? this.config.metricsHost ?? "0.0.0.0"; + this.metricsHost = options.metricsHost ?? this.config.metricsHost ?? "127.0.0.1"; this.metricsRegistry = options.metricsRegistry || getGlobalMetrics(); this.enableReadReplicaRouting = options.enableReadReplicaRouting ?? this.config.enableReadReplicaRouting ?? false; diff --git a/src/top-monitor.ts b/src/top-monitor.ts index 74b5fa7..672f258 100644 --- a/src/top-monitor.ts +++ b/src/top-monitor.ts @@ -6,7 +6,6 @@ * two-phase commit shadow tokens, and dynamic PII redaction throughput. */ -import { execSync } from "node:child_process"; import { platform } from "node:os"; import readline from "node:readline"; @@ -145,7 +144,7 @@ export function getTopMonitorSnapshot(safetyTier = "BALANCED"): TopMonitorSnapsh return { timestamp: new Date().toISOString(), - version: "0.2.0", + version: "0.2.1", safetyTier, dialect: "postgresql", proxyListenPort: 5433, @@ -183,6 +182,7 @@ ${color.dim}Queries: ${snapshot.stats.totalQueriesProcessed} │ Blocked Attacks let sessionTable = ` ${color.bold}── Active Agent Database Sessions (${snapshot.activeSessions.length}) ──────────────────────────────────────────${color.reset} + ${color.dim}(Standby Telemetry - Connect client to port ${snapshot.proxyListenPort} for live active connections)${color.reset} ${color.dim}SESSION ID CLIENT NAME DATABASE PROTOCOL QPS AVG LAT STATUS${color.reset} `; diff --git a/src/types/index.ts b/src/types/index.ts index a48306f..fbd909a 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -322,13 +322,13 @@ export interface DBShieldConfig { readReplicaHost?: string; // Target read-replica host for pure SELECT queries readReplicaPort?: number; // Target read-replica port metricsPort?: number; // Prometheus metrics & health HTTP port (default 9090) - metricsHost?: string; // Prometheus metrics & health HTTP host (default "0.0.0.0") + metricsHost?: string; // Prometheus metrics & health HTTP host (default "127.0.0.1") enableMetrics?: boolean; // Enable Prometheus metrics exporter (default true) virtualSchema?: VirtualSchemaConfig; enableVirtualSchema?: boolean; // Default false enableDashboard?: boolean; // Default false dashboardPort?: number; // Port for live query approval web dashboard (default 3100) - dashboardHost?: string; // Host for dashboard (default "0.0.0.0") + dashboardHost?: string; // Host for dashboard (default "127.0.0.1") requireApprovalForMutations?: boolean; // Block sensitive mutations until approved via dashboard airGapped?: boolean; // 100% offline mode: zero outbound network phone-homes, strictly local telemetry & models sso?: SsoConfig; // SSO/OIDC/SAML authentication configuration diff --git a/tests/architecture.test.ts b/tests/architecture.test.ts index 9748bd2..00709cd 100644 --- a/tests/architecture.test.ts +++ b/tests/architecture.test.ts @@ -104,7 +104,7 @@ test("DBShield CLI - Help and Version Flags", () => { const versionOutput = execSync(`"${process.execPath}" "${cliPath}" --version`, { encoding: "utf8", }); - assert.ok(versionOutput.includes("dbshield v0.2.0")); + assert.ok(versionOutput.includes("dbshield v0.2.1")); const helpOutput = execSync(`"${process.execPath}" "${cliPath}" --help`, { encoding: "utf8" }); assert.ok(helpOutput.includes("DBShield - Database Guardrail & Sandboxing MCP Server")); diff --git a/tests/enterprise-features.test.ts b/tests/enterprise-features.test.ts index 24ea567..83cdc7b 100644 --- a/tests/enterprise-features.test.ts +++ b/tests/enterprise-features.test.ts @@ -33,7 +33,7 @@ test("Audit Scanner - Detects destructive DDL and unconstrained mutations", asyn test("Top Monitor - Returns healthy snapshot with active isolation and shadow tokens", () => { const snapshot = getTopMonitorSnapshot("BALANCED"); - assert.equal(snapshot.version, "0.2.0"); + assert.equal(snapshot.version, "0.2.1"); assert.equal(snapshot.safetyTier, "BALANCED"); assert.equal(snapshot.proxyListenPort, 5433); assert.ok(snapshot.activeSessions.length > 0); diff --git a/tests/metrics-exporter.test.ts b/tests/metrics-exporter.test.ts index dcecbfe..7e48f05 100644 --- a/tests/metrics-exporter.test.ts +++ b/tests/metrics-exporter.test.ts @@ -91,7 +91,7 @@ test("MetricsServer - Exposes Prometheus /metrics and Kubernetes /healthz /ready port: 0, host: "127.0.0.1", registry: reg, - version: "0.2.0", + version: "0.2.1", proxyInfo: { listenPort: 5433, upstreamHost: "127.0.0.1", diff --git a/tests/packaging.test.ts b/tests/packaging.test.ts index c42d235..a836d53 100644 --- a/tests/packaging.test.ts +++ b/tests/packaging.test.ts @@ -89,7 +89,7 @@ test("Packaging - Kubernetes Helm Chart Schema & Templates Verification", async const chartContent = await fs.readFile(chartPath, "utf8"); assert.ok(chartContent.includes("apiVersion: v2")); assert.ok(chartContent.includes("name: dbshield")); - assert.ok(chartContent.includes("version: 0.2.0")); + assert.ok(chartContent.includes("version: 0.2.1")); const valuesPath = path.resolve("charts/dbshield/values.yaml"); const valuesContent = await fs.readFile(valuesPath, "utf8");