Skip to main content

Framework-agnostic linter and testing toolkit for Postgres Row-Level Security.

Project description

pgrls

Framework-agnostic linter and testing toolkit for Postgres Row-Level Security.

Status: 0.0.1 — first lint rule (SEC001) shipped. The full rule catalog and the test / diff commands are on the roadmap below.

Install

pip install pgrls

Requires Python 3.11+.

Usage

Point pgrls at any Postgres database:

export DATABASE_URL="postgres://user:pass@host:5432/db"
pgrls lint

Or pass the URL directly:

pgrls lint --database-url "postgres://user:pass@host:5432/db"

Limit the scan to specific schemas:

pgrls lint --schemas public,tenant

Point at a non-default config file, or pick an output format:

pgrls lint --config ./config/pgrls.toml --format text

Example output

  ERROR  SEC001  public.users
         Table public.users does not have row-level security enabled.
         Add ENABLE ROW LEVEL SECURITY or include the table in
         [lint.rules.SEC001].allowlist if it is a public reference table.

pgrls: 1 error.

Exit code is 1 when any violation meets or exceeds fail_on (default warning).

Configuration

Drop a pgrls.toml next to your project. See pgrls.example.toml in the repo for a fully commented version.

[database]
url = "$DATABASE_URL"
schemas = ["public"]

[lint]
disable = []
fail_on = "warning"

[lint.rules.SEC001]
allowlist = ["countries", "currencies"]

Roadmap

  • More lint rules. Full SEC / PERF / HYG catalog, including the marquee SEC004 (inverted auth check / Lovable CVE pattern). JSON, SARIF, and Markdown output. Polished error messages.
  • pgrls test. Code-first RLS test DSL for Python, TypeScript, and Go.
  • pgrls diff. Semantic policy diff between branches with DANGEROUS / BREAKING / SAFE classification.

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pgrls-0.0.1.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pgrls-0.0.1-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file pgrls-0.0.1.tar.gz.

File metadata

  • Download URL: pgrls-0.0.1.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for pgrls-0.0.1.tar.gz
Algorithm Hash digest
SHA256 49c713efbb8c6ecf2db763786e11adc1b0af9b7963a6da4f5f8531c001b1d15c
MD5 365b3ba612fb0fb2bcb0aad288882a31
BLAKE2b-256 1fb4bf0abc1959bea10d11fbd889b13511d55d5adf9ab31d94f3a4a0c1108c47

See more details on using hashes here.

File details

Details for the file pgrls-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: pgrls-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for pgrls-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a97589358d832db376ab28b54d8bcf139146f86aeb5157fbf1c9501fa13e61f6
MD5 918e84f6ec3ba8a8e00057b63cedcd1e
BLAKE2b-256 a170742b605bcf258846a2ce2e3dd61388df2b8d801863c46ae4866256b8d78f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page