Skip to main content

SENSE Python Wrapper

PyPI version Python versions License

Python wrapper for SENSE (Shadow Exposure & eNterprise Surveillance for AI) - a comprehensive security tool designed to detect and monitor unauthorized or "shadow" AI instances within enterprise environments.

Features

  • 🐍 Pure Python API - Easy integration with Python applications
  • 🚀 Simple CLI - Command-line interface for quick operations
  • 🔄 Real-time Streaming - Stream findings as they are detected
  • 🎯 Process Management - Automatic backend lifecycle management
  • 📦 Zero Configuration - Binary auto-download and setup

Installation

pip install senseai

Requirements

  • Python 3.8+
  • macOS or Linux (Windows support coming soon)
  • libpcap for network scanning (install via brew install libpcap on macOS)

Note: Network scanning requires sudo privileges. The package works without sudo but with limited functionality (endpoint detection only).

Quick Start

CLI Usage

# Start the SENSE server
senseai start --port 8080

# Check server status
senseai status

# List findings
senseai findings

# Stream real-time findings
senseai stream

# Stop the server
senseai stop

Python API Usage

from senseai import SenseClient, SenseServer

# Start the backend server
server = SenseServer(port=8080)
server.start()

# Use the API client
client = SenseClient(base_url="http://localhost:8080")

# Get all findings
findings = client.get_findings()
print(f"Found {len(findings)} findings")

# Filter by severity
critical_findings = client.get_findings_by_severity(min_severity=7.0)

# Stream real-time findings
for finding in client.stream_findings():
    print(f"[{finding['type']}] {finding['details']}")

# Cleanup
server.stop()

Context Manager Usage

from senseai import SenseServer, SenseClient

# Automatic cleanup with context manager
with SenseServer(port=8080) as server:
    with SenseClient() as client:
        findings = client.get_findings()
        print(findings)

CLI Reference

senseai start

Start the SENSE backend server.

Options:

  • --port, -p - Port to run the server on (default: 8080)
  • --interface, -i - Network interface to monitor (default: en0)
  • --db, -d - Path to database file (default: /tmp/sense.db)
  • --policies, -c - Path to policies file (default: policies.yaml)
  • --sudo - Run with sudo for network scanning
  • --background, -b - Run server in background

Example:

sudo senseai start --port 8080 --sudo --interface en0

senseai status

Check the status of the SENSE backend server.

Options:

  • --port, -p - Port the server is running on (default: 8080)
  • --json - Output in JSON format

senseai findings

List findings from the SENSE backend.

Options:

  • --port, -p - Port the server is running on (default: 8080)
  • --limit, -n - Limit number of findings to display
  • --type, -t - Filter by finding type (network, endpoint)
  • --min-severity - Minimum severity level
  • --json - Output in JSON format

Example:

senseai findings --type network --min-severity 5.0 --limit 10

senseai stream

Stream real-time findings from the SENSE backend.

Options:

  • --port, -p - Port the server is running on (default: 8080)

senseai stop

Stop the SENSE backend server.

Options:

  • --port, -p - Port the server is running on (default: 8080)

Python API Reference

SenseServer

Manages the SENSE Go backend server process.

Constructor:

SenseServer(
    port: int = 8080,
    interface: str = "en0",
    db_path: Optional[str] = None,
    policy_file: Optional[str] = None,
    use_sudo: bool = False,
)

Methods:

  • start(wait_for_ready=True, timeout=30) - Start the server
  • stop(timeout=10) - Stop the server
  • restart(timeout=30) - Restart the server
  • is_running() - Check if server is running
  • get_status() - Get server status information

SenseClient

Client for interacting with the SENSE REST API.

Constructor:

SenseClient(
    base_url: str = "http://localhost:8080",
    timeout: int = 30,
)

Methods:

  • health_check() - Check if server is responsive
  • get_findings(limit=None) - Get all findings
  • stream_findings() - Stream real-time findings (generator)
  • get_finding_by_id(finding_id) - Get specific finding
  • get_findings_by_type(finding_type) - Filter by type
  • get_findings_by_severity(min_severity, max_severity) - Filter by severity

Platform Support

Platform Status Notes
macOS (Intel) ✅ Supported Requires libpcap
macOS (Apple Silicon) ✅ Supported Requires libpcap
Linux (x86_64) ✅ Supported Requires libpcap
Linux (ARM64) ✅ Supported Requires libpcap
Windows 🚧 Coming Soon -

Troubleshooting

Binary Download Fails

If the automatic binary download fails, you can manually build and install the Go binary:

# Clone the repository
git clone https://github.com/Faux16/sense-ai.git
cd sense-ai

# Build the binary
go build -o sense cmd/sense/main.go

# Make it available in PATH
sudo cp sense /usr/local/bin/

Permission Errors

Network scanning requires root privileges:

# Run with sudo flag
sudo senseai start --sudo

Or run in limited mode (endpoint detection only):

# No sudo required
senseai start

Port Already in Use

If port 8080 is already in use, specify a different port:

senseai start --port 8081

Development

Building from Source

# Clone the repository
git clone https://github.com/Faux16/sense-ai.git
cd sense-ai/python

# Install in development mode
pip install -e ".[dev]"

# Run tests
pytest tests/

Running Tests

# Unit tests
pytest tests/test_binary.py tests/test_client.py -v

# Integration tests (requires Go binary)
pytest tests/test_integration.py -v

# All tests with coverage
pytest --cov=senseai --cov-report=html

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE for details.

Acknowledgments

Built with ❤️ for the security community. Presented at Black Hat MEA.

Metadata

Release files for senseai 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 senseai 0.1.0
File Size Uploaded Provenance Actions
senseai-0.1.0.tar.gz 16.3 kB Without provenance Details for senseai-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 29.8 kB

Release files / senseai-0.1.0.tar.gz

Download URL senseai-0.1.0.tar.gz
Size 16.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a73153bf3305035b9290547a44be1abd2d9967a734b0a9fa60495a3168782afb
BLAKE2b-256 checksum
How to use checksums
80b8cc07b80ecbcc5d706bee9309951fa525532d2068413ecabae49d7f007b14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

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

Download URL senseai-0.1.0-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
81dbdc0362afc3cd2e1b2ea1df16d00417a6a31778ffa19d0062589c7f68d21f
BLAKE2b-256 checksum
How to use checksums
efd834447d5bf6ec7de19214769bea8a592a7e9eabccb099dd384590e1121d6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for senseai 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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