Scan code and pull requests for leaked secrets
Scan commits, pull requests, and candidate training files for leaked credentials via POST /v1/security/scans and inspect masked findings.
Catch leaked keys before they land in git history or model weights. POST /v1/security/scans runs Hanzo's rule engine over any file batch and returns structured, masked findings with line numbers and stable fingerprints.
Architecture & contract
Findings store only masked previews and fingerprints — never raw secret material — scoped strictly to your org. Pair with CI pre-commit hooks and dataset upload pipelines.
Primary endpoint: POST /v1/security/scans · Status: shipped · Level: practitioner
Run it across all four surfaces
CLI
SDK
HTTP
MCP
hanzo security rules
hanzo security scans create --data '{"files":[{"path":"deploy.sh","content":"export DATABASE_URL=postgres://[email protected]/prod"}]}'
hanzo security findings listTypeScript
Python
import { Configuration, SecurityApi } from 'hanzoai';
const sec = new SecurityApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data: scan } = await sec.postSecurityScans({
files: [{ path: 'deploy.sh', content: 'export DATABASE_URL=postgres://[email protected]/prod' }],
});
console.log(scan);import os
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import SecurityApi
api = SecurityApi(ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"])))
print(api.post_security_scans({"files": [{"path": "deploy.sh", "content": "export DATABASE_URL=postgres://[email protected]/prod"}]}))curl -s -X POST https://api.hanzo.ai/v1/security/scans \
-H "Authorization: Bearer $HANZO_API_KEY" -H "Content-Type: application/json" \
-d '{"files":[{"path":"deploy.sh","content":"export DATABASE_URL=postgres://[email protected]/prod"}]}' | jq '.'
curl -s https://api.hanzo.ai/v1/security/findings \
-H "Authorization: Bearer $HANZO_API_KEY" | jq '.'curl -s -X POST https://api.hanzo.ai/v1/mcp \
-H "Authorization: Bearer $HANZO_API_KEY" -H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "security",
"arguments": {"op": "get_security_scans", "input": {}}
}
}'Verify the outcome
- Run a scan against a clean file (expect
0findings) and verifyGET /v1/security/scans/{id}returns full scan metadata.
Production guardrails
- Whenever a real credential triggers a finding, rotate it immediately in Hanzo KMS (
/v1/kms/secrets) — deleting the commit alone is never sufficient.
Next steps & Hanzo University
Was this page useful?
Broken link or missing step? Drop it in #docs on Discord or open a PR.PreviousEnforce allow < ask < deny over agent shell commandsNextAudit container image SBOMs by digest before deploy
Last updated Nov 25, 2026