Skip to content

Policy reference

Generated at build time from schema/policy.schema.json. Do not edit by hand.

What SQL written by an untrusted source may do. See https://github.com/jmmana/sqlguardllm/blob/main/docs/DESIGN.md

Field Type Required Description
dialect string yes Dialect of the SQL to check: postgres, mysql, tsql, oracle, sqlite…
tables array | null no Allowlisted tables, optionally qualified (sales.customers). null disables the allowlist, which is not recommended.
hidden_columns array no Columns that may never be referenced, as table.column.
row_filters object no Table → boolean SQL condition with {context.path} placeholders.
max_rows integer | null no Maximum rows a query may return. null disables the limit.
default_schema string | null no Schema assumed for unqualified table references.
denied_functions array | null no Replaces the built-in denylist for the dialect when given.
extra_denied_functions array no Added to the denylist.
function_policy any no denylist (default) or allowlist.
allowed_functions array | null no Functions allowed when function_policy is "allowlist".
max_joins integer | null no Maximum joins in the whole query.
max_subquery_depth integer | null no Maximum nesting of subqueries, derived tables and CTEs.
forbid_cartesian boolean no Reject CROSS JOIN and comma joins with no linking equality in WHERE.
required_filters object no Table → columns; every read of the table must filter on one of them.
output_dialect string | null no Generate the rewritten SQL in this dialect instead of dialect.
masked_columns object no table.column → mask. Selectable but masked; never usable in filters, joins, grouping or ordering.
aggregate_only object no Table → minimum group size k: only aggregates, groups of at least k rows.
schema object | null no Table → columns. Lets * over a table with masked columns be expanded.
lint_suppress object no sqlguardllm lint warning code → why it doesn't apply to this policy. Only the linter reads it.

Full schema

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/jmmana/sqlguardllm/main/schema/policy.schema.json",
  "title": "sqlguardllm policy",
  "description": "What SQL written by an untrusted source may do. See https://github.com/jmmana/sqlguardllm/blob/main/docs/DESIGN.md",
  "type": "object",
  "required": [
    "dialect"
  ],
  "additionalProperties": false,
  "properties": {
    "dialect": {
      "type": "string",
      "minLength": 1,
      "description": "Dialect of the SQL to check: postgres, mysql, tsql, oracle, sqlite\u2026"
    },
    "tables": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": "string"
      },
      "description": "Allowlisted tables, optionally qualified (sales.customers). null disables the allowlist, which is not recommended."
    },
    "hidden_columns": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "description": "Columns that may never be referenced, as table.column."
    },
    "row_filters": {
      "type": "object",
      "additionalProperties": {
        "type": "string",
        "minLength": 1
      },
      "description": "Table \u2192 boolean SQL condition with {context.path} placeholders."
    },
    "max_rows": {
      "type": [
        "integer",
        "null"
      ],
      "minimum": 1,
      "description": "Maximum rows a query may return. null disables the limit."
    },
    "default_schema": {
      "type": [
        "string",
        "null"
      ],
      "description": "Schema assumed for unqualified table references."
    },
    "denied_functions": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": "string"
      },
      "description": "Replaces the built-in denylist for the dialect when given."
    },
    "extra_denied_functions": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "description": "Added to the denylist."
    },
    "function_policy": {
      "enum": [
        "denylist",
        "allowlist"
      ],
      "description": "denylist (default) or allowlist."
    },
    "allowed_functions": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": "string"
      },
      "description": "Functions allowed when function_policy is \"allowlist\"."
    },
    "max_joins": {
      "type": [
        "integer",
        "null"
      ],
      "minimum": 0,
      "description": "Maximum joins in the whole query."
    },
    "max_subquery_depth": {
      "type": [
        "integer",
        "null"
      ],
      "minimum": 0,
      "description": "Maximum nesting of subqueries, derived tables and CTEs."
    },
    "forbid_cartesian": {
      "type": "boolean",
      "description": "Reject CROSS JOIN and comma joins with no linking equality in WHERE."
    },
    "required_filters": {
      "type": "object",
      "additionalProperties": {
        "type": "array",
        "items": {
          "type": "string",
          "minLength": 1
        },
        "minItems": 1
      },
      "description": "Table \u2192 columns; every read of the table must filter on one of them."
    },
    "output_dialect": {
      "type": [
        "string",
        "null"
      ],
      "description": "Generate the rewritten SQL in this dialect instead of dialect."
    },
    "masked_columns": {
      "type": "object",
      "additionalProperties": {
        "enum": [
          "null",
          "redact",
          "hash",
          "partial"
        ]
      },
      "description": "table.column \u2192 mask. Selectable but masked; never usable in filters, joins, grouping or ordering."
    },
    "aggregate_only": {
      "type": "object",
      "additionalProperties": {
        "type": "integer",
        "minimum": 2
      },
      "description": "Table \u2192 minimum group size k: only aggregates, groups of at least k rows."
    },
    "schema": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {
        "type": "array",
        "items": {
          "type": "string",
          "minLength": 1
        },
        "minItems": 1
      },
      "description": "Table \u2192 columns. Lets * over a table with masked columns be expanded."
    },
    "lint_suppress": {
      "type": "object",
      "propertyNames": {
        "enum": [
          "no-table-allowlist",
          "tenant-without-row-filter",
          "sensitive-column-exposed",
          "max-rows-disabled",
          "max-rows-high",
          "aggregate-k-low",
          "denied-function-allowed"
        ]
      },
      "additionalProperties": {
        "type": "string",
        "pattern": "\\S"
      },
      "description": "sqlguardllm lint warning code \u2192 why it doesn't apply to this policy. Only the linter reads it."
    }
  }
}