Official Python SDK for the BlackShield Security Platform
Project description
BlackShield Python SDK
Official Python SDK for the BlackShield Security Platform.
Installation
pip install blackshield-sdk
Quick Start
import blackshield
client = blackshield.BlackShield(api_key="bsk_live_...")
# List critical findings
page = client.findings.list(severity=["critical", "high"], page_size=10)
for f in page.items:
print(f"{f.severity.value} | {f.title}")
# Get a specific finding
finding = client.findings.get("550e8400-e29b-41d4-a716-446655440000")
# Update finding status
client.findings.update_status(finding.id, status="in_progress", reason="Investigating")
Async Usage
import asyncio
from blackshield import AsyncBlackShield
async def main():
async with AsyncBlackShield(api_key="bsk_live_...") as client:
page = await client.findings.list(severity=["critical"])
for f in page.items:
print(f.title)
asyncio.run(main())
Available Resources
| Resource | Description | Example |
|---|---|---|
client.findings |
List, get, update findings | client.findings.list(severity=["critical"]) |
client.ingestion |
Ingest findings & assets | client.ingestion.ingest_findings([...]) |
client.dashboard |
Stats, trends, usage | client.dashboard.stats() |
client.compliance |
Compliance overview & controls | client.compliance.overview(framework="SOC2") |
client.reports |
Summaries & CSV/PDF exports | client.reports.export_findings_csv() |
client.easm |
External attack surface | client.easm.overview() |
client.threat_intel |
Blocklist & indicator lookup | client.threat_intel.lookup(indicator="1.2.3.4") |
client.connectors |
Connector health monitoring | client.connectors.freshness() |
client.api_keys |
API key management | client.api_keys.create(label="CI") |
client.policies |
Policy guardrails & custom Rego | client.policies.list_packs() |
client.security_reviews |
Guided security reviews & templates | client.security_reviews.get_default_template() |
client.audit |
Tenant audit logs & evidence export | client.audit.query(limit=50) |
client.alerts |
Alerts & alert sync integrations | client.alerts.list(severity=["critical"]) |
client.identity |
Identity, OIDC & mapping configs | client.identity.list_oidc() |
client.remediation |
Remediation & compensating controls | client.remediation.get_policy("default") |
client.ai_gateway |
AI Gateway client & usage logs | client.ai_gateway.list_clients() |
Ingestion
from blackshield.types.ingestion import UnifiedFinding, AffectedResource, SourceMeta
finding = UnifiedFinding(
finding_type="vulnerability",
title="CVE-2024-1234 in openssl 3.0.8",
severity="critical",
cve_id="CVE-2024-1234",
affected_resource=AffectedResource(
resource_type="container_image",
resource_id="sha256:abc123",
resource_name="myapp:latest",
),
source=SourceMeta(scanner="trivy", scanner_version="0.50.0"),
dedup_key="vuln:CVE-2024-1234:sha256:abc123",
)
result = client.ingestion.ingest_findings([finding])
print(f"Job ID: {result.job_id}, Status: {result.status}")
# Poll for completion
job = client.ingestion.get_job(result.job_id)
print(f"Created: {job.created}, Updated: {job.updated}")
Error Handling
import blackshield
try:
finding = client.findings.get("nonexistent-id")
except blackshield.NotFoundError:
print("Finding not found")
except blackshield.RateLimitError as e:
print(f"Rate limited, retry after {e.retry_after}s")
except blackshield.AuthenticationError:
print("Invalid API key")
except blackshield.BlackShieldError as e:
print(f"API error: {e}")
Configuration
client = blackshield.BlackShield(
api_key="bsk_live_...",
base_url="https://api.blackshield.chaplau.com", # or self-hosted URL
timeout=60.0, # request timeout in seconds
max_retries=3, # automatic retries on 429/5xx
)
Development
cd sdk
pip install -e ".[dev]"
pytest -v --cov=blackshield
ruff check .
mypy .
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
blackshield_sdk-0.1.2.tar.gz
(29.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file blackshield_sdk-0.1.2.tar.gz.
File metadata
- Download URL: blackshield_sdk-0.1.2.tar.gz
- Upload date:
- Size: 29.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0eb09fa00219df6c2ef8a7958fc990092eb1764712df2f6fb2b1579401d909b8
|
|
| MD5 |
44a5847eca5e9bc989f3cfd17d1b2f35
|
|
| BLAKE2b-256 |
4f9ed7a2bbfe0389c8c969b55c15fec8d8401984bb5c8174b3340030d813c90d
|
File details
Details for the file blackshield_sdk-0.1.2-py3-none-any.whl.
File metadata
- Download URL: blackshield_sdk-0.1.2-py3-none-any.whl
- Upload date:
- Size: 40.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b63003e065c9e32147507311554b93014a86311ef7e49c67d62bd297533b0d6
|
|
| MD5 |
9568411b6383ef4dd609abb8d7da7e4f
|
|
| BLAKE2b-256 |
f6b14ad5841a8ca944fe0377cb09d19c220834b164bdcedea726422afeb04f7a
|