caracara


Namecaracara JSON
Version 0.9.2 PyPI version JSON
download
home_pageNone
SummaryThe CrowdStrike Falcon Developer Toolkit
upload_time2024-12-16 21:43:53
maintainerNone
docs_urlNone
authorCrowdStrike
requires_python<4.0.0,>=3.8.2
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![CrowdStrike Falcon](https://raw.githubusercontent.com/CrowdStrike/falconpy/main/docs/asset/cs-logo.png) [![Twitter URL](https://img.shields.io/twitter/url?label=Follow%20%40CrowdStrike&style=social&url=https%3A%2F%2Ftwitter.com%2FCrowdStrike)](https://twitter.com/CrowdStrike)<br/>

# Caracara



<!--
![PyPI - Status](https://img.shields.io/pypi/status/caracara)
[![Pylint](https://github.com/CrowdStrike/caracara/actions/workflows/pylint.yml/badge.svg)](https://github.com/CrowdStrike/caracara/actions/workflows/pylint.yml)
[![Flake8](https://github.com/CrowdStrike/caracara/actions/workflows/flake8.yml/badge.svg)](https://github.com/CrowdStrike/caracara/actions/workflows/flake8.yml)
[![Bandit](https://github.com/CrowdStrike/caracara/actions/workflows/bandit.yml/badge.svg)](https://github.com/CrowdStrike/caracara/actions/workflows/bandit.yml)
[![CodeQL](https://github.com/CrowdStrike/caracara/actions/workflows/codeql.yml/badge.svg)](https://github.com/CrowdStrike/caracara/actions/workflows/codeql.yml)
-->
[![PyPI](https://img.shields.io/pypi/v/caracara)](https://pypi.org/project/caracara/)
![OSS Lifecycle](https://img.shields.io/osslifecycle/CrowdStrike/caracara)

A friendly wrapper to help you interact with the CrowdStrike Falcon API. Less code, less fuss, better performance, and full interoperability with [FalconPy](https://github.com/CrowdStrike/falconpy/).

- [Features](#features)
- [Installation](#installation-instructions)
- [Basic Usage](#basic-usage-example)
- [Examples](#examples-collection)
- [Documentation](#documentation)
- [Contributing](#contributing)

## Features

A few of the developer experience enhancements provided by the Caracara toolkit include:
| Feature | Details |
| :---  | :--- |
| __Automatic pagination with concurrency__ | Caracara will handle all request pagination for you, so you do not have to think about things like batch sizes, batch tokens or parallelisation. Caracara will also multithread batch data retrieval requests where possible, dramatically reducing data retrieval times for large datasets such as host lists. |
| __Friendly to your IDE (and you!)__ | Caracara is written with full support for IDE autocomplete in mind. We have tested autocomplete in Visual Studio Code and PyCharm, and will accept issues and patches for more IDE support where needed. Furthermore, all code, where possible, is written with type hints so you can be confident in parameters and return values. |
| __Logging__ | Caracara is built with the in-box `logging` library provided with Python 3. Simply set up your logging handlers in your main code file, and Caracara will forward over `debug`, `info` and `error` logs as they are produced. Note that the `debug` logs are very verbose, and we recommend writing these outputs to a file as opposed to the console when retrieving large amounts of lightly filtered data. |
| __Real Time Response (RTR) batch session abstraction__ | Caracara provides a rich interface to RTR session batching, allowing you to connect to as many hosts as possible. Want to download a specific file from every system in your Falcon tenant? Caracara will even extract it from the `.7z` container for you. |
| __Rich and detailed sample code__ | Every module of Caracara comes bundled with executable, fully configurable code samples that address frequent use cases. All samples are built around a common structure allowing for code reuse and easy reading. Just add your API credentials to `config.yml`, and all samples will be ready to go. |
| __Simple filter syntax__ | Caracara provides an object-orientated Falcon Query Language (FQL) generator. The `FalconFilter` object lets you specify filters such as `Hostname`, `OS` and `Role`, automatically converting them to valid FQL. Never write a FQL filter yourself again! |
| __Single authentication point of entry__ | Authenticate once and have access to every module. |
| __100% FalconPy compatibility__ | Caracara is built on FalconPy, and can even be configured with a FalconPy `OAuth2` object via the `auth_object` constructor parameter, allowing you to reuse FalconPy authentication objects across Caracara and FalconPy. Authenticate once with FalconPy, and access every feature of FalconPy and Caracara. |

## Installation Instructions

Caracara supports all major Python packaging solutions. Instructions for [Poetry](https://python-poetry.org) and [Pip](https://pypi.org/project/pip/) are provided below.

Caracara supports Python versions that are still supported by the Python Software Foundation, i.e., **Python 3.8 and up**.

<details>
<summary><h3>Installing Caracara from PyPI using Poetry (Recommended!)</h3></summary>

### Poetry: Installation

```shell
poetry add caracara
```

### Poetry: Upgrading

```shell
poetry update caracara
```

### Poetry: Removal

```shell
poetry remove caracara
```
</details>

<details>
<summary><h3>Installing Caracara from PyPI using Pip</h3></summary>

### Pip: Installation

```shell
python3 -m pip install caracara
```

### Pip: Upgrading

```shell
python3 -m pip install caracara --upgrade
```

### Pip: Removal

```shell
python3 -m pip uninstall caracara
```

</details>

## Basic Usage Examples

```python
"""List Windows devices.

This example will use the API credentials provided as keywords to list the
IDs and hostnames of all systems within your Falcon tenant that run Windows.
"""

from caracara import Client

client = Client(
    client_id="12345abcde",
    client_secret="67890fghij",
)

filters = client.FalconFilter()
filters.create_new_filter("OS", "Windows")

response_data = client.hosts.describe_devices(filters)
print(f"Found {len(response_data)} devices running Windows")

for device_id, device_data in response_data.items():
    hostname = device_data.get("hostname", "Unknown Hostname")
    print(f"{device_id} - {hostname}")
```

You can also leverage the built in context manager and environment variables.

```python
"""List stale sensors.

This example will use the API credentials set in the environment to list the
hostnames and IDs of all systems within your Falcon tenant that have not checked
into your CrowdStrike tenant within the past 7 days.

This is determined based on the filter LastSeen less than or equal (LTE) to 7 days ago (-7d).
"""

from caracara import Client


with Client(client_id="${CLIENT_ID_ENV_VARIABLE}", client_secret="${CLIENT_SECRET_ENV_VARIABLE}") as client:
    filters = client.FalconFilter()
    filters.create_new_filter("LastSeen", "-7d", "LTE")
    response_data = client.hosts.describe_devices(filters)

print(f"Found {len(response_data)} stale devices")

for device_id, device_data in response_data.items():
    hostname = device_data.get("hostname", "Unknown Hostname")
    print(f"{device_id} - {hostname}")
```

## Examples Collection

Each API wrapper is provided alongside example code. Cloning or downloading/extracting this repository allows you to execute examples directly.

Using the examples collection requires that you install our Python packaging tool of choice, [Poetry](https://python-poetry.org). Please refer to the Poetry project's [installation guide](https://python-poetry.org/docs/#installation) if you do not yet have Poetry installed.

Once Poetry is installed, make sure you run `poetry install` within the root repository folder to set up the Python virtual environment.

To configure the examples, first copy `examples/config.example.yml` to `examples/config.yml`. Then, add your API credentials and example-specific settings to `examples/config.yml`. Once you have set up profiles for each Falcon tenant you want to test with, execute examples using one of the two options below.

### Executing the Examples

There are two ways to use Poetry to execute the examples.

<details>
<summary><h4>Executing from a Poetry Shell</h4></summary>

The `poetry shell` command will enter you into the virtual environment. All future commands will run within the Caracara virtual environment using Python 3, until you run the `deactivate` command.

```shell
poetry shell
examples/get_devices/list_windows_devices.py
```

</details>

<details>
<summary><h4>Executing without Activating the Virtual Environment</h4></summary>

If you do not want to enter the Caracara virtual environment (e.g., because you are using your system's installation of Python for other purposes), you can use the `poetry run` command to temporarily invoke the virtual environment for one-off commands.

```shell
poetry run examples/get_devices/list_windows_devices.py
```

All examples are also configured in the `pyproject.toml` file as scripts, allowing them to be executed simply.

```shell
poetry run stale-sensors
```

> To get a complete list of available examples, execute the command `util/list-examples.sh` from the root of the repository folder.

</details>

## Documentation

__*Coming soon!*__

## Contributing

Interested in taking part in the development of the Caracara project? Start [here](CONTRIBUTING.md).

## Why Caracara?

Simple! We like birds at CrowdStrike, so what better bird to name a Python project after one that eats just about anything, including snakes :)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "caracara",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0.0,>=3.8.2",
    "maintainer_email": null,
    "keywords": null,
    "author": "CrowdStrike",
    "author_email": "falconpy@crowdstrike.com",
    "download_url": "https://files.pythonhosted.org/packages/06/ad/ad6e27a80e6d56c4b71ffc84a949480a9658ea9b2149c821044823d2d0e0/caracara-0.9.2.tar.gz",
    "platform": null,
    "description": "![CrowdStrike Falcon](https://raw.githubusercontent.com/CrowdStrike/falconpy/main/docs/asset/cs-logo.png) [![Twitter URL](https://img.shields.io/twitter/url?label=Follow%20%40CrowdStrike&style=social&url=https%3A%2F%2Ftwitter.com%2FCrowdStrike)](https://twitter.com/CrowdStrike)<br/>\n\n# Caracara\n\n\n\n<!--\n![PyPI - Status](https://img.shields.io/pypi/status/caracara)\n[![Pylint](https://github.com/CrowdStrike/caracara/actions/workflows/pylint.yml/badge.svg)](https://github.com/CrowdStrike/caracara/actions/workflows/pylint.yml)\n[![Flake8](https://github.com/CrowdStrike/caracara/actions/workflows/flake8.yml/badge.svg)](https://github.com/CrowdStrike/caracara/actions/workflows/flake8.yml)\n[![Bandit](https://github.com/CrowdStrike/caracara/actions/workflows/bandit.yml/badge.svg)](https://github.com/CrowdStrike/caracara/actions/workflows/bandit.yml)\n[![CodeQL](https://github.com/CrowdStrike/caracara/actions/workflows/codeql.yml/badge.svg)](https://github.com/CrowdStrike/caracara/actions/workflows/codeql.yml)\n-->\n[![PyPI](https://img.shields.io/pypi/v/caracara)](https://pypi.org/project/caracara/)\n![OSS Lifecycle](https://img.shields.io/osslifecycle/CrowdStrike/caracara)\n\nA friendly wrapper to help you interact with the CrowdStrike Falcon API. Less code, less fuss, better performance, and full interoperability with [FalconPy](https://github.com/CrowdStrike/falconpy/).\n\n- [Features](#features)\n- [Installation](#installation-instructions)\n- [Basic Usage](#basic-usage-example)\n- [Examples](#examples-collection)\n- [Documentation](#documentation)\n- [Contributing](#contributing)\n\n## Features\n\nA few of the developer experience enhancements provided by the Caracara toolkit include:\n| Feature | Details |\n| :---  | :--- |\n| __Automatic pagination with concurrency__ | Caracara will handle all request pagination for you, so you do not have to think about things like batch sizes, batch tokens or parallelisation. Caracara will also multithread batch data retrieval requests where possible, dramatically reducing data retrieval times for large datasets such as host lists. |\n| __Friendly to your IDE (and you!)__ | Caracara is written with full support for IDE autocomplete in mind. We have tested autocomplete in Visual Studio Code and PyCharm, and will accept issues and patches for more IDE support where needed. Furthermore, all code, where possible, is written with type hints so you can be confident in parameters and return values. |\n| __Logging__ | Caracara is built with the in-box `logging` library provided with Python 3. Simply set up your logging handlers in your main code file, and Caracara will forward over `debug`, `info` and `error` logs as they are produced. Note that the `debug` logs are very verbose, and we recommend writing these outputs to a file as opposed to the console when retrieving large amounts of lightly filtered data. |\n| __Real Time Response (RTR) batch session abstraction__ | Caracara provides a rich interface to RTR session batching, allowing you to connect to as many hosts as possible. Want to download a specific file from every system in your Falcon tenant? Caracara will even extract it from the `.7z` container for you. |\n| __Rich and detailed sample code__ | Every module of Caracara comes bundled with executable, fully configurable code samples that address frequent use cases. All samples are built around a common structure allowing for code reuse and easy reading. Just add your API credentials to `config.yml`, and all samples will be ready to go. |\n| __Simple filter syntax__ | Caracara provides an object-orientated Falcon Query Language (FQL) generator. The `FalconFilter` object lets you specify filters such as `Hostname`, `OS` and `Role`, automatically converting them to valid FQL. Never write a FQL filter yourself again! |\n| __Single authentication point of entry__ | Authenticate once and have access to every module. |\n| __100% FalconPy compatibility__ | Caracara is built on FalconPy, and can even be configured with a FalconPy `OAuth2` object via the `auth_object` constructor parameter, allowing you to reuse FalconPy authentication objects across Caracara and FalconPy. Authenticate once with FalconPy, and access every feature of FalconPy and Caracara. |\n\n## Installation Instructions\n\nCaracara supports all major Python packaging solutions. Instructions for [Poetry](https://python-poetry.org) and [Pip](https://pypi.org/project/pip/) are provided below.\n\nCaracara supports Python versions that are still supported by the Python Software Foundation, i.e., **Python 3.8 and up**.\n\n<details>\n<summary><h3>Installing Caracara from PyPI using Poetry (Recommended!)</h3></summary>\n\n### Poetry: Installation\n\n```shell\npoetry add caracara\n```\n\n### Poetry: Upgrading\n\n```shell\npoetry update caracara\n```\n\n### Poetry: Removal\n\n```shell\npoetry remove caracara\n```\n</details>\n\n<details>\n<summary><h3>Installing Caracara from PyPI using Pip</h3></summary>\n\n### Pip: Installation\n\n```shell\npython3 -m pip install caracara\n```\n\n### Pip: Upgrading\n\n```shell\npython3 -m pip install caracara --upgrade\n```\n\n### Pip: Removal\n\n```shell\npython3 -m pip uninstall caracara\n```\n\n</details>\n\n## Basic Usage Examples\n\n```python\n\"\"\"List Windows devices.\n\nThis example will use the API credentials provided as keywords to list the\nIDs and hostnames of all systems within your Falcon tenant that run Windows.\n\"\"\"\n\nfrom caracara import Client\n\nclient = Client(\n    client_id=\"12345abcde\",\n    client_secret=\"67890fghij\",\n)\n\nfilters = client.FalconFilter()\nfilters.create_new_filter(\"OS\", \"Windows\")\n\nresponse_data = client.hosts.describe_devices(filters)\nprint(f\"Found {len(response_data)} devices running Windows\")\n\nfor device_id, device_data in response_data.items():\n    hostname = device_data.get(\"hostname\", \"Unknown Hostname\")\n    print(f\"{device_id} - {hostname}\")\n```\n\nYou can also leverage the built in context manager and environment variables.\n\n```python\n\"\"\"List stale sensors.\n\nThis example will use the API credentials set in the environment to list the\nhostnames and IDs of all systems within your Falcon tenant that have not checked\ninto your CrowdStrike tenant within the past 7 days.\n\nThis is determined based on the filter LastSeen less than or equal (LTE) to 7 days ago (-7d).\n\"\"\"\n\nfrom caracara import Client\n\n\nwith Client(client_id=\"${CLIENT_ID_ENV_VARIABLE}\", client_secret=\"${CLIENT_SECRET_ENV_VARIABLE}\") as client:\n    filters = client.FalconFilter()\n    filters.create_new_filter(\"LastSeen\", \"-7d\", \"LTE\")\n    response_data = client.hosts.describe_devices(filters)\n\nprint(f\"Found {len(response_data)} stale devices\")\n\nfor device_id, device_data in response_data.items():\n    hostname = device_data.get(\"hostname\", \"Unknown Hostname\")\n    print(f\"{device_id} - {hostname}\")\n```\n\n## Examples Collection\n\nEach API wrapper is provided alongside example code. Cloning or downloading/extracting this repository allows you to execute examples directly.\n\nUsing the examples collection requires that you install our Python packaging tool of choice, [Poetry](https://python-poetry.org). Please refer to the Poetry project's [installation guide](https://python-poetry.org/docs/#installation) if you do not yet have Poetry installed.\n\nOnce Poetry is installed, make sure you run `poetry install` within the root repository folder to set up the Python virtual environment.\n\nTo configure the examples, first copy `examples/config.example.yml` to `examples/config.yml`. Then, add your API credentials and example-specific settings to `examples/config.yml`. Once you have set up profiles for each Falcon tenant you want to test with, execute examples using one of the two options below.\n\n### Executing the Examples\n\nThere are two ways to use Poetry to execute the examples.\n\n<details>\n<summary><h4>Executing from a Poetry Shell</h4></summary>\n\nThe `poetry shell` command will enter you into the virtual environment. All future commands will run within the Caracara virtual environment using Python 3, until you run the `deactivate` command.\n\n```shell\npoetry shell\nexamples/get_devices/list_windows_devices.py\n```\n\n</details>\n\n<details>\n<summary><h4>Executing without Activating the Virtual Environment</h4></summary>\n\nIf you do not want to enter the Caracara virtual environment (e.g., because you are using your system's installation of Python for other purposes), you can use the `poetry run` command to temporarily invoke the virtual environment for one-off commands.\n\n```shell\npoetry run examples/get_devices/list_windows_devices.py\n```\n\nAll examples are also configured in the `pyproject.toml` file as scripts, allowing them to be executed simply.\n\n```shell\npoetry run stale-sensors\n```\n\n> To get a complete list of available examples, execute the command `util/list-examples.sh` from the root of the repository folder.\n\n</details>\n\n## Documentation\n\n__*Coming soon!*__\n\n## Contributing\n\nInterested in taking part in the development of the Caracara project? Start [here](CONTRIBUTING.md).\n\n## Why Caracara?\n\nSimple! We like birds at CrowdStrike, so what better bird to name a Python project after one that eats just about anything, including snakes :)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "The CrowdStrike Falcon Developer Toolkit",
    "version": "0.9.2",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2d3e46922e09c7a5a3884a852b082084a2a3d1b36021972de652a46ec4e1550e",
                "md5": "f775056575f79238112590b2dc0fa734",
                "sha256": "61cae61a23484aad8b1798b03d80c9206de61fd4f31a5cc4bf77bca00eb0ac7b"
            },
            "downloads": -1,
            "filename": "caracara-0.9.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f775056575f79238112590b2dc0fa734",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0.0,>=3.8.2",
            "size": 78352,
            "upload_time": "2024-12-16T21:43:50",
            "upload_time_iso_8601": "2024-12-16T21:43:50.740533Z",
            "url": "https://files.pythonhosted.org/packages/2d/3e/46922e09c7a5a3884a852b082084a2a3d1b36021972de652a46ec4e1550e/caracara-0.9.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "06adad6e27a80e6d56c4b71ffc84a949480a9658ea9b2149c821044823d2d0e0",
                "md5": "2b722a2353adeb383b610c3b87b6034d",
                "sha256": "1051389c5e80bc552f3b6ed917312c0a51671f9acdd33bf70a9c547797370d02"
            },
            "downloads": -1,
            "filename": "caracara-0.9.2.tar.gz",
            "has_sig": false,
            "md5_digest": "2b722a2353adeb383b610c3b87b6034d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0.0,>=3.8.2",
            "size": 60551,
            "upload_time": "2024-12-16T21:43:53",
            "upload_time_iso_8601": "2024-12-16T21:43:53.247516Z",
            "url": "https://files.pythonhosted.org/packages/06/ad/ad6e27a80e6d56c4b71ffc84a949480a9658ea9b2149c821044823d2d0e0/caracara-0.9.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-16 21:43:53",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "caracara"
}
        
Elapsed time: 0.52013s