Skip to main content

OpenAPI Scanner

A tool for scanning and testing OpenAPI specifications.

Features

  • Support for both JSON and YAML OpenAPI specifications
  • Flexible authentication system
  • Automatic path parameter replacement
  • Custom header support
  • Multiple report formats (Console, HTML, CSV, JSONL)

Installation

# Install dependencies
pip install -r requirements.txt

# Install in development mode
pip install -e .

Usage

Basic Usage

# Using JSON specification
python -m specphp_scanner spec.json --host localhost --port 8080

# Using YAML specification
python -m specphp_scanner spec.yaml --host localhost --port 8080

Using Authentication

# Using module path
python -m specphp_scanner spec.json --auth-class examples.koel.auth.KoelAuth --auth-params '{"email": "user@example.com", "password": "secret"}'

# Using file path
python -m specphp_scanner spec.json --auth-class ./examples/koel/auth.py --auth-params '{"email": "user@example.com", "password": "secret"}'

Using Custom Headers

python -m specphp_scanner spec.json --headers '{"X-Custom-Header": "value"}'

Generating Reports

# Console output (default)
python -m specphp_scanner spec.json

# HTML report
python -m specphp_scanner spec.json --format html --output report.html

# CSV report
python -m specphp_scanner spec.json --format csv --output report.csv

# JSONL report
python -m specphp_scanner spec.json --format jsonl --output report.jsonl

Command Line Options

  • spec_file: Path to OpenAPI specification file (JSON or YAML)
  • --host: Target host (default: localhost)
  • --port: Target port (default: 8080)
  • --auth-class: Authentication class path or Python file path
  • --auth-params: JSON string containing authentication parameters
  • --headers: JSON string containing custom headers
  • --format: Report format (console, html, csv, jsonl)
  • --output: Output file path for the report
  • --verbose, -v: Enable verbose logging

Creating Custom Authentication Classes

Create a class that inherits from BaseAuth:

from specphp_scanner.auth.base import BaseAuth

class MyCustomAuth(BaseAuth):
    def __init__(self, **kwargs):
        # Initialize your authentication parameters
        self.token = None

    def authenticate(self):
        # Implement your authentication logic
        # This method should be called before making API requests
        pass

    def get_headers(self):
        # Return headers required for authentication
        return {"Authorization": f"Bearer {self.token}"}

    def get_cookies(self):
        # Return cookies required for authentication
        return {}

Examples

See the examples directory for sample implementations.

Project Structure

specphp_scanner/
├── __init__.py
├── cli.py
├── scanner.py
├── auth/
│   ├── __init__.py
│   ├── base.py
│   └── factory.py
└── utils/
    ├── __init__.py
    ├── param_generator.py
    ├── report.py
    └── templates/
        └── report.html

Running Tests

pytest

Release files for specphp-scanner 0.0.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for specphp-scanner 0.0.13
File Size Uploaded
specphp_scanner-0.0.13.tar.gz 57.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for specphp-scanner 0.0.13
File Interpreter ABI Platform
specphp_scanner-0.0.13-py3-none-any.whl Python 3 none any Details

Total release size: 79.4 kB

Release files / specphp_scanner-0.0.13.tar.gz

Download URL specphp_scanner-0.0.13.tar.gz
Size 57.2 kB
Tags Source
SHA-256 checksum
How to use checksums
268e267f241ca09405252f647aae7fcd356539f774ba15dccb3433bebc756465
BLAKE2b-256 checksum
How to use checksums
0c8e6a959db21bc5a591612270a77b0558c8542f951f7f4e1cdc2f3e99fd80e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.8.12

Release files / specphp_scanner-0.0.13-py3-none-any.whl

Download URL specphp_scanner-0.0.13-py3-none-any.whl
Size 22.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e0069c119a0b186d42d656e92a669a7f345735638dbdab7def9d7f3ecb67b67
BLAKE2b-256 checksum
How to use checksums
e3e23ed3a9977bcb69bb6a009c894a6bf078a786972de4c822aa94d53356705d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.8.12

Release history Release notifications | RSS feed

This release

0.0.13 This release

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page