Skip to main content

A framework for building and managing invoker scripts across different nodes in Sierra.

Project description

Sierraโ€‘SDK

๐Ÿš€ Overview

Sierraโ€‘SDK is a Python framework for building and managing invoker scripts that can be used across different nodes in Sierra during any investigation.

Project Goals

  • Provide a robust and flexible framework for managing invoker scripts
  • Offer a simple and intuitive API for building and compiling Sierra applications
  • Support extensibility through plugins and custom configurations

Key Features

  • Modular Design: Sierraโ€‘SDK is built with a modular architecture, allowing for easy extension and customization
  • Invoker Script Management: Easily build, compile, and load invoker scripts across different nodes in Sierra
  • Plugin Support: Extend the functionality of Sierraโ€‘SDK through custom plugins

โš™๏ธ Installation


pip Installation

You can install Sierraโ€‘SDK using pip:

pip install sierra-dev

Installation from Source

To install Sierraโ€‘SDK from source, clone the repository and run the following command:

git clone https://github.com/xsyncio/sierra-dev.git
cd sierra-dev
pip install .

๐Ÿ”ง Usage Examples


Building an Invoker Script

import sierra

# โ”€โ”€โ”€ Define the Invoker โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
invoker = sierra.InvokerScript(
    name="greet",
    description="Prints a personalized greeting message."
)


invoker.requirement(["requests"])


# โ”€โ”€โ”€ Dependency functions โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
@invoker.dependancy
def random_function_one(param: int) -> int:
    return param * 2

@invoker.dependancy
def random_function_two(message: str) -> str:
    return message.upper()

@invoker.dependancy
def random_function_three(value: float) -> float:
    return value / 3.14

@invoker.dependancy
def random_function_four(flag: bool) -> bool:
    return not flag

# โ”€โ”€โ”€ Entry point โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
@invoker.entry_point
def run(
    name: sierra.Param[
        str | None,
        sierra.SierraOption(
            description="The name of the person to greet.",
            mandatory="MANDATORY"
        )
    ],
    polite: sierra.Param[
        bool | None,
        sierra.SierraOption(
            description="Whether to include a polite phrase in the greeting.",
            mandatory=None
        )
    ] = False,
) -> None:
    """
    Greet the specified user by name, optionally politely.

    Parameters
    ----------
    name : str
        Name of the user (mandatory).
    polite : bool, optional
        If True, includes a polite prefix.
    """
    if name is None:
        # Missing mandatory parameter
        result = sierra.create_error_result("Missing mandatory parameter: name")
    else:
        # Build greeting
        greeting = f"Hello, {name}!"
        if polite:
            greeting = f"Good day to you, {name}!"
        # Wrap the greeting in a TreeResult
        result = sierra.create_tree_result([greeting])

    # Print the structured result
    print(result)

# โ”€โ”€โ”€ Loader โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
def load(client: sierra.SierraDevelopmentClient) -> None:
    """
    Register this invoker with the given Sierra client.

    Parameters
    ----------
    client : SierraDevelopmentClient
        The Sierra client instance.
    """
    client.load_invoker(invoker)

Compiling

import sierra

# Initialize Sierra client with DEBUGโ€‘level logging
client = sierra.SierraDevelopmentClient(
    environment_name="idd",
    logger=sierra.UniversalLogger(
        name="Sierra",
        level=sierra.sierra_internal_logger.LogLevel.DEBUG,
    ),
)

# Discover and register all invoker scripts
client.load_invokers_from_scripts()

# Generate standalone scripts and config.yaml
client.compiler.compile()

๐Ÿ“ฆ API Highlights


  • sierra.core.builder: Builder for invoker scripts
  • sierra.core.compiler: Compiler for invoker scripts
  • sierra.core.loader: Loader for compiled scripts
  • sierra.abc.sierra: Abstract base classes for Sierra components
  • sierra.invoker: Invoker script definitions

๐Ÿ› ๏ธ Configuration & Extensibility


Sierraโ€‘SDK supports extensibility through plugins and custom configurations. You can add custom plugins by creating a new folder in the plugins/ directory and adding your plugin code.

Plugin Folders

  • plugins/: Folder for custom plugins
  • core/: Folder for core Sierraโ€‘SDK components
  • abc/: Folder for abstract base classes
  • invoker/: Folder for invoker script definitions

๐Ÿ’ก Contributing Guidelines & Code of Conduct


We welcome contributions to Sierraโ€‘SDK! Please see our CONTRIBUTING.md file for guidelines on how to contribute.

Code of Conduct

We follow the Python Code of Conduct.

๐Ÿ“ License & Authors


Sierraโ€‘SDK is licensed under the GNU AFFERO GENERAL PUBLIC LICENSE.

Authors

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

sierra_dev-0.1.1.tar.gz (44.1 kB view details)

Uploaded Source

Built Distribution

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

sierra_dev-0.1.1-py3-none-any.whl (47.8 kB view details)

Uploaded Python 3

File details

Details for the file sierra_dev-0.1.1.tar.gz.

File metadata

  • Download URL: sierra_dev-0.1.1.tar.gz
  • Upload date:
  • Size: 44.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for sierra_dev-0.1.1.tar.gz
Algorithm Hash digest
SHA256 13bd241fe2b97728e423ddbcb5e5717c428098cf02e8931acd3657caf3c6ba05
MD5 f8a52013997ebe9790b13eb14f0d4f1a
BLAKE2b-256 8cc3fee6c864313ecfa864c6460bba2c6e5931db45a8fef1a30c7f4dabcffe46

See more details on using hashes here.

Provenance

The following attestation bundles were made for sierra_dev-0.1.1.tar.gz:

Publisher: python-publish.yml on xsyncio/sierra-dev

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

File details

Details for the file sierra_dev-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: sierra_dev-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 47.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for sierra_dev-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8913a45068592468f375cc07e8fccc834cb5c79341ed40178d2a3a96321cadb8
MD5 41f64680ba45b9421699ebd7f316bf46
BLAKE2b-256 3536f4d5dbe68b36501d946424eed42affc1344cea07ff1b3daeef195530da02

See more details on using hashes here.

Provenance

The following attestation bundles were made for sierra_dev-0.1.1-py3-none-any.whl:

Publisher: python-publish.yml on xsyncio/sierra-dev

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