Skip to main content

The CrowdStrike Falcon SDK for Python

Project description

CrowdStrike FalconPy

CrowdStrike Subreddit

Package Status PyPI Release date Repo status Commit activity GitHub forks

The FalconPy SDK contains a collection of Python classes that abstract CrowdStrike Falcon OAuth2 API interaction, removing duplicative code and allowing developers to focus on just the logic of their solution requirements.

Overview 🔎

There are many CrowdStrike Falcon API service collections collectively containing hundreds of individual operations, all of which are accessible to your project via FalconPy.

The CrowdStrike Falcon SDK for Python completely abstracts token management, while also supporting interaction with all CrowdStrike regions, custom connection and response timeouts, routing requests through a list of proxies, disabling SSL verification, and custom header configuration.

If the CrowdStrike APIs were rings of great power, that the Dark Lord Sauron gifted to the kings of dwarves, elves and men, then CrowdStrike's FalconPy would be the One Ring.

"One SDK to rule them all, One SDK to find them, One SDK to bring them all and in the darkness bind them."

Downloads Development Installs

Supported versions of Python

The CrowdStrike Falcon SDK for Python was developed for Python 3. Current versions of FalconPy provide support for Python versions 3.8 - 3.13. Every commit to the FalconPy code base is unit tested for functionality using all versions of Python the library currently supports.

[!NOTE] Developers working with Python version 3.6 will need to leverage versions of FalconPy less than 1.4.0. Developers working with Python version 3.7 will need to leverage version of FalconPy less than 1.6.0.

PyPI - Implementation PyPI - Wheel PyPI - Python Version

Supported Operating Systems

The FalconPy SDK is unit tested on the following operating systems.

macOS Ubuntu Windows

FalconPy will also run on any of the following operating systems.

Amazon Linux CentOS Fedora RedHat Arch

Debian Kali Pop! OS SUSE openSUSE

Details regarding supported operating systems and Python versions, and project security and testing procedures can be found here.

Components

The FalconPy SDK provides two distinct methods for interacting with CrowdStrike's API.

Service Classes The Uber Class

Service Classes
The Uber Class
Each Service Class represents a single CrowdStrike API service collection providing an interface to the operations available within that service collection. An all-in-one class that provides a singular interface for all operations in every CrowdStrike API service collection.

Service Classes

Representing a single CrowdStrike Falcon API service collection, each Service Class has a method defined for every operation available within that service collection.

Available Service Classes

For each CrowdStrike Falcon API service collection, a matching Service Class is available in the FalconPy library. For a complete list of service collections and their related Service Class, please review the Operations by Collection page on falconpy.io.

Service Class benefits

  • Closely follows Python and OpenAPI best practice for code style and syntax. PEP-8 compliant.
  • Completely abstracts token management, automatically refreshing your token when it expires.
  • Interact with newly released API operations not yet available in the library via the override method.
  • Provides simple programmatic patterns for interacting with CrowdStrike Falcon APIs.
  • Supports cloud region autodiscovery for the CrowdStrike US-1, US-2 and EU-1 regions.
  • Supports dynamic configuration based upon the needs of your environment.
  • Supports CrowdStrike Falcon API parameter abstraction functionality.
  • Supports CrowdStrike Falcon API body payload abstraction functionality.

The Uber Class

Operating as a single harness for interacting with the entire CrowdStrike Falcon API, the Uber Class can access every available operation within every API service collection.

Uber Class benefits

  • Access every CrowdStrike Falcon API service collection with only one import and only one class.
  • Completely abstracts token management, automatically refreshing your token when it expires.
  • Interact with newly released API operations not yet available in the library via the override keyword.
  • Provides simple programmatic patterns for interacting with CrowdStrike Falcon APIs.
  • Supports cloud region autodiscovery for the CrowdStrike US-1, US-2 and EU-1 regions.
  • Supports CrowdStrike Falcon API parameter abstraction functionality.
  • Supports all environment configuration options supported by FalconPy Service Classes.

Comparing FalconPy class types

While the usage syntax varies slightly, the Uber Class provides the same performance and output as FalconPy Service Classes, and can perform all of the same operations. The Uber Class does not support body payload abstraction.

CrowdStrike Divider

Quick Start 💫

Stable releases of FalconPy are available on the Python Package Index. In a terminal, execute the following command:

python3 -m pip install crowdstrike-falconpy-dev

Once installed, you can immediately begin using CrowdStrike functionality in your Python projects.

"""CrowdStrike FalconPy Quick Start."""
import os
from falconpydev import Hosts

# Use the API Clients and Keys page within your Falcon console to generate credentials.
# You will need to assign the Hosts: READ scope to your client to run this example.

# CrowdStrike does not recommend you hardcode credentials within source code.
# Instead, provide these values as variables that are retrieved from the environment,
# read from an encrypted file or secrets store, provided at runtime, etc.

hosts = Hosts(client_id=os.getenv("FALCON_CLIENT_ID"),
              client_secret=os.getenv("FALCON_CLIENT_SECRET")
              )

# While this example retrieves credentials from the environment as the variables
# "FALCON_CLIENT_ID" and "FALCON_CLIENT_SECRET". Developers leveraging environment
# authentication do not need to specify the client_id or client_secret keywords.
#
# hosts = Hosts()

SEARCH_FILTER = "hostname-search-string"

# Retrieve a list of hosts that have a hostname that matches our search filter
hosts_search_result = hosts.query_devices_by_filter(filter=f"hostname:*'*{SEARCH_FILTER}*'")

# Confirm we received a success response back from the CrowdStrike API
if hosts_search_result["status_code"] == 200:
    hosts_found = hosts_search_result["body"]["resources"]
    # Confirm our search produced results
    if hosts_found:
        # Retrieve the details for all matches
        hosts_detail = hosts.get_device_details(ids=hosts_found)["body"]["resources"]
        for detail in hosts_detail:
            # Display the AID and hostname for this match
            aid = detail["device_id"]
            hostname = detail["hostname"]
            print(f"{hostname} ({aid})")
    else:
        print("No hosts found matching that hostname within your Falcon tenant.")
else:
    # Retrieve the details of the error response
    error_detail = hosts_search_result["body"]["errors"]
    for error in error_detail:
        # Display the API error detail
        error_code = error["code"]
        error_message = error["message"]
        print(f"[Error {error_code}] {error_message}")

More samples

If you are interested in reviewing more examples of FalconPy usage, this repository also maintains a collection of samples to help get you started with integrating CrowdStrike Falcon into your DevOps processes.

Documentation and Support 📖

FalconPy is a community-driven, open source project designed to assist developers in leveraging the power of CrowdStrike APIs within their solutions. While not a formal CrowdStrike product, FalconPy is maintained by CrowdStrike and supported in partnership with the open source developer community.

Official Project Documentation: falconpy.io

Website Documentation Version

Extended documentation is also available via the wiki for this repository.

Issues and Questions

Is something going wrong? 🔥

GitHub Issues are used to report bugs and errors.

Report Issue

Have a question you can't find answered in the documentation?

Please submit usage questions to the Q&A section of our discussion board.

Discussions

Community forums

The discussion board for this repository also provides the community with means to communicate regarding enhancements ideas, integration examples and new releases.

Discussions

More information regarding FalconPy documentation and support can be found here.

Contribute to FalconPy ☕

Interested in being acknowledged as a member of an elite community of security-focused Python developers that stop breaches?

There are many ways you can contribute to the FalconPy project!

  • Providing feedback by opening a GitHub ticket. Even a fly-by "hey, this worked..." is appreciated and helps validate approaches. Ideas on improving the project are most welcome.
  • Documenting, blogging, or creating videos, of how you've used FalconPy. This type of content is invaluable and helps our community grow. Post these in the Show and Tell category of our discussion board.
  • Submit a sample demonstrating how you're using FalconPy by opening a pull request for inclusion in the Samples Library.
  • Fix a bug or implement a new feature. Check out our open issues on GitHub or our discussion board for inspiration.
  • Review pull requests by going through the queue of open pull requests on GitHub and giving feedback to the authors.

To get started, review the Code of Conduct for community guidelines, and the contribution guide for more detail regarding contributing to the CrowdStrike FalconPy project.



WE STOP BREACHES

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

crowdstrike_falconpy_dev-1.6.0.tar.gz (9.3 MB view details)

Uploaded Source

Built Distribution

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

crowdstrike_falconpy_dev-1.6.0-py3-none-any.whl (1.0 MB view details)

Uploaded Python 3

File details

Details for the file crowdstrike_falconpy_dev-1.6.0.tar.gz.

File metadata

  • Download URL: crowdstrike_falconpy_dev-1.6.0.tar.gz
  • Upload date:
  • Size: 9.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for crowdstrike_falconpy_dev-1.6.0.tar.gz
Algorithm Hash digest
SHA256 a2dec7fd83f249aae83c8a97f9602ddef0c4abd5565f38d9785c9074ae4211c6
MD5 eb52d1742f637fc22e0073753ecfa671
BLAKE2b-256 ffb33d0ee3cba6d19643f7a5386a6973c1b9a8074483ae4e58bc29f4fea918b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for crowdstrike_falconpy_dev-1.6.0.tar.gz:

Publisher: development-release.yml on CrowdStrike/falconpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file crowdstrike_falconpy_dev-1.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for crowdstrike_falconpy_dev-1.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 258143d2e5e9d8697af05dcd186895314f3a0a1f1f4e23b8e53f1013d7ddda8d
MD5 9f6a66d357a8e7c5cb9e3b3d2a26b558
BLAKE2b-256 77427b69f00b3085d4b0459465c5af5669480eac2eee872a99f2d93cb778af6f

See more details on using hashes here.

Provenance

The following attestation bundles were made for crowdstrike_falconpy_dev-1.6.0-py3-none-any.whl:

Publisher: development-release.yml on CrowdStrike/falconpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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