Skip to main content

Add your description here

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

specphp_scanner-0.0.5.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

specphp_scanner-0.0.5-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file specphp_scanner-0.0.5.tar.gz.

File metadata

  • Download URL: specphp_scanner-0.0.5.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.4

File hashes

Hashes for specphp_scanner-0.0.5.tar.gz
Algorithm Hash digest
SHA256 1adfc6b6edab872657d749a276c26d126232ccc2ff26410797dc47f88376034a
MD5 62dcd3b3b2029499657aba87d996d933
BLAKE2b-256 86d16929e465da8781ba7c4903d1f42f2af294cf184b2efa2a40de6b0d4b2578

See more details on using hashes here.

File details

Details for the file specphp_scanner-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for specphp_scanner-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 dba4d1a62399f8d9804e75db6d619c52fbb848937078bee99589767089f2fa85
MD5 5ceb64c7f53655499d00fc1365a4b2a0
BLAKE2b-256 29e4145b1396e4e215c2350c1a268750c2b4bc19adc33bbec8de1d52dc26e8a5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page