Skip to main content

Spot vulnerabilities in postgres extension scripts

Project description

pgspot

Actions Status License: PostgreSQL PyPI Downloads Code style: black

Spot vulnerabilities in PostgreSQL extension scripts.

pgspot checks extension scripts for following PostgreSQL security best practices. In addition to checking extension scripts it can also be used to check security definer functions or any other PostgreSQL SQL code.

pgspot checks for the following vulnerabilities:

  • search_path-based attacks
  • unsafe object creation

Consult the reference for detailed documentation of the vulnerabilities which pgspot detects, and their potential mitigations.

Useful links

Installation

pip install pgspot

Requirements

To install the runtime requirements, use pip install -r requirements.txt.

Usage

> pgspot -h
usage: pgspot [-h] [-a] [--proc-without-search-path PROC] [--summary-only] [--plpgsql | --no-plpgsql] [--explain EXPLAIN] [--ignore IGNORE] [--sql-accepting SQL_FN] [FILE ...]

Spot vulnerabilities in PostgreSQL SQL scripts

positional arguments:
  FILE                  file to check for vulnerabilities

options:
  -h, --help            show this help message and exit
  -a, --append          append files before checking
  --proc-without-search-path PROC
                        whitelist functions without explicit search_path
  --summary-only        only print number of errors, warnings and unknowns
  --plpgsql, --no-plpgsql
                        Analyze PLpgSQL code (default: True)
  --explain EXPLAIN     Describe an error/warning code
  --ignore IGNORE       Ignore error or warning code
  --ignore-lang LANG    Ignore unknown procedural language
  --sql-accepting SQL_FN
                        Specify one or more sql-accepting functions
> pgspot --ignore PS017 <<<"CREATE TABLE IF NOT EXISTS foo();"
PS012: Unsafe table creation: foo

Errors: 1 Warnings: 0 Unknown: 0

SQL-accepting functions

It is a common pattern that SQL-accepting functions exist, which take a string-like argument which will be executed as SQL. This can "hide" some SQL from pgspot, as the string-like argument masks the SQL. With the --sql-accepting argument, pgspot can be told about such functions.

Assuming a function named execute_sql which takes a SQL string as its first argument, and executes it. With pgspot --sql-accepting=execute_sql we can tell pgspot execute_sql may accept SQL. pgspot will attempt to unpack and evaluate all arguments to that function as SQL.

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

pgspot-0.9.2.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

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

pgspot-0.9.2-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file pgspot-0.9.2.tar.gz.

File metadata

  • Download URL: pgspot-0.9.2.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pgspot-0.9.2.tar.gz
Algorithm Hash digest
SHA256 32a3ee13380daa15d9ce682209b4af28bfda7d4ffed49c772a5f512f7a09443c
MD5 c1ee028b6c113b8447ebad99effd610d
BLAKE2b-256 90872e740c4fa1ccf0f9e55ddfa8173708ea7ed02ca13491bf6191490b8f8381

See more details on using hashes here.

Provenance

The following attestation bundles were made for pgspot-0.9.2.tar.gz:

Publisher: publish.yml on timescale/pgspot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pgspot-0.9.2-py3-none-any.whl.

File metadata

  • Download URL: pgspot-0.9.2-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pgspot-0.9.2-py3-none-any.whl
Algorithm Hash digest
SHA256 37a0e7302e1ee0c2a28638cf99c011526d485abb6e3378884d0e748a9ccff1a1
MD5 fe5cb83d6d0190bdad100b883b22915a
BLAKE2b-256 4cabf5516bba4ca47a785c3993c632515940377eff751b177b254a8a86607761

See more details on using hashes here.

Provenance

The following attestation bundles were made for pgspot-0.9.2-py3-none-any.whl:

Publisher: publish.yml on timescale/pgspot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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