Implementation:0xSteph Pentest ai import scope
| Knowledge Sources | |
|---|---|
| Domains | Security_Testing, Bug_Bounty |
| Last Updated | 2026-10-23 12:00 GMT |
Overview
Concrete scope import function that parses a bug-bounty platform's scope export into an ImportedScope with allowed, excluded, and skipped entries, supporting HackerOne, Bugcrowd, Intigriti, YesWeHack, and generic formats.
Description
import_scope parses a bug-bounty program's scope export (in-scope and out-of-scope assets) into an ImportedScope dataclass with three lists:
- allowed: In-scope targets (domains, wildcards, CIDRs)
- excluded: Out-of-scope targets (exclusions win over allow)
- skipped: Unparseable or unsupported entries
Supported platforms:
- hackerone / h1: HackerOne scope JSON
- bugcrowd: Bugcrowd scope JSON
- intigriti: Intigriti scope JSON
- yeswehack / ywh: YesWeHack scope JSON
- generic: Simple in-scope/out-of-scope lists
De-duplicates entries while preserving order. An entry that is both in and out of scope stays excluded (exclusions win).
Usage
Import this when you need to:
- Import a bug-bounty program's scope for `ptai start --scope-file`
- Parse platform-specific scope exports into a unified format
Code Reference
Source Location
- Repository: pentest-ai
- File: engine/bounty/scope_import.py
Signature
@dataclass
class ImportedScope:
allowed: list[str]
excluded: list[str]
skipped: list[str]
def import_scope(platform: str, data: Any) -> ImportedScope:
"""Parse a program scope export for ``platform`` into an ImportedScope.
``data`` may be a parsed dict/list or a JSON string.
Raises ValueError for an unknown platform or unparseable data.
"""
Import
from engine.bounty.scope_import import import_scope, ImportedScope
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| platform | str | Yes | hackerone/bugcrowd/intigriti/yeswehack/generic |
| data | Any | Yes | Parsed dict/list or JSON string from platform export |
Outputs
| Name | Type | Description |
|---|---|---|
| returns | ImportedScope | allowed, excluded, skipped lists |
| raises | ValueError | Unknown platform or unparseable data |
Usage Examples
Importing HackerOne Scope
import json
from engine.bounty.scope_import import import_scope
with open("h1-scope.json") as f:
data = json.load(f)
scope = import_scope("hackerone", data)
print(f"Allowed: {len(scope.allowed)} targets")
print(f"Excluded: {len(scope.excluded)} targets")
# Write scope file for ptai start --scope-file
with open("scope.txt", "w") as f:
for target in scope.allowed:
f.write(f"{target}\n")
for target in scope.excluded:
f.write(f"!{target}\n")
Related Pages
Implements Principle
- Principle:0xSteph_Pentest_ai_Bug_Bounty_Automation_Principle
- Principle:0xSteph_Pentest_ai_Scope_Enforcement