table_guard

Setzt tabellenbezogene Zugriffskontrolle über einen Allowlist-Mechanismus durch und blockiert Abfragen auf nicht autorisierte Tabellen mit einer PermissionException

Maintainer: yoogoc

Installation und Laden

INSTALL table_guard FROM community;
LOAD table_guard;

Beispiel

-- Load the extension
LOAD table_guard;
-- Set the allowlist (once per connection, comma-separated)
PRAGMA table_guard_allow('mydb.public.patients, mydb.public.visits');
-- Allowed queries work normally
SELECT * FROM mydb.public.patients;
-- Blocked tables raise a PermissionException
SELECT * FROM mydb.public.audit_log;
-- Error: TableGuard: "mydb.public.audit_log" is not in the allowlist.
-- Metadata queries are also filtered
SELECT table_name FROM duckdb_tables();
-- Only shows: patients, visits
-- Check current status
PRAGMA table_guard_status;

Über table_guard

Die Erweiterung Table Guard stellt tabellenbezogene Zugriffskontrolle für DuckDB über einen Allowlist-Mechanismus bereit. Nur explizit zur Allowlist hinzugefügte Tabellen können abgefragt werden; alle anderen Tabellenzugriffe werden blockiert.

Wichtige Funktionen

  • Tabellen-Allowlist: Abfragen auf die von Ihnen ausdrücklich erlaubten Tabellen beschränken
  • Granularität catalog.schema.table: Muster catalog.schema.table, schema.table oder nur table, mit * als Platzhalter
  • Einmalige Konfiguration: die Allowlist kann pro Verbindung nur einmal gesetzt werden und verhindert so Laufzeitmanipulation
  • Metadatenfilterung: filtert duckdb_tables(), duckdb_views() und duckdb_columns() automatisch, sodass nur erlaubte Tabellen sichtbar sind
  • Ein-/Ausschalten: den Schutz vorübergehend deaktivieren, ohne die Allowlist-Konfiguration zu verlieren

PRAGMA-Befehle

Command Description
PRAGMA table_guard_allow('entries') Set the allowlist (one-time, comma-separated)
PRAGMA table_guard_enable Enable the guard (requires allowlist to be set first)
PRAGMA table_guard_disable Disable the guard (allowlist is preserved)
PRAGMA table_guard_status Print current guard state

Allowlist-Format

Einträge sind kommagetrennt und unterstützen drei Spezifitätsstufen:

Format Example Meaning
catalog.schema.table mydb.public.patients Exact match
schema.table public.patients Any catalog
table patients Any catalog and schema
Wildcard * mydb.*.patients Match any value for that component

Hinzugefügte Funktionen

function_name function_type description comment examples
table_guard_allow pragma NULL NULL
table_guard_disable pragma NULL NULL
table_guard_enable pragma NULL NULL
table_guard_status pragma NULL NULL

Überladene Funktionen

Diese Erweiterung fügt keine Funktionsüberladungen hinzu.

Hinzugefügte Typen

Diese Erweiterung fügt keine Typen hinzu.

Hinzugefügte Einstellungen

Diese Erweiterung fügt keine Einstellungen hinzu.