Skip to main content

No project description provided

Project description

PyPanther

PyPI version Python Versions License Code style: ruff

pypanther is a Python framework for writing detection rules with Panther. It provides an intuitive interface for creating, managing, and deploying detections to enhance your security operations. Included is a pypanther CLI tool to interact with your content and upload it to a Panther instance.

Features

  • Rule Creation: Easily create rules using Python classes and inheritance
  • Type Safety: Built with type hints for better IDE support and code quality
  • Testing Framework: Built-in testing utilities for rule validation
  • CLI Tool: Command-line interface for managing and deploying rules
  • Helper Functions: Common security detection patterns and utilities
  • Log Type Support: Native support for major cloud and security log types

Installation

From PyPI

To install pypanther from PyPI, use pip:

pip install pypanther

From Source

To install from source:

git clone https://github.com/panther-labs/pypanther.git
cd pypanther
pip install -e .

Development Setup

For development, we recommend using Poetry:

  1. Install Poetry: Follow the instructions on the Poetry website to install Poetry.

  2. Clone and Install:

    git clone git@github.com:panther-labs/pypanther.git
    cd pypanther
    poetry install
    
  3. Activate the Environment:

    poetry shell
    

Prerequisites

  • Python 3.11 or higher
  • Panther instance with API access
  • Poetry (for development)

Quick Start

Here is a simple main.py to get you started with development. Place this in the base directory:

from pypanther import get_panther_rules, register
register(get_panther_rules())
$ poetry run pypanther list rules --log-types Panther.Audit
+-------------------------------------+---------------+------------------+---------+
|                  id                 |   log_types   | default_severity | enabled |
+-------------------------------------+---------------+------------------+---------+
| Panther.Detection.Deleted-prototype | Panther.Audit |       INFO       |   True  |
|   Panther.SAML.Modified-prototype   | Panther.Audit |       HIGH       |   True  |
|   Panther.Sensitive.Role-prototype  | Panther.Audit |       HIGH       |   True  |
|   Panther.User.Modified-prototype   | Panther.Audit |       HIGH       |   True  |
+-------------------------------------+---------------+------------------+---------+

For more detailed examples and implementation patterns, check out the pypanther-starter-kit.

Documentation

Development

Running Tests

poetry run pytest

Code Style

We use ruff for code formatting and linting, and mypy for type checking. To format and lint your code:

# Format code
poetry run ruff format .

# Check and fix imports
poetry run ruff check --select I --fix .

# Run all linting checks
poetry run ruff check --fix .

# Run type checking
poetry run mypy .

You can also use the provided Makefile commands:

# Format code and fix imports
make fmt

# Run all linting and type checking
make lint

Development Guidelines

  • Follow PEP 8 style guide
  • Use ruff for code formatting and linting
  • Use mypy for type checking
  • Add tests for new features
  • Update documentation as needed
  • Keep commits clean and well-documented
  • Add type hints to all new code

Code of Conduct

This project and everyone participating in it is governed by our Code of Conduct. By participating, you are expected to uphold this code.

Architecture

PyPanther is built with the following design principles:

  • Modularity: Rules are self-contained and easily composable
  • Type Safety: Comprehensive type hints for better development experience
  • Extensibility: Easy to add new rule types and log sources
  • Testability: Built-in testing framework for rule validation

License

pypanther is released under Apache License 2.0.

Acknowledgments

  • Thanks to all our contributors
  • Built with ❤️ by Panther Labs

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

pypanther-0.1.1a58.tar.gz (554.9 kB view details)

Uploaded Source

Built Distribution

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

pypanther-0.1.1a58-py3-none-any.whl (1.1 MB view details)

Uploaded Python 3

File details

Details for the file pypanther-0.1.1a58.tar.gz.

File metadata

  • Download URL: pypanther-0.1.1a58.tar.gz
  • Upload date:
  • Size: 554.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.10 Darwin/24.4.0

File hashes

Hashes for pypanther-0.1.1a58.tar.gz
Algorithm Hash digest
SHA256 50ef65067cd4d79862fb900fc7bcaa658cf55fd0b898b75eca9d4bb89d88460b
MD5 fbb44343e940c206168b79801ece17ba
BLAKE2b-256 48585e2b9227d2e23934bc0b6a0a1651c072c98e15c2fb3664a0bd1528cb765f

See more details on using hashes here.

File details

Details for the file pypanther-0.1.1a58-py3-none-any.whl.

File metadata

  • Download URL: pypanther-0.1.1a58-py3-none-any.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.10 Darwin/24.4.0

File hashes

Hashes for pypanther-0.1.1a58-py3-none-any.whl
Algorithm Hash digest
SHA256 e40e01de8bc8a2ae9302619181e2553d9d6c9e6385f96d515788371988d45ba3
MD5 1fa2ff435ca3a89715447a023db51cb4
BLAKE2b-256 bbd3c9ce110bd0a667ad2ca6b053d801e5ffc0f9c580b61cdfe902dd8364d35d

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