Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:0xSteph Pentest ai Dashboard Auth Sync

From Leeroopedia
Knowledge Sources
Domains CLI, Authentication, Cloud_Sync
Last Updated 2026-10-23 00:00 GMT

Overview

Concrete tool for linking the local CLI to a cloud dashboard via API key management and engagement sync, provided by the pentest-ai CLI module.

Description

The cli.auth module handles API key persistence and remote engagement syncing to app.pentestai.xyz. Key resolution order: PENTESTAI_API_KEY env var (takes precedence, good for CI/CD), then ~/.pentest-ai/credentials file (populated by ptai auth login). The validate_key_remote function POSTs to /api/cli/validate to verify the key, and ingest_engagement POSTs engagement + findings to /api/cli/ingest for cloud dashboard sync. All remote calls are best-effort and never break a local scan.

Usage

Import this module when you need to store/load API keys or sync engagement findings to the cloud dashboard. Used by ptai auth login, ptai auth status, and the engagement completion handler.

Code Reference

Source Location

Signature

def store_api_key(api_key: str) -> None: ...
def load_api_key() -> str | None: ...
def key_source() -> str | None: ...
def remove_credentials() -> None: ...
def validate_key_remote(api_key: str, *, timeout: float = 10.0) -> dict | None: ...
def ingest_engagement(payload: dict, *, api_key: str | None = None, timeout: float = 30.0) -> dict | None: ...
def mask_key(key: str) -> str: ...

Import

from cli.auth import store_api_key, load_api_key, validate_key_remote, ingest_engagement, mask_key

I/O Contract

Inputs

Name Type Required Description
api_key str Yes Dashboard API key for authentication
payload dict Yes Engagement + findings payload for ingest
PENTESTAI_API_KEY str (env) No API key via env var (takes precedence over file)
PENTESTAI_API_BASE str (env) No Override dashboard base URL (for staging)

Outputs

Name Type Description
validation result None Org payload on success, None on failure
ingest result None Server JSON on success, None on network error

Usage Examples

Login and Validate

from cli.auth import store_api_key, validate_key_remote, key_source

api_key = "ptai_abcd1234..."
store_api_key(api_key)

result = validate_key_remote(api_key)
if result:
    print(f"Valid key for org: {result.get('org_name')}")
print(f"Key source: {key_source()}")  # 'env' or 'file'

Sync Engagement to Dashboard

from cli.auth import ingest_engagement, load_api_key

payload = {
    "engagement": {"name": "Q4 pentest", "target": "example.com"},
    "findings": [{"title": "SQLi", "severity": "critical", "target": "https://example.com"}],
}

result = ingest_engagement(payload)
if result and result.get("quota_exceeded"):
    print("Plan quota exceeded — upgrade required")
elif result:
    print(f"Synced to dashboard: {result}")

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment