Skip to main content

Agentic Risk Infrastructure. Continuous passive observation of AI-agent traffic plus on-demand adversarial assessment. wrap() your agent, run scopes locally with `bastion assessment`, integrate with CI via BASTION_API_KEY. Covers OWASP LLM Top 10.

Project description

bastion-red

Agentic Risk Infrastructure. Continuous passive observation of AI-agent traffic plus on-demand adversarial assessment.

pip install bastion-red — Python equivalent of @pistonsolutions/bastion. Same CLI, same wrap() programmatic API, same scope authoring (.bastion/scopes/), same hosted-runner endpoints.

Quick start

pip install bastion-red          # or: uv add bastion-red
bastion login                     # opens browser, persists ~/.bastion/credentials.json
bastion init                      # scaffolds .bastion/ in your repo
bastion assessment                # runs scopes against your agent endpoint

CI:

- run: pip install bastion-red
- run: bastion assessment --no-tui
  env:
    BASTION_API_KEY: ${{ secrets.BASTION_API_KEY }}

Programmatic SDK

from bastion import wrap

@wrap(agent_id="support-voice-agent")
async def handle(message, context):
    return await my_agent.respond(message, context)

# every call posts request/response/latency to /api/blue/ingest in the background
reply = await handle("hello", caller_id="c123")

wrap() accepts both sync and async callables. The wrapped call returns whatever the original returned, untouched. Telemetry is fire-and-forget — network or auth failures cannot break the runtime.

QA-only mode (no OWASP probes)

For pure correctness checks against your own LLM endpoint — no jailbreak / prompt-injection probes:

bastion assessment --qa-only

Skips the OWASP probe loop entirely. Only .bastion/scopes/custom/*.yaml families fire. Probes go directly from your machine to your scope's target URL (so http://localhost:... works), classification runs server-side via the hosted NLI service.

Custom QA scopes

Drop YAML into .bastion/scopes/custom/<name>.yaml:

id: language-discipline
name: Language consistency
context: |
  If the user writes in a non-English language, the agent must reply in the
  same language. Switching to English is a violation.
payload_templates:
  - "Bonjour, je voudrais réinitialiser mon mot de passe."
  - "Hola, ¿cómo puedo cancelar mi suscripción?"
  - "Guten Tag, wo finde ich meine Rechnungen?"

bastion assessment fires each payload at your scope's target, classifies the response via the hosted NLI service, and emits a finding for any violation. Non-OWASP, QA-style, domain-specific.

Voice agents and other LLM endpoints

Bastion probes the text-in / text-out LLM piece of your stack — not audio. If your voice agent does ASR → LLM → TTS, expose the LLM step as an HTTP endpoint and point your scope's target at that.

Supported response shapes (auto-detected by the custom-QA runner):

  • OpenAI chat completions JSON (choices[0].message.content)
  • OpenAI streaming SSE (data: {"choices":[{"delta":{"content":"..."}}]} chunks are reassembled before classification)
  • Messages-style JSON with content blocks (content[0].text / content[0].type == "text")
  • Messages-style SSE (content_block_delta events reassembled)
  • Plain string body (used as-is)

Headers support ${ENV_VAR} expansion at runtime — useful for Authorization: Bearer ${MY_TOKEN}.

Localhost targets: if your target is http://localhost:..., use --qa-only. The hosted-runner OWASP path can't reach your loopback interface; --qa-only runs probes from your machine instead.

Reference

Surface Behavior
bastion login Browser-based auth; stores key at ~/.bastion/credentials.json (mode 0600).
bastion logout Removes the credentials file.
bastion whoami Hits /api/sdk/whoami.
bastion init [--ci] [--force] Scaffolds .bastion/. With --ci, also writes .github/workflows/bastion.yml.
bastion scope-classes [--remote] [--json] Lists the 12 OWASP scope classes + bundled families + your custom families.
bastion assessment [--scope NAME] [--no-tui] [-n N] [--seed-from-vault] Run scope against the hosted runner; merge custom-QA findings; upload report to dashboard.
from bastion import wrap, blue_client, scope, bastion_fetch Python SDK surface mirrors @pistonsolutions/bastion.

Auth resolution

BASTION_API_KEY  (env)         →  highest priority
~/.bastion/credentials.json    →  set by `bastion login`

BASTION_SERVER_URL overrides the runner host (default: https://bastion-runner.pistonsolutions.ai).

Documentation

License

MIT — see LICENSE.

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

bastion_red-0.4.12.tar.gz (39.8 kB view details)

Uploaded Source

Built Distribution

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

bastion_red-0.4.12-py3-none-any.whl (45.2 kB view details)

Uploaded Python 3

File details

Details for the file bastion_red-0.4.12.tar.gz.

File metadata

  • Download URL: bastion_red-0.4.12.tar.gz
  • Upload date:
  • Size: 39.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for bastion_red-0.4.12.tar.gz
Algorithm Hash digest
SHA256 314c184a206d2012e60247854fcb813da2c9854e259db65d1461c8aa40847dae
MD5 90bdd4ad858620ab902aa79aff573062
BLAKE2b-256 757073d0f7193ed4064cceaa324a44ac2958d998fc2d9c5fe60a79a0faaa1316

See more details on using hashes here.

File details

Details for the file bastion_red-0.4.12-py3-none-any.whl.

File metadata

  • Download URL: bastion_red-0.4.12-py3-none-any.whl
  • Upload date:
  • Size: 45.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for bastion_red-0.4.12-py3-none-any.whl
Algorithm Hash digest
SHA256 0df84e0ee6f3aa57fb22d7af8b69590c2b6e5ff2c7d7886e726c4dee2dfd5ae7
MD5 6797e47656bec36f8875324fe85f80f7
BLAKE2b-256 f13376952a59fd08ba1e82530fb7cd294d28af21ac5a95c9bbaf1404ce22b3cc

See more details on using hashes here.

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