Skip to main content

Insights Sandbox

Run rules with access only to necessary binaries and the archive working directory.

Strategy

  • Create a sandbox using bubblewrap (bwrap).
    • Enable only required linux namespaces (see man namespaces for more info).
  • Communicate with the sandbox using zeromq over named pipes.
    • zmq hides underlying buffer details (man 7 pipe for fifos).

Architecture

Client <-> runner adapter proxy <-> named pipes <-> [controller <-> runner adapter <-> runner]

The Client creates named pipes and a child process that uses bwrap to invoke insights_sandbox.consumer.

The client creates a RunnerAdapterProxy and configures it with zmq functions for sending and recieving messages over the pipes. The proxy is used to setup the Runner via the Controller and RunnerAdapter.

Installation

CentOS 7:
yum install epel-release
yum install bubblewrap

Fedora:
dnf install epel-release
dnf install bubblewrap

Both:
python3 -m venv .
. bin/activate
pip install -e .[develop]

Test an archive

./driver.py -p examples.rules <archive>

Example Code

#!/usr/bin/env python3
"""
This script is only for testing the sandbox.
"""
import argparse

from insights import dr, parse_plugins
from insights_sandbox.client import Client


def parse_args():
    p = argparse.ArgumentParser()
    p.add_argument("--plugins", "-p", help="plugins to load", default="")
    p.add_argument("archive", help="pass an archive to analyze.")
    return p.parse_args()


def main():
    args = parse_args()
    broker = dr.Broker()
    packages = parse_plugins(args.plugins)
    with Client(packages=packages) as client:
        doc = client.process(args.archive, broker=broker)
        print(doc["results"].decode("utf-8"))


if __name__ == "__main__":
    main()

Metadata

Release files for insights-sandbox 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for insights-sandbox 0.1.0
File Size Uploaded
insights-sandbox-0.1.0.linux-x86_64.tar.gz 16.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for insights-sandbox 0.1.0
File Interpreter ABI Platform
insights_sandbox-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 26.9 kB

Release files / insights-sandbox-0.1.0.linux-x86_64.tar.gz

Download URL insights-sandbox-0.1.0.linux-x86_64.tar.gz
Size 16.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f4bbd414540b16938f2675cd31f08c3a1fac1f4c31f2bf09831665793febd715
BLAKE2b-256 checksum
How to use checksums
878f0d59f3c3bca89d430838ac3a64388682b2441010de7696d407fbbdcbd44a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.7

Release files / insights_sandbox-0.1.0-py3-none-any.whl

Download URL insights_sandbox-0.1.0-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c77725687544587ad09486de035d61aee67bb5eb6a99415c82c71bac80b772f2
BLAKE2b-256 checksum
How to use checksums
f23332f439f6e3dd37d36e4b8789852f869bd3ec3c13033c4f7e45aa83791e5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.7

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page