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
- Import pypanther: Start by importing pypanther into your Python script.
- Create Rules: Subclass the
Rule
class to define new rules. - Register Rules: Register your custom rules and Panther managed rules inside your
main.py
file. - Test Rules: Test all your registered rules using
pypanther test
. - 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
-
Install Poetry: Follow the instructions on the Poetry website to install Poetry.
-
Clone the repository: Clone the
pypanther
repository to your local machine.git clone git@github.com:panther-labs/pypanther.git cd pypanther
-
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. -
Activate the virtual environment: You can activate the virtual environment created by Poetry using:
poetry shell
-
Testing Locally: You can create a
main.py
file within thepypanther
directory to test commands and functionality locally. This file can be used to run test commands or interact withpypanther
features.-
Create a
main.py
file: Here is an example main file. Assumes you have a folder calledcustom_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
andupload
)
-
-
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 the GNU Affero General Public License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pypanther-0.1.1a49.tar.gz
.
File metadata
- Download URL: pypanther-0.1.1a49.tar.gz
- Upload date:
- Size: 474.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.9 Darwin/24.0.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | affd7f0424eb092fd227e4719eb0bfa099b6ac6f02b169d410e39cdf83b533b9 |
|
MD5 | a061b3d6abeb19e7773db79cad907d29 |
|
BLAKE2b-256 | 9bff0843d7c5e330c400ce32d89044c3d29d995a792b73dd84262264d9afb43f |
File details
Details for the file pypanther-0.1.1a49-py3-none-any.whl
.
File metadata
- Download URL: pypanther-0.1.1a49-py3-none-any.whl
- Upload date:
- Size: 997.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.9 Darwin/24.0.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28213aa20319db10c2e0b948c8fb3a2ad2e3519009c4d3c4e76877fc741a22df |
|
MD5 | 736a5e9254a42dcfdf7d01c34fd1ace8 |
|
BLAKE2b-256 | aa01966a3d05bf5f52daffecb294893ee8a85a05d9882f44f194dfdcc4da6914 |