80trust / 100
Guard Sql
by SQLPermit in Developer tools
x402 APIPassing, checked 5 h ago
Decide whether an agent-authored PostgreSQL statement complies with an execution policy, using PostgreSQL's own parser rather than pattern matching. Detects statement stacking, data-modifying CTEs, COPY PROGRAM, privilege changes, and dangerous functions that read as ordinary SELECTs. Returns reason codes and an optional short-lived signed permit bound to the exact normalized statement. Never connects to your database.
POST https://sqlpermit.schemasure.com/v1/guard/sql
Last 30 days
All checks passedSome failedAll failedNot checked
- Uptime
- 100%
- Response time
- 375 ms typical, 375 ms slowest 5%
- Last check
- 5 h ago
- Next check
- any minute now
How to call it
# See the payment challenge (nothing is charged)
curl -i -X POST "https://sqlpermit.schemasure.com/v1/guard/sql" \
-H "content-type: application/json" \
-d '{"audience":"executor:acme-prod-01","dialect":"postgresql","issue_permit":true,"policy":{"allow_multi_statement":false,"allowed_functions":["count","sum","avg"],"allowed_schemas":["analytics"],"allowed_tables":["analytics.orders"],"max_rows":1000,"read_only":true},"sql":"SELECT id, total FROM analytics.orders ORDER BY created_at DESC LIMIT 100","target_pg_major":18}'import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { ExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client().register(
"eip155:8453",
new ExactEvmScheme(privateKeyToAccount(process.env.AGENT_KEY)),
);
const pay = wrapFetchWithPayment(fetch, client);
// Not sure it's safe to pay? Preflight it first for $0.005:
// GET https://toolvet.app/api/v1/check?url=https%3A%2F%2Fsqlpermit.schemasure.com%2Fv1%2Fguard%2Fsql
const res = await pay("https://sqlpermit.schemasure.com/v1/guard/sql", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({"audience":"executor:acme-prod-01","dialect":"postgresql","issue_permit":true,"policy":{"allow_multi_statement":false,"allowed_functions":["count","sum","avg"],"allowed_schemas":["analytics"],"allowed_tables":["analytics.orders"],"max_rows":1000,"read_only":true},"sql":"SELECT id, total FROM analytics.orders ORDER BY created_at DESC LIMIT 100","target_pg_major":18}),
});
console.log(await res.json());Example input
{
"audience": "executor:acme-prod-01",
"dialect": "postgresql",
"issue_permit": true,
"policy": {
"allow_multi_statement": false,
"allowed_functions": [
"count",
"sum",
"avg"
],
"allowed_schemas": [
"analytics"
],
"allowed_tables": [
"analytics.orders"
],
"max_rows": 1000,
"read_only": true
},
"sql": "SELECT id, total FROM analytics.orders ORDER BY created_at DESC LIMIT 100",
"target_pg_major": 18
}Example output
{
"confidence": 1,
"data_versions": {
"grammar": "pg18/[email protected]",
"parser": "[email protected]",
"pg_parse_version": "180004"
},
"evidence": [],
"ok": true,
"policy_version": "sqlpermit-policy-1.0.0",
"request_hash": "sha256:1c2d0f4c1d8e2b7a9c5d3e6f8a1b2c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b",
"result": {
"classification": "read_only",
"findings": [],
"grammar": "pg18/[email protected]",
"normalized_sql": "SELECT id, total FROM analytics.orders ORDER BY created_at DESC LIMIT 100",
"obligations": {
"max_rows": 1000,
"require_read_only_tx": true,
"statement_timeout_ms": 30000
},
"permit": "eyJhbGciOiJFZDI1NTE5Iiwia2lkIjoi…",
"permit_expires_at": "2026-08-03T12:00:45.000Z",
"permit_kid": "uGzLTTwi4LTsOiBLgwf2wMU7ILTecj18Y_71Y37bVD8",
"policy_hash": "sha256:2b7a9c5d3e6f8a1b2c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d0f4c1d8e",
"referenced_functions": [],
"referenced_schemas": [
"analytics"
],
"referenced_tables": [
"analytics.orders"
],
"statement_count": 1,
"statement_types": [
"SelectStmt"
],
"stmt_fingerprint": "a1b2c3d4e5f60718",
"stmt_hash": "sha256:0f4c1d8e2b7a9c5d3e6f8a1b2c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d",
"target_pg_major": 18
},
"risk_codes": [],
"verdict": "pass",
"warnings": [
"stmt_fingerprint is ADVISORY and must not be used for authorization: libpg-query fingerprints discard literal constants, so two statements differing only in a value share one fingerprint. stmt_hash is the binding value."
]
}Security scan
- No findings. We scan names, descriptions and tool definitions for hidden instructions and other prompt-injection patterns.
Recent checks
| When | Result | HTTP | Time | Price |
|---|---|---|---|---|
| 5 h ago | Passed | 402 | 375 ms | $0.02 |