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 EvidenceCollector

From Leeroopedia
Knowledge Sources
Domains Evidence, Artifacts, Integrity
Last Updated 2026-10-23 00:00 GMT

Overview

Concrete tool for auto-capturing timestamped evidence artifacts with SHA-256 integrity hashes for every finding, provided by the pentest-ai engine.

Description

The EvidenceCollector class stores tool output, HTTP interactions, and screenshots as evidence artifacts on disk, each with a SHA-256 integrity hash. It provides methods for storing tool output (stdout, stderr, exit code, duration), HTTP request/response pairs, and generic files. The resolve_engagement_dir function prevents path traversal by validating that the engagement ID is a single path component that cannot escape the base directory.

Usage

Import this class when you need to capture and store evidence for findings. Used by the agent loop, verifier, and report generator.

Code Reference

Source Location

Signature

@dataclass(frozen=True)
class EvidenceArtifact:
    id: str
    finding_id: str
    artifact_type: str  # tool_output, http_request, http_response, screenshot, pcap, config
    filename: str
    sha256: str
    size_bytes: int
    created_at: str

class EvidenceCollector:
    def __init__(self, base_dir: str = "evidence") -> None: ...
    async def store_tool_output(self, engagement_id: str, finding_id: str, tool_name: str, command: str, stdout: str, stderr: str, exit_code: int, duration_ms: int) -> EvidenceArtifact: ...
    async def store_http_interaction(self, engagement_id: str, finding_id: str, request: str, response: str) -> EvidenceArtifact: ...
    async def store_file(self, engagement_id: str, finding_id: str, filepath: str, artifact_type: str = "config") -> EvidenceArtifact: ...

def resolve_engagement_dir(base: str | Path, engagement_id: str) -> Path: ...

Import

from engine.evidence import EvidenceCollector, EvidenceArtifact, resolve_engagement_dir

I/O Contract

Inputs

Name Type Required Description
engagement_id str Yes Engagement ID (validated against path traversal)
finding_id str Yes Finding ID to associate artifact with
tool_name str Yes (store_tool_output) Name of the tool that produced the output
stdout/stderr str Yes (store_tool_output) Tool output streams

Outputs

Name Type Description
EvidenceArtifact dataclass Frozen artifact metadata with SHA-256 hash, filename, size

Usage Examples

Store Tool Output Evidence

import asyncio
from engine.evidence import EvidenceCollector

async def main():
    ec = EvidenceCollector(base_dir="~/.pentest-ai/evidence")

    artifact = await ec.store_tool_output(
        engagement_id="abc123",
        finding_id="f1",
        tool_name="nuclei",
        command="nuclei -u https://example.com -t cves",
        stdout='[critical] CVE-2024-1234 detected',
        stderr="",
        exit_code=0,
        duration_ms=5000,
    )
    print(f"Stored: {artifact.filename} (SHA-256: {artifact.sha256[:16]}...)")

asyncio.run(main())

Related Pages

Page Connections

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