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.4.tar.gz (45.2 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.4-py3-none-any.whl (49.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sierra_dev-0.1.4.tar.gz
  • Upload date:
  • Size: 45.2 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.4.tar.gz
Algorithm Hash digest
SHA256 1ce10463187ca295a56c22f9ef4d5c9d0c6d6d1dd1eafc3815ffedf9ebeb5da8
MD5 5194d02d9ff98918b65926ab2ae0ab47
BLAKE2b-256 841db6ae56659ae0bd73440070c2cbcc713cd4ebf39bfd8f7ef0aebc647c59ad

See more details on using hashes here.

Provenance

The following attestation bundles were made for sierra_dev-0.1.4.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.4-py3-none-any.whl.

File metadata

  • Download URL: sierra_dev-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 49.1 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a9dc881d994c1e5aebb122185265160f5c39dbad9f731318230456f719827837
MD5 884f53d85cb9ad13e248716c5b377f7f
BLAKE2b-256 5867d590c51043b809480fb2121d6b41c0a9c160c4e2969381c76a3feec7c235

See more details on using hashes here.

Provenance

The following attestation bundles were made for sierra_dev-0.1.4-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