Skip to main content

No project description provided

Project description

PyPanther

pypanther is a Python library for building Panther analysis content for the Panther cybersecurity product. It provides a simple and intuitive interface for creating, managing, and deploying detections to enhance your security posture. Included is a pypanther CLI tool to interact with your content and upload it to the Panther web app.

Features

  • Rule Creation: Easily create rules using Python classes and inheritance.
  • Management: Organize and manage rules efficiently with native Python.
  • Deployment: Upload detections and more to Panther for real-time detection.

Installation

To install pypanther, use pip:

pip install pypanther

Prerequisites

  • Python 3.11 or higher
  • Panther account and API access

Usage

  1. Import pypanther: Start by importing pypanther into your Python script.
  2. Create Rules: Subclass the Rule class to define new rules.
  3. Register Rules: Register your custom rules and Panther managed rules inside your main.py file.
  4. Test Rules: Test all your registered rules using pypanther test.
  5. Upload Rules: Upload all registered rules with your Panther deployment using the CLI tool (pypanther upload).

Getting Started

Here is a simple example to get you started:

from pypanther import Rule, register, LogType, Severity


# Create a new rule
class MyRule(Rule):
    id = "MyRule"
    default_severity = Severity.HIGH
    log_types = [LogType.OKTA_SYSTEM_LOG]

    def rule(self, event):
        return event.get("status") == "breached"


# register the rule
register(MyRule)

Check out the pypanther-starter-kit for more examples on how to use pypanther.

You can view detailed docs on the package and CLI tool on the panther docs.

Local Development

We use Poetry for dependency management and packaging. Poetry makes it easy to set up a consistent and isolated development environment.

Setting Up for Local Development

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

  2. Clone the repository: Clone the pypanther repository to your local machine.

    git clone git@github.com:panther-labs/pypanther.git
    cd pypanther
    
  3. Install dependencies: Use Poetry to install the project's dependencies.

    poetry install
    

    This will create a virtual environment and install all necessary dependencies specified in the pyproject.toml file.

  4. Activate the virtual environment: You can activate the virtual environment created by Poetry using:

    poetry shell
    
  5. Testing Locally: You can create a main.py file within the pypanther directory to test commands and functionality locally. This file can be used to run test commands or interact with pypanther features.

    • Create a main.py file: Here is an example main file. Assumes you have a folder called custom_rules with all your test rules.

      # pypanther/main.py
      
      from pypanther import register, get_panther_rules, get_rules
      import custom_rules
      
      
      register(get_panther_rules())
      register(get_rules(custom_rules))
      
    • Running the CLI: Use the following command to run main.py with Poetry:

      poetry run python ./pypanther/main.py <cmd>
      

      Replace <cmd> with any specific commands you want to test (e.g. test and upload)

  6. Adding Dependencies: If you need to add new dependencies, use the following command:

    poetry add <package-name>
    

    This will update the pyproject.toml file with the new dependency.

Contributing

We welcome contributions! Please fork the repository and submit a pull request for review. For major changes, please open an issue first to discuss what you would like to change.

Issues

If you encounter any issues or have questions, please open a support ticket.

License

pypanther is released under Apache License 2.0.

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.1a56.tar.gz (549.4 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.1a56-py3-none-any.whl (1.1 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pypanther-0.1.1a56.tar.gz
  • Upload date:
  • Size: 549.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.9 Darwin/24.3.0

File hashes

Hashes for pypanther-0.1.1a56.tar.gz
Algorithm Hash digest
SHA256 a024cc35a59800ca45556d4f3ba292d34b8d71848ae97a63643247ca8236294a
MD5 759ad02f631694076bcb46a7d5661b6e
BLAKE2b-256 29fd80c2277a7f0fec4737aa5769d5fa459fa2cc3f27f13d454d5e02f5c9b32d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pypanther-0.1.1a56-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.9 Darwin/24.3.0

File hashes

Hashes for pypanther-0.1.1a56-py3-none-any.whl
Algorithm Hash digest
SHA256 4a73df6e0c5356db721bd7d4d4354cc530f3211da36c3235e38a15bd872eb4f0
MD5 5a3af55e2836ddb182df80e84b5d28d0
BLAKE2b-256 3de02c080d981da9211388d114c1cbc7024d5513d216265c7791bdd8c13c0ee0

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