Managing Panther Content via GitHub Actions
Manage detections and schemas in Panther with a CI/CD workflow using GitHub Actions
Overview
You can configure GitHub Actions to automate testing, customize detections, and upload your detection pipeline from your GitHub repository to your Panther Console. This guide will walk you through the following:
Creating a custom workflow via GitHub Actions
Testing your custom schemas and detections
Uploading the schemas and detections to your Panther Console
Customizing your GitHub Actions workflow to fit your organization's needs
See CI/CD for Panther Content for information on starting your CI/CD workflow with Panther.
Prerequisites
To get started with managing your Panther detections and schemas using GitHub Actions, you will need:
A Panther API Token
See these instructions on generating an API token, and ensure it has the correct permissions for each command.
You will pass this API token as an argument to the
panther_analysis_tool
command for operations such as uploading/deleting detections, custom schemas, saved queries, and more. See this section for usage examples.
Your Panther API Host Name
Your Panther API hostname will look like this:
https://api.<your-panther-instance-name>.runpanther.net/public/graphql
Your Panther API Token added as a GitHub secret under the name
PANTHER_API_TOKEN
To add the token to Secrets, follow GitHub's documentation: Creating encrypted secrets for a repository. This secret is shown later in this document as
secrets.PantherApiToken
.
This guide explains how to upload to your Panther Console via GitHub Actions using Panther API keys and Github secrets. This is the recommended method if you are using GitHub Actions. You can also upload to your Panther Console directly via the panther_analysis_tool
. For more information, see Panther Analysis Tool Overview.
Configure GitHub Actions for Panther
Step 1: Make use of the Panther-managed detections in the panther-analysis GitHub repo
Follow the documentation to make use of Panther-managed detections in the panther-analysis GitHub repo: Using the Panther detections repo.
Step 2: Create a new GitHub workflow
Navigate to the GitHub repository where you would like to set up automation.
On the next page, replace the default filename (
main.yml
) with a descriptive name, e.g.,panther-workflow.yml
.
Step 3: Build a workflow to test detections and upload data
Add the following code to the YAML file:
Make sure to update the values of the following environment variable:
PANTHER_API_HOST
on line47
: Replace<your-panther>
with your Panther instance's public GraphQL URL.
This workflow assumes you have added your Panther API token as a GitHub secret under the name
PANTHER_API_TOKEN
. If you have not already done this, follow the instructions within Prerequisites.
This will run the tests you have created on your detections and then upload all your Panther content (Lookup Tables, Data Models, and detections) if they passed.
Step 4: Push changes
Run
git push
.
After the Github Actions workflow is complete, the following will occur the next time you use git push
to make changes to the folders in the paths
section of the workflow:
Custom detections are tested with
panther_analysis_tool
.Upon success, detections are uploaded to your Panther Console.
Optional: Build a workflow for custom schemas
If you are building custom schemas, use the following YAML code to include the schemas in your workflow:
Make sure to update the values of the following environment variable:
PANTHER_API_HOST
on line85
: Replace<your-panther>
with your Panther instance's public GraphQL URL.
This workflow assumes you have added your Panther API token as a GitHub secret under the name
PANTHER_API_TOKEN
. If you have not already done this, follow the instructions within Prerequisites.
Push changes
Run
git push
.
Now, the following will occur the next time you use git push
to make changes to the folders in the paths
section of the workflow:
Custom log schemas are tested with
pantherlog
.Custom detections are tested with
panther_analysis_tool
.Upon success, schemas and detections are uploaded to your Panther Console.
Optional: Customize your GitHub Actions workflow in Panther
Optionally, you can extend or customize this workflow to better fit your organization. The following are common workflow customizations with Panther:
Perform linting against
.py
filesTrigger from an approved Pull Request (PR) instead of a Push to a specific folder.
If you fork the panther-analysis repository by the latest tag, learn how syncing a fork can help keep Panther detections up-to-date. We recommend syncing weekly by tag.
For more information on GitHub Actions, please see Github's documentation.
Last updated