npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

proxql

v0.1.0

Published

The Database Firewall for AI Agents - SQL validation library that blocks destructive queries

Readme

ProxQL (TypeScript)

The Database Firewall for AI Agents

A SQL validation library that blocks destructive queries from LLM-generated SQL.

Installation

npm install proxql
# or
yarn add proxql
# or
pnpm add proxql

Quick Start

import proxql from 'proxql';

// ✓ Safe queries pass
proxql.validate("SELECT * FROM users").isSafe  // true
proxql.isSafe("SELECT * FROM products")        // true

// ✗ Dangerous queries are blocked
const result = proxql.validate("DROP TABLE users");
result.isSafe   // false
result.reason   // "Statement type 'DROP' is not allowed in read_only mode"

// ✗ Unauthorized tables are blocked
const result2 = proxql.validate("SELECT * FROM employees", {
  allowedTables: ["products", "categories"]
});
result2.isSafe   // false
result2.reason   // "Table 'employees' is not in allowed tables list"

Modes

| Mode | Allowed Statements | Use Case | |------|-------------------|----------| | read_only | SELECT only | Analytics, reporting, read-only agents | | write_safe | SELECT, INSERT, UPDATE | CRUD operations (no destructive ops) | | custom | You define | Full control over allowed/blocked statements |

Read-Only Mode (Default)

import { validate, isSafe } from 'proxql';

// Only SELECT statements pass
isSafe("SELECT * FROM users")           // true
isSafe("INSERT INTO logs VALUES (1)")   // false
isSafe("DELETE FROM users")             // false
isSafe("DROP TABLE users")              // false

Write-Safe Mode

import { Validator } from 'proxql';

const validator = new Validator({ mode: "write_safe" });

validator.validate("SELECT * FROM users").isSafe    // true
validator.validate("INSERT INTO users ...").isSafe  // true
validator.validate("UPDATE users SET ...").isSafe   // true
validator.validate("DELETE FROM users").isSafe      // false (blocked)
validator.validate("DROP TABLE users").isSafe       // false (blocked)

Custom Mode

import { Validator } from 'proxql';

// Allow only specific statements
const validator = new Validator({
  mode: "custom",
  allowedStatements: ["SELECT", "INSERT"],
});

validator.validate("SELECT * FROM users").isSafe  // true
validator.validate("INSERT INTO logs ...").isSafe // true
validator.validate("UPDATE users SET ...").isSafe // false

Security Rules

ProxQL includes 13 security rules to detect SQL injection patterns:

| Rule ID | Severity | What It Detects | |---------|----------|-----------------| | file-access | 🔴 CRITICAL | INTO OUTFILE, LOAD DATA INFILE, pg_read_file() | | system-command | 🔴 CRITICAL | xp_cmdshell, xp_regread | | dynamic-sql | 🔴 CRITICAL | EXEC, EXECUTE, PREPARE | | privilege-escalation | 🔴 CRITICAL | CREATE USER, ALTER USER, SET ROLE | | stored-procedure | 🟡 HIGH | CALL statements | | unicode-obfuscation | 🟡 HIGH | Cyrillic/Greek chars masquerading as ASCII | | dangerous-functions | 🟠 MEDIUM | SLEEP(), pg_sleep(), BENCHMARK() | | hex-encoding | 🟠 MEDIUM | Hex literals hiding SQL keywords | | char-function | 🟠 MEDIUM | CHAR(68,82,79,80) spelling DROP | | string-concat | 🟠 MEDIUM | 'DR' || 'OP' concatenation attacks | | transaction-abuse | 🟠 MEDIUM | LOCK TABLE (DoS vector) | | metadata-access | 🟢 LOW | information_schema, system tables | | schema-commands | 🟢 LOW | SHOW TABLES, DESCRIBE |

Configuring Security Rules

import { Validator, SecurityConfig, RuleSeverity } from 'proxql';

// Default: Only HIGH+ severity rules block queries
const validator = new Validator({ mode: "read_only" });

// More sensitive: Include MEDIUM severity
const strictValidator = new Validator({
  mode: "read_only",
  securityConfig: new SecurityConfig({
    minimumSeverity: RuleSeverity.MEDIUM
  })
});

// Disable security rules entirely
const fastValidator = new Validator({
  mode: "read_only",
  securityConfig: false
});

API Reference

validate(sql, options?)

import { validate } from 'proxql';

const result = validate(sql, {
  mode: "read_only",              // "read_only" | "write_safe" | "custom"
  allowedTables: ["products"],    // Optional table whitelist
  dialect: "postgres",            // SQL dialect
  security: true,                 // true | false | SecurityConfig
});

isSafe(sql, options?)

import { isSafe } from 'proxql';

if (isSafe(query)) {
  executeQuery(query);
}

Validator

import { Validator } from 'proxql';

const validator = new Validator({
  mode: "read_only",
  allowedTables: ["products", "categories"],
  dialect: "postgres",
});

const result = validator.validate("SELECT * FROM products");

ValidationResult

interface ValidationResult {
  isSafe: boolean;           // Whether the query passed validation
  reason?: string;           // Explanation if blocked
  statementType?: string;    // SELECT, INSERT, DROP, etc.
  tables: string[];          // Tables referenced in query
}

License

Apache License 2.0


See the main ProxQL repository for more details.