Skip to content

jmountifield/jupiterone-python-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unofficial JupiterOne CLI Client

A command-line interface (CLI) client for interacting with the JupiterOne API. This tool allows you to execute J1QL queries against your JupiterOne account and output the results in JSON or CSV format.

Table of Contents

Installation

Prerequisites

  • Python 3.6 or later
  • A JupiterOne account with an API token

Steps

  1. Clone the repository:

    git clone https://github.com/jmountifield/jupiterone-cli-client.git
    cd jupiterone-cli-client
  2. Install the required dependencies:

    pip install -r requirements.txt
  3. Install the CLI tool:

    pip install .

Usage

Once installed, you can use the CLI client by running the jupiterone-cli command followed by the necessary arguments.

Command-Line Arguments

  • --account-id (Required): The ID of your JupiterOne account.
  • --token (Required): Your API token for authentication.
  • --api-url (Optional): The URL of the JupiterOne API. Defaults to https://api.us.jupiterone.io.
  • --output (Optional): Output format, either csv or json. Defaults to csv.
  • --include-deleted (Optional): Include deleted entities in the query results.
  • query (Positional, Required): The J1QL query to execute.

Examples

  • Basic Query with JSON Output:

    jupiterone-cli --account-id your_account_id --token your_api_token "FIND * LIMIT 1" --output json
  • Query with CSV Output:

    jupiterone-cli --account-id your_account_id --token your_api_token "FIND * LIMIT 1" --output csv > output.csv
  • Include Deleted Entities:

    jupiterone-cli --account-id your_account_id --token your_api_token --include-deleted "FIND * LIMIT 1" --output json

Output

  • JSON: The results will be printed to stdout in JSON format.
  • CSV: The results will be printed to stdout in CSV format. You can redirect the output to a file using > output.csv.

Testing

Unit tests are provided to ensure the CLI client works as expected.

Running Tests

  1. Install the test dependencies:

    pip install coverage
  2. Run the tests with coverage:

    coverage run -m unittest discover -s tests
  3. Generate a coverage report:

    coverage report
  4. Optionally, generate an HTML coverage report:

    coverage html

    Open htmlcov/index.html in your web browser to view the coverage details.

Contributing

Contributions are welcome! Please fork the repository and create a pull request with your changes. Ensure your code is well-documented and covered by tests.

Development Setup

  1. Clone the repository:

    git clone https://github.com/jmountifield/jupiterone-cli-client.git
  2. Create a virtual environment:

    python3 -m venv venv
    source venv/bin/activate
  3. Install dependencies:

    pip install -r requirements.txt
  4. Make your changes and add tests as necessary.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

An example CLI using the JupiterOne Python SDK

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published