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.13.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.13-py3-none-any.whl (45.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bastion_red-0.4.13.tar.gz
  • Upload date:
  • Size: 39.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for bastion_red-0.4.13.tar.gz
Algorithm Hash digest
SHA256 d877496771950536ceab459e38dde42c63bb56125f4dc4bd3e9767de348eeae8
MD5 40b9005058c4bfbc01fabfe599f3d772
BLAKE2b-256 e765316b0ccec9d6260caddb802c0c7989a60241b5b0342da4862609f39a348a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bastion_red-0.4.13-py3-none-any.whl
  • Upload date:
  • Size: 45.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for bastion_red-0.4.13-py3-none-any.whl
Algorithm Hash digest
SHA256 e77ac0786a00aac7417ae4b270118d00d9510644e69c60673d46b9b9a58fafc3
MD5 493ce1191d8ed683e4e189752dbc5440
BLAKE2b-256 db99af3c4f30c8c5f0dc40cc60a61fa951ac6c1a34721624e85d4492a7ef4603

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