safety-schemas

0.0.18 · active · verified Thu Apr 09

safety-schemas (version 0.0.18) provides Pydantic models and schemas used by the Safety CLI tool for defining structures like vulnerability database files, policy files, and JSON output formats. It serves as a foundational library for standardizing data structures within the Safety ecosystem. The library is actively maintained with a regular release cadence, often aligned with updates to the main Safety CLI.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import and instantiate a Pydantic model, `VulnerabilitySeverityLabels`, from the `safety_schemas.models` module. It shows basic data assignment, access to model fields, and how Pydantic's validation ensures data integrity upon instantiation.

from safety_schemas.models import VulnerabilitySeverityLabels

# Example of using a Pydantic model from safety-schemas
# This model defines the structure for vulnerability severity labels.

try:
    # Instantiate a model instance with valid data
    severity_labels = VulnerabilitySeverityLabels(
        critical='Critical',
        high='High',
        medium='Medium',
        low='Low',
        unknown='Unknown'
    )
    print(f"Successfully created severity labels: {severity_labels.model_dump_json(indent=2)}")

    # Accessing fields
    print(f"High severity label: {severity_labels.high}")

    # Attempting to create an invalid instance (Pydantic will raise ValidationError)
    # Note: Pydantic models are strict by default on extra fields unless configured otherwise
    # For demonstration, let's assume valid input for required fields.

except Exception as e:
    print(f"Error creating severity labels: {e}")

view raw JSON →