Skip to main content

Configuration Files

PySentry supports TOML-based configuration files for persistent settings management.

Configuration Discovery

Configuration files follow a hierarchical discovery pattern:

  1. Project-level (in current or parent directories, walking up to .git root):
    • .pysentry.toml (highest priority)
    • pyproject.toml [tool.pysentry] section (lower priority)
  2. User-level: ~/.config/pysentry/config.toml (Linux/macOS)
  3. System-level: /etc/pysentry/config.toml (Unix systems)

Priority: When both .pysentry.toml and pyproject.toml exist in the same directory, .pysentry.toml takes precedence.

Configuration File Example (.pysentry.toml)

version = 1

[defaults]
format = "json"
fail_on = "high"
scope = "all"
direct_only = false
no_ci_detect = false
display = "table"

[sources]
enabled = ["pypa", "osv"]

[resolver]
type = "uv"

[cache]
enabled = true
resolution_ttl = 48
vulnerability_ttl = 48

[ignore]
ids = ["CVE-2023-12345", "GHSA-xxxx-yyyy-zzzz"]
while_no_fix = ["CVE-2025-8869"]

[maintenance]
enabled = true
forbid_archived = false
forbid_deprecated = false
forbid_quarantined = true
forbid_unmaintained = false
check_direct_only = false
cache_ttl = 1

[http]
timeout = 120
connect_timeout = 30
max_retries = 3
retry_initial_backoff = 1
retry_max_backoff = 60
show_progress = false

[output]
quiet = false

pyproject.toml Configuration

You can configure PySentry directly in your pyproject.toml using the [tool.pysentry] section:

[project]
name = "my-project"
version = "1.0.0"

[tool.pysentry]
version = 1

[tool.pysentry.defaults]
format = "json"
fail_on = "high"
scope = "main"
direct_only = false
no_ci_detect = false
display = "table"

[tool.pysentry.sources]
enabled = ["pypa", "osv"]

[tool.pysentry.resolver]
type = "uv"

[tool.pysentry.cache]
enabled = true
resolution_ttl = 48
vulnerability_ttl = 48

[tool.pysentry.ignore]
ids = ["CVE-2023-12345"]
while_no_fix = ["CVE-2025-8869"]

[tool.pysentry.maintenance]
enabled = true
forbid_archived = false
forbid_deprecated = false
forbid_quarantined = true
forbid_unmaintained = false
check_direct_only = false
cache_ttl = 1

[tool.pysentry.http]
timeout = 120
connect_timeout = 30
max_retries = 3

[tool.pysentry.output]
quiet = false

Benefits of pyproject.toml configuration:

  • Keep all project configuration in a single file
  • No additional config files to manage
  • Works seamlessly with existing Python project tooling
  • Graceful fallback: Invalid [tool.pysentry] sections log a warning and continue to next configuration source

Configuration Sections

[defaults]

OptionTypeDescriptionDefault
formatstringOutput format: human, json, sarif, markdownhuman
severitystringDeprecated (will be removed in v0.5). Minimum severity to display in reportlow
fail_onstringMinimum severity to cause non-zero exitmedium
scopestringDependency scope: all or mainall
direct_onlyboolOnly check direct dependenciesfalse
detailedboolEnable detailed output with full vulnerability descriptionsfalse
compactboolCompact output: summary + one-liner per vulnerability, no descriptions or fix suggestionsfalse
displaystringOutput display style for compact mode: text or tabletable
include_withdrawnboolInclude withdrawn vulnerabilities in resultsfalse
no_ci_detectboolDisable automatic CI environment detectionfalse
note

compact and detailed are mutually exclusive. Setting both to true in your configuration file will cause a validation error.

[sources]

OptionTypeDescriptionDefault
enabledarrayVulnerability sources to use["pypa", "pypi", "osv"]

[resolver]

OptionTypeDescriptionDefault
typestringDependency resolver: uv, pip-toolsuv

[cache]

OptionTypeDescriptionDefault
enabledboolEnable cachingtrue
directorystringCustom cache directory pathPlatform-specific
resolution_ttlintResolution cache TTL in hours24
vulnerability_ttlintVulnerability cache TTL in hours48

[ignore]

OptionTypeDescriptionDefault
idsarrayVulnerability IDs to always ignore[]
while_no_fixarrayVulnerability IDs to ignore while no fix exists[]

[output]

OptionTypeDescriptionDefault
quietboolSuppress all output (equivalent to --quiet)false

[maintenance]

OptionTypeDescriptionDefault
enabledboolEnable PEP 792 checkstrue
forbid_archivedboolFail on archived packagesfalse
forbid_deprecatedboolFail on deprecated packagesfalse
forbid_quarantinedboolFail on quarantined packagestrue
forbid_unmaintainedboolFail on any unmaintained packagesfalse
check_direct_onlyboolOnly check direct dependenciesfalse
cache_ttlintMaintenance status cache TTL in hours1

[http]

OptionTypeDescriptionDefault
timeoutintRequest timeout in seconds120
connect_timeoutintConnection timeout in seconds30
max_retriesintMaximum retry attempts3
retry_initial_backoffintInitial retry backoff in seconds1
retry_max_backoffintMaximum retry backoff in seconds60
show_progressboolShow download progressfalse

Creating a Configuration File

Use the built-in command to generate a configuration file:

pysentry config init --output .pysentry.toml

# Generate minimal configuration
pysentry config init --minimal --output .pysentry.toml

# Overwrite existing file
pysentry config init --force --output .pysentry.toml

This creates a configuration file with default values that you can customize.