OpenLatch detection-tool SDK — Standard Webhooks v1 verify/sign + FastAPI decorator.
Project description
openlatch-tool-sdk
Standard Webhooks v1 verify/sign + FastAPI decorator for OpenLatch
detection tools (Python). Pairs with openlatch-provider listen (HMAC
verification happens there) or stands on its own when the tool server is
exposed publicly.
Install
pip install 'openlatch-tool-sdk[fastapi]'
FastAPI
from openlatch_tool_sdk import CloudEvent, Verdict, tool
from fastapi import FastAPI
app = FastAPI()
@tool(app, path="/event", secret=None) # secret=os.environ["OPENLATCH_WHSEC"] for standalone
async def detect(event: CloudEvent) -> Verdict:
text = str((event.tool_call.input if event.tool_call else None) or {})
if "AKIA" in text:
return Verdict(
risk_score=99,
severity_hint="critical",
verdict_hint="deny",
rule_id="aws.access_key",
rationale_summary="AWS access key detected",
)
return Verdict(risk_score=5, severity_hint="low", verdict_hint="allow")
Direct API
from openlatch_tool_sdk import compute_signature, sign_response, verify
Verdict shape
Pydantic models are configured with alias_generator=to_camel, so wire
JSON uses camelCase (riskScore, severityHint, …) per
provider-call.schema.json, while Python code uses snake_case naturally.
Per-action scoring + config state
Optional v2 contract additions (camelCase on the wire, snake_case in Python):
from openlatch_tool_sdk import (
ActionScore, CloudEvent, Verdict, score_to_severity,
)
async def detect(event: CloudEvent) -> Verdict:
# Stateful config/integrity detectors: prior artifact state arrives as
# the CloudEvents `priorconfigstate` extension when the capability
# declares `needs_prior_config_state: true` in the manifest.
prior = event.prior_config_state
risk = 87
return Verdict(
risk_score=risk,
severity_hint=score_to_severity(risk),
verdict_hint="deny",
actions=[
ActionScore(
action_ref="cmd:0", # "{kind}:{index}" join key
risk_score=risk,
severity=score_to_severity(risk),
threat_category="shell_dangerous", # routing 12-category
axes={"destructive": 18, "exfil": 0, "secret": 0,
"privesc": 0, "reversibility": 20},
)
],
)
Verdict.actions— optionallist[ActionScore](≤256). Absent ⇒ the platform records per-action risk as null (gap-tolerant). Eachaction_refis the platform-emitted"{kind}:{index}"join key.CloudEvent.prior_config_state— typed view of thepriorconfigstateCloudEvents extension; populated only for capabilities declaringneeds_prior_config_state: true.score_to_severity(risk_score)— canonical<40 / 40-69 / 70-89 / 90+buckets. First-party tools MUST deriveseverityfrom this so the bucket invariant holds by construction (the platform trusts the provider-reported severity verbatim).
Cross-impl HMAC parity
Test fixtures and signed outputs are byte-identical between this SDK,
@openlatch/tool-sdk (npm), and runtime/webhook.rs in the
openlatch-provider Rust binary. The same whsec_<base64> secret +
<id>.<timestamp>.<raw-body> payload + base64(HMAC-SHA256) framing is
used by all three.
Releases
openlatch-tool-sdk is released in lock-step with openlatch-provider
via release-please. Land conventional-commit PRs against main;
release-please opens a Release PR bumping all three packages
(openlatch-provider on crates.io + npm, openlatch-tool-sdk on PyPI,
@openlatch/tool-sdk on npm). Merging the Release PR creates a v*
tag and the unified publish.yml workflow publishes everything via
OIDC trusted publishing.
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
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 openlatch_tool_sdk-2.0.0.tar.gz.
File metadata
- Download URL: openlatch_tool_sdk-2.0.0.tar.gz
- Upload date:
- Size: 38.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2cd7506de3b7d1b2f9b032417d3515b168c317903d0c4f84f146bc40e8ca4e79
|
|
| MD5 |
1f26c4406e94fac8086d452427d47e74
|
|
| BLAKE2b-256 |
7be97b124b5bed1297672ee4e34d3ca83d66c0a0ec234bb92fe96dd06bbca73c
|
Provenance
The following attestation bundles were made for openlatch_tool_sdk-2.0.0.tar.gz:
Publisher:
publish.yml on OpenLatch/openlatch-provider
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openlatch_tool_sdk-2.0.0.tar.gz -
Subject digest:
2cd7506de3b7d1b2f9b032417d3515b168c317903d0c4f84f146bc40e8ca4e79 - Sigstore transparency entry: 1549565310
- Sigstore integration time:
-
Permalink:
OpenLatch/openlatch-provider@047682ffab6813873f7cd614d283648b88228214 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/OpenLatch
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@047682ffab6813873f7cd614d283648b88228214 -
Trigger Event:
push
-
Statement type:
File details
Details for the file openlatch_tool_sdk-2.0.0-py3-none-any.whl.
File metadata
- Download URL: openlatch_tool_sdk-2.0.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
466e7056532ce1c5e7d05b8105ff76f3363e6e34e3f9f1c1a5f91ad60b9d0724
|
|
| MD5 |
f2666962032720615bba0d18c859ca8f
|
|
| BLAKE2b-256 |
4f79bc0f973679cdfcf68ba13e2a27fe181cad06c0572a7d781ea196269aa6c4
|
Provenance
The following attestation bundles were made for openlatch_tool_sdk-2.0.0-py3-none-any.whl:
Publisher:
publish.yml on OpenLatch/openlatch-provider
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openlatch_tool_sdk-2.0.0-py3-none-any.whl -
Subject digest:
466e7056532ce1c5e7d05b8105ff76f3363e6e34e3f9f1c1a5f91ad60b9d0724 - Sigstore transparency entry: 1549565347
- Sigstore integration time:
-
Permalink:
OpenLatch/openlatch-provider@047682ffab6813873f7cd614d283648b88228214 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/OpenLatch
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@047682ffab6813873f7cd614d283648b88228214 -
Trigger Event:
push
-
Statement type: