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 FindingsDB

From Leeroopedia
Knowledge Sources
Domains Persistence, Findings_Management, SQLite
Last Updated 2026-10-23 00:00 GMT

Overview

Concrete tool for persistent SQLite storage of engagements, findings, attack chains, PoCs, and detection rules, provided by the pentest-ai engine.

Description

The FindingsDB class provides async SQLite persistence for all pentest findings, engagements, attack chains, tool results, auth sessions, and detection rules. It includes forward-only schema migrations, evidence-required contract enforcement (high-severity findings must carry evidence or be coerced to 'unverified'), and JSON column hydration for consumer-facing objects. The DB path resolves via PTAI_DB_PATH env var, XDG_DATA_HOME, or ~/.local/share/pentest-ai/findings.db.

Usage

Import this class when you need to store or query pentest findings, engagements, or attack chains. Used by the orchestrator, MCP server, REST API, and CLI to persist engagement state across sessions.

Code Reference

Source Location

Signature

class FindingsDB:
    def __init__(self, db_path: str | None = None): ...

    async def init(self) -> None: ...
    async def close(self) -> None: ...
    async def create_engagement(self, ...) -> str: ...
    async def add_finding(self, finding: dict[str, Any], engagement_id: str) -> str: ...
    async def get_findings(self, engagement_id: str, severity: str | None = None, status: str | None = None, include_unverified: bool = False) -> list[dict[str, Any]]: ...
    async def get_engagement(self, engagement_id: str) -> dict[str, Any] | None: ...
    async def list_engagements(self, limit: int = 50) -> list[dict[str, Any]]: ...
    async def get_engagement_summary(self, engagement_id: str) -> dict[str, Any]: ...
    async def get_attack_chains(self, engagement_id: str) -> list[dict[str, Any]]: ...
    async def get_detection_rules(self, engagement_id: str) -> list[dict[str, Any]]: ...

Import

from engine.findings_db import FindingsDB, EvidenceMissingError

I/O Contract

Inputs

Name Type Required Description
db_path None No SQLite DB path. Defaults to ~/.local/share/pentest-ai/findings.db
finding dict[str, Any] Yes Finding dict with title, severity, evidence, poc, etc.
engagement_id str Yes Engagement UUID to associate findings with

Outputs

Name Type Description
finding_id str UUID of the stored finding
findings list list[dict] Hydrated finding dicts with parsed JSON columns
engagement summary dict Severity counts, status counts, chain counts

Usage Examples

Create Engagement and Add Findings

import asyncio
from engine.findings_db import FindingsDB

async def main():
    db = FindingsDB()
    await db.init()

    # Create an engagement
    eng_id = await db.create_engagement(
        target="https://example.com",
        scope="example.com",
    )

    # Add a finding
    finding_id = await db.add_finding({
        "title": "SQL injection in search parameter",
        "description": "Boolean-based SQLi detected",
        "severity": "critical",
        "category": "injection",
        "evidence": "TRUE=5000B, FALSE=4200B, baseline=4200B",
        "poc": "GET /search?q=' OR '1'='1",
        "tool_source": "authenticated_scan",
        "target": "https://example.com/search",
    }, engagement_id=eng_id)

    # Query findings
    findings = await db.get_findings(eng_id, severity="critical")
    print(f"Found {len(findings)} critical findings")

    await db.close()

asyncio.run(main())

Get Engagement Summary

import asyncio
from engine.findings_db import FindingsDB

async def main():
    db = FindingsDB()
    await db.init()

    summary = await db.get_engagement_summary("eng-uuid-here")
    print(f"Total: {summary['total_findings']}")
    print(f"Critical: {summary['severity_counts']['critical']}")
    print(f"Verified: {summary['status_counts']['confirmed']}")

    await db.close()

asyncio.run(main())

Related Pages

Page Connections

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