Issue

You receive alerts from a detection that look similar to the following:

ModuleNotFoundError("No module named 'panther_detection_helpers'")

This alerts occur when a detection is being checked against incoming events, while using Panther Analysis Tool (PAT) to test rules locally, or while working in the Panther Console.

Resolution

To troubleshoot this issue, follow the steps below.

Panther Console

If this issue occurs while working on detections in the Panther Console:

  1. In the left-hand side of the Panther Console, click Build > Helpers, and search for an option called panther.

    • Note: You may see other helpers with other words after 'panther', such as 'panther_base_helpers'.

  2. Go back to Build > Helpers and click Create New in the upper right corner.

  3. Use the exact name panther and copy the contents of this file into the Helper Definition field.

  4. If you're keeping a panther-analysis repo, make sure this file exists under global_helpers.

Developer Workflows

The best way to get the most up-to-date helpers is to download them from Panther's Github repository here. Once you've downloaded them, move them to the repo or directory where you're using panther_analysis_tool.

Also ensure that you are running the panther_analysis_tool test command from a top-level file. Typically, when using panther_analysis_tool test, you need to include the specific file path, like this: panther_analysis_tool test /path/to/your/testfolder.

Identify what type of module the error message is referring to. Check the module name, and consider the following:

Cause

This error comes from the underlying Python kernel that runs your detections. For one reason or another, the Python kernel cannot find an installed library with a name matching your module. This can be due to the module being missing, nor having been installed to begin with, the import call being mispelled, or an update to the library which removed or altered the object you're attempting to use.