For interacting with the Chariot API
Project description
Praetorian CLI and SDK
:link: Chariot Platform :book: Documentation :bookmark: PyPI
Table of Contents
Description
Praetorian CLI and SDK are open-source tools for interacting with our products and services. Currently, they support
access to Chariot, our
offensive security platform.
The SDK exposes the full set of APIs that the Chariot UI uses.
The CLI is a fully-featured companion to the Chariot UI.
Getting Started
Prerequisites
- Python v3.9 or above
- pip v23.0 or above
Installation
Install the Python package using this command:
pip install praetorian-cli
Signing up
Register for an account for Chariot using the instructions in our documentation.
Authentication
Once you can properly access Chariot through the UI. You can obtain API credentials through the UI under Settings -> User Settings -> API Keys. Be sure to careful copy the API credentials you created as you will need to provide them to the CLI for interacting with Chariot.
Note: SSO Organizations should provision access through API Keys as well.
Using API Keys
This is the authentication method for CLI. You can authenticate using either a keychain file or environment variables.
Using the keychain file
This method stores your API key in a keychain file.
- Run
praetorian configure
and follow the prompts to set up authentication. Use the default values forprofile name
,URL of backend API
, andclient ID
. - It creates
~/.praetorian/keychain.ini
, which should read like this:
[United States]
name = chariot
client_id = 795dnnr45so7m17cppta0b295o
api = https://d0qcl2e18h.execute-api.us-east-2.amazonaws.com/chariot
api_key_id = your-api-key-id-here
api_key_secret = your-api-key-here
Using environment variables
This method uses in-memory environment variables to pass your API key to the CLI. There is no need for a keychain file on disk. This enables you to choose a credential storage method suitable for your use cases. To use this method, set the following environment variable:
export PRAETORIAN_CLI_API_KEY_ID=your-api-key-id-here
export PRAETORIAN_CLI_API_KEY_SECRET=your-api-key-here
For more advanced configuration options or managing access in SSO organizations see the documentation on configuration.
Using the CLI
The CLI is a command and option utility for accessing the full suite of Chariot's API. You can see the documentation for commands
using the help
option:
praetorian chariot --help
As an example, run the following command to retrieve the list of all assets in your account:
praetorian --account chariot+example@praetorian.com chariot list assets
You can obtain the account
argument by viewing the email of the first user on the Users page in your Chariot account, as shown below:
To get detailed information about a specific asset, run:
praetorian --account chariot+example@praetorian.com chariot get asset <ASSET_KEY>
Developers
Both CLI and SDK is open-source in this repository. The SDK is installed along with the praetorian-cli
package. You can extend Chariot by creating scripts using the SDK.
SDK
Integrate the SDK into your own Python application with the following steps:
- Include the dependency
praetorian-cli
in your project. - Import the Chariot class
from praetorian_cli.sdk.chariot import Chariot
. - Import the Keychain class
from praetorian_cli.sdk.keychain import Keychain
. - Call any function of the Chariot class, which expose the full backend API. See example below:
from praetorian_cli.sdk.chariot import Chariot
from praetorian_cli.sdk.keychain import Keychain
chariot = Chariot(Keychain(account='chariot+example@praetorian.com'))
chariot.add('asset', dict(name='example.com', dns='example.com'))
The best place to explore the SDK is the code of the CLI, especially the handlers of the CLI
You can inspect the handler code to see how each CLI command is implemented with the SDK.
Developing external scripts
The CLI has a scripting engine that allow external scripts to be executed within the CLI's framework, taking
advantage of the SDK, click
, and authentication.
To add those external scripts to the CLI, set the PRAETORIAN_SCRIPTS_PATH
environment to point to directories where you store additional extension scripts.
Those external scripts are available under the script
commands. To see a list of them:
praetorian --account chariot+example@praetorian.com chariot script --help
For developing scripts, you can refer to this readme file.
Contributing
We welcome contributions from the community, from scripts, to the core CLI and SDK. To contribute, fork this repository and following the GitHub instructions to create pull requests.
By contributing, you agree to our Code of Conduct.
Support
If you have any questions or need support, please open an issue here or reach out via support@praetorian.com.
License
This project is licensed under the MIT License - see the LICENSE file for details.
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 praetorian_cli-2.1.4.tar.gz
.
File metadata
- Download URL: praetorian_cli-2.1.4.tar.gz
- Upload date:
- Size: 45.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
76c3b0598c8f215972a1b001ed4bfe53e9a6e464c675232769551ffc59d0a2b2
|
|
MD5 |
926dd727a23adef3ef571fa5e47eda99
|
|
BLAKE2b-256 |
166a3ebe168584ffd33f88ace8c364de1812d3f98157fac331fc7ae4966d71a5
|
File details
Details for the file praetorian_cli-2.1.4-py3-none-any.whl
.
File metadata
- Download URL: praetorian_cli-2.1.4-py3-none-any.whl
- Upload date:
- Size: 67.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
3329a0e478ef0fc3621637f1acf8253b5e07b2f0cf8b46a402030e7f52a88fdc
|
|
MD5 |
07176fad9b48612f8be85c8fdc06aef3
|
|
BLAKE2b-256 |
ee4f6e50cbc9f998f529514ee5c1522b5f228975a1fadd51fc9b31a39da20128
|