#artificial-intelligence #api-testing #swagger

bin+lib amalthea

AI-powered API testing and security vulnerability scanner - harnessing the volcanic power of Jupiter's moon

11 releases (4 breaking)

0.5.1 Oct 13, 2025
0.4.0 Oct 7, 2025
0.3.0 Oct 6, 2025
0.2.5 Oct 6, 2025
0.1.1 Sep 26, 2025

#1762 in Authentication

Download history 442/week @ 2025-09-26 503/week @ 2025-10-03 225/week @ 2025-10-10 46/week @ 2025-10-17 5/week @ 2025-10-24

891 downloads per month

MIT license

13MB
13K SLoC

Contains (ELF exe/lib, 12MB) releases/amalthea-linux-x86_64

Amalthea Amalthea

Crates.io Docker License: MIT Rust

Amalthea - AI-powered API testing tool with comprehensive test generation, execution, database integration, and advanced AI security vulnerability scanning capabilities!

๐Ÿš€ Production Ready v0.5.0

โœ… ๐Ÿค– NEW: AI-Powered Security Vulnerability Scanner: Complete AI security module with GPT-4 intelligence
โœ… ๐Ÿ” NEW: 14+ Vulnerability Types: SQL Injection, XSS, Auth Bypass, Rate Limiting, and more
โœ… ๏ฟฝ๏ธ NEW: OWASP & CWE Integration: Professional security assessment with industry standards
โœ… ๐Ÿ“Š NEW: Multi-Format Security Reports: Console, HTML, JSON with strategic insights
โœ… โš™๏ธ NEW: Configurable AI Scanning: Intensity levels, focus areas, confidence thresholds
โœ… ๐Ÿ—„๏ธ Database Integration Testing: Complete database testing framework with multi-database support
โœ… ๐Ÿ“Š State Validation: Validate database state after API calls with comprehensive assertions
โœ… ๐ŸŒฑ Data Seeding & Cleanup: Automated test data seeding with proper cleanup management
โœ… โšก Query Performance Testing: Built-in performance monitoring and query optimization insights
โœ… ๐Ÿ”„ CI/CD Pipeline Integration: Full automation support with reporting and Docker containers
โœ… Multi-Provider AI Support: OpenAI, Anthropic Claude, Google Gemini, Local models (Ollama)
โœ… Test Generation & Execution: Generate test cases AND execute them automatically
โœ… ๐Ÿ” Comprehensive Authentication: Bearer, Basic, API Key, JWT, OAuth2
โœ… ๐Ÿš€ Advanced Protocol Testing: WebSocket, GraphQL, gRPC, Server-Sent Events
โœ… ๐Ÿ›ก๏ธ Enhanced Security Testing: AI-powered vulnerability detection + traditional security scans
โœ… ๐Ÿงช Test Data Fuzzing: Advanced fuzzing with 20+ strategies for security vulnerability testing
โœ… Universal AI Client: Unified interface for all AI providers
โœ… Postman Collections: Full support for Postman collection imports
โœ… Smart Date Generation: Automatic current date injection in test data (no more 2023 dates!)
โœ… Docker Ready: docker pull ksdco/amalthea:0.5.0

โœจ Features

  • ๐Ÿค– Multi-Provider AI Support - OpenAI, Anthropic Claude, Google Gemini, Local models (Ollama)
  • ๐Ÿงช Test Generation & Execution - Generate comprehensive test cases and execute them automatically
  • ๐Ÿ” Comprehensive Authentication - Bearer Token, HTTP Basic, API Key, JWT, OAuth2 authentication support
  • ๐Ÿš€ Advanced Protocol Testing - WebSocket, GraphQL, gRPC, Server-Sent Events (SSE) testing capabilities
  • ๐Ÿค– ๐Ÿ†• AI-Powered Security Scanner - GPT-4 intelligent vulnerability detection with OWASP/CWE mapping
  • ๐Ÿ›ก๏ธ Enhanced Security Testing - AI-driven + traditional security vulnerability scanning (SQL injection, XSS, auth bypass, rate limiting, security headers, etc.)
  • ๐ŸŽฏ Test Data Fuzzing - Advanced fuzzing with 20+ strategies including SQL injection, XSS, buffer overflow, unicode attacks, and malicious payloads for comprehensive security testing
  • ๐Ÿ“Š Knowledge Base Integration - Custom knowledge bases with valid data patterns and examples for realistic test generation
  • ๐Ÿ“Š Execution Reports - Detailed pass/fail results with comprehensive statistics
  • ๐Ÿ” Smart URL Detection - Automatic base URL extraction from OpenAPI specs and Postman collections
  • ๐Ÿ“ OpenAPI/Swagger Support - Full OpenAPI 3.0 and 2.0 specification support
  • ๐Ÿ“ฎ Postman Collection Support - Import and test from Postman Collections with variable support
  • ๐Ÿ”„ Universal AI Client - Unified interface routing to appropriate AI providers
  • ๐Ÿ“… Smart Date Generation - Automatic current date injection in test data (no more 2023 dates!)
  • ๏ฟฝ HTML Reports - Beautiful interactive reports with charts and visualizations
  • ๏ฟฝ๐Ÿ’ฐ Cost Optimization - Per-endpoint processing to avoid token limits and save costs
  • ๐Ÿณ Docker Ready - Available on Docker Hub as ksdco/amalthea
  • โšก Fast & Reliable - Built with Rust for maximum performance
  • ๐Ÿ—๏ธ Professional Architecture - Modular, maintainable codebase

๐Ÿ“‹ Version History & New Features

๐ŸŽ‰ v0.5.0 - Latest (October 2025)

  • ๐Ÿค– ๐Ÿ†• AI-Powered Security Vulnerability Scanner - Complete AI security module with 4 sub-components
  • ๐Ÿ” ๐Ÿ†• GPT-4 Intelligence - AI-powered analysis using OpenAI for intelligent vulnerability detection
  • ๐Ÿ›ก๏ธ ๐Ÿ†• 14+ Vulnerability Types - SQL Injection, XSS, Authentication Bypass, Authorization Flaws, Rate Limiting, Information Disclosure, Input Validation, Session Management, CSRF, Insecure Deserialization, XXE Injection, Security Misconfiguration, Broken Access Control, Cryptographic Failures
  • ๐Ÿ“Š ๐Ÿ†• Professional Security Reporting - Multi-format reports (Console, HTML, JSON) with strategic insights
  • โš™๏ธ ๐Ÿ†• Configurable AI Scanning - Scan intensity levels (1-5), focus areas, confidence thresholds
  • ๐ŸŽฏ ๐Ÿ†• OWASP & CWE Integration - Maps vulnerabilities to OWASP Top 10 and CWE categories
  • ๐Ÿ“ˆ ๐Ÿ†• AI Security CLI - New arguments: --ai-security-scan, --ai-scan-intensity, --ai-scan-focus, --ai-scan-confidence

๐ŸŽ‰ v0.4.0 - Previous (October 2025)

  • ๐Ÿ—„๏ธ ๐Ÿ†• Database Integration Testing - Complete database testing framework with multi-database support
  • ๐Ÿ“Š ๐Ÿ†• State Validation - Validate database state after API calls with comprehensive assertions
  • ๐ŸŒฑ ๐Ÿ†• Data Seeding & Cleanup - Automated test data seeding with dependency management and proper cleanup
  • โšก ๐Ÿ†• Query Performance Testing - Built-in performance monitoring with configurable thresholds
  • ๐Ÿ”„ ๐Ÿ†• CI/CD Pipeline Integration - Full automation support with JUnit XML/JSON reporting
  • ๐Ÿณ ๐Ÿ†• Multi-Database Support - PostgreSQL, MySQL, SQLite, MongoDB, Redis with feature flags
  • ๐Ÿงช ๐Ÿ†• Database Testing Examples - E-commerce, User Management, Performance testing scenarios
  • ๐Ÿ“š ๐Ÿ†• Comprehensive Documentation - Quick start guide, usage documentation, and CI/CD integration

๐ŸŽ‰ v0.3.0 - Previous (October 2025)

  • ๐Ÿ” ๐Ÿ†• Comprehensive Authentication - Bearer Token, HTTP Basic, API Key, JWT, OAuth2 support
  • ๐Ÿš€ ๐Ÿ†• Advanced Protocol Testing - WebSocket, GraphQL, gRPC, Server-Sent Events (SSE) testing
  • ๐Ÿ›ก๏ธ ๐Ÿ†• Security Analysis - JWT validation, password strength analysis, security recommendations
  • ๐Ÿ’ป ๐Ÿ†• Enhanced CLI - New authentication and protocol testing arguments
  • ๐Ÿ“š ๐Ÿ†• Complete Documentation - Comprehensive guides and examples for new features

v0.2.5 - Previous (October 2025)

  • ๐ŸŽฏ Advanced Test Data Fuzzing - Comprehensive fuzzing with 5 intensity levels and 20+ strategies
  • ๐Ÿ›ก๏ธ Enhanced Security Testing - Comprehensive vulnerability scanning with 8+ security checks
  • ๐Ÿ”€ Fuzzing vs Security Distinction - Clear separation between robustness testing and vulnerability detection
  • ๐ŸŽฒ Configurable Fuzzing Intensity - 5 levels from light (CI/CD) to extreme (stress testing)
  • ๐Ÿ” Smart URL Detection - Automatic base URL extraction from OpenAPI specs and Postman collections
  • ๐Ÿ“ฎ Advanced Postman Support - Full Postman Collection v2.0+ support with variable handling
  • ๐Ÿ”„ Universal AI Client - Unified interface routing to all AI providers automatically
  • ๐Ÿ“… Smart Date Generation - Automatic current date injection (2025+ dates, not 2023!)
  • ๐Ÿงช Enhanced Test Generation - 8-12 comprehensive test cases per endpoint (vs 3-5 previously)
  • ๐Ÿ“Š HTML Reports - Beautiful interactive reports with charts and security dashboards
  • ๐Ÿ› ๏ธ Improved Error Handling - Better error messages and graceful fallbacks
  • ๐Ÿ“Š Enhanced Reporting - Detailed security vulnerability reports with severity levels

๐Ÿš€ v0.2.4 - Previous Release

  • ๐Ÿ›ก๏ธ Enhanced Security Testing - Comprehensive vulnerability scanning with 8+ security checks
  • ๐ŸŽฏ Test Data Fuzzing - Advanced fuzzing system with 20+ strategies for security vulnerability testing
  • ๐Ÿ” Smart URL Detection - Automatic base URL extraction from OpenAPI specs and Postman collections
  • ๐Ÿ“ฎ Advanced Postman Support - Full Postman Collection v2.0+ support with variable handling
  • ๐Ÿ”„ Universal AI Client - Unified interface routing to all AI providers automatically
  • ๐Ÿ“… Smart Date Generation - Automatic current date injection (2025+ dates, not 2023!)
  • ๐Ÿงช Enhanced Test Generation - 8-12 comprehensive test cases per endpoint (vs 3-5 previously)
  • ๐Ÿ“Š HTML Reports - Beautiful interactive reports with charts and security dashboards
  • ๐Ÿ› ๏ธ Improved Error Handling - Better error messages and graceful fallbacks
  • ๐Ÿ“Š Enhanced Reporting - Detailed security vulnerability reports with severity levels

๐Ÿš€ v0.2.2 - Previous Release

  • ๐Ÿค– Multi-Provider AI Support - Added support for OpenAI, Anthropic Claude, Google Gemini, Local models
  • ๐Ÿงช Test Generation & Execution - Combined test generation with automatic execution
  • ๐Ÿ“ OpenAPI/Swagger Support - Full OpenAPI 3.0 and 2.0 specification support
  • ๐Ÿณ Docker Integration - Complete Docker support with automated builds

๐ŸŒŸ v0.2.1 - Foundation Release

  • โšก Core Architecture - Built with Rust for maximum performance
  • ๐Ÿ’ฐ Cost Optimization - Per-endpoint processing to save API costs
  • ๐Ÿ“Š Execution Reports - Pass/fail statistics and detailed results
  • ๐Ÿ—๏ธ Professional Codebase - Modular, maintainable architecture

๐Ÿ“… Smart Date Generation

Amalthea automatically injects current dates into test data to avoid outdated timestamps:

Before (v0.2.2):

{
  "dateRange": {
    "start": "2023-01-01",
    "end": "2023-12-31"
  }
}

After (v0.2.4):

{
  "dateRange": {
    "start": "2025-01-01", 
    "end": "2026-12-31"
  }
}

Features:

  • ๐Ÿ—“๏ธ Current Year Injection - Uses actual current year (2025+)
  • ๐Ÿ“ˆ Date Range Intelligence - Current year to next year ranges
  • โฐ ISO Timestamp Support - Realistic current timestamps
  • ๐Ÿ”„ Dynamic Updates - Always uses current date, never hardcoded

๐ŸŽฏ Test Data Fuzzing vs Security Testing

Amalthea provides two distinct but complementary testing approaches:

๐ŸŽฒ Fuzzing (--fuzz) - API Robustness Testing

Purpose: Test API stability and robustness with random/malformed data

What it does:

  • Generates random, oversized, or malformed data to stress-test APIs
  • Tests how APIs handle unexpected input gracefully
  • Finds crashes, errors, and edge cases in data processing
  • Validates input validation and error handling logic

Example fuzz data:

{
  "invoice_id": "AAAAAAAAAAAAAAAAAAAAAAAAAAAA...",  // Extremely long strings
  "amount": 999999999999999999,                    // Boundary values
  "items": [null, null, null, ...],               // Unexpected nulls
  "๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ": "unicode_data",                         // Unicode/emoji
  "nested": {"very": {"deep": {"object": "test"}}} // Deep nesting
}

Intensity Levels (1-5):

  • Level 1: Light fuzzing (2-3 test cases per endpoint)
  • Level 2: Moderate fuzzing (3-5 test cases)
  • Level 3: Standard fuzzing (5-7 test cases) - Default
  • Level 4: Heavy fuzzing (7-10 test cases)
  • Level 5: Extreme fuzzing (10+ test cases)

๐Ÿ›ก๏ธ Security Testing (--security) - Vulnerability Detection

Purpose: Detect specific security vulnerabilities and attack vectors

What it does:

  • Tests for known security vulnerabilities (OWASP Top 10)
  • Uses crafted payloads to detect injection attacks
  • Validates authentication and authorization controls
  • Checks security headers and configurations

Example security payloads:

{
  "username": "' OR '1'='1",                       // SQL injection
  "comment": "<script>alert('XSS')</script>",      // XSS attack
  "file_path": "../../../etc/passwd",              // Path traversal
  "command": "; ls -la",                           // Command injection
  "ldap_query": ")(cn=*))(|(cn=*"                  // LDAP injection
}

Security Test Categories:

  • ๐Ÿ’‰ Injection Attacks - SQL, NoSQL, LDAP, XPath injection
  • ๐Ÿšจ Cross-Site Scripting (XSS) - Reflected, stored, DOM-based XSS
  • ๐Ÿ’ป Command Injection - OS command execution attempts
  • ๐Ÿ“‚ Path Traversal - Directory traversal and file access
  • ๐Ÿ” Authentication Bypass - Token validation, session handling
  • ๐Ÿ“‹ Security Headers - Missing security headers check
  • โฑ๏ธ Rate Limiting - Brute force and DoS protection

๐Ÿค When to Use What

Scenario Recommended Approach
Development Testing --fuzz --fuzz-intensity 2
Security Audit --security
Pre-Production --fuzz --security (both)
CI/CD Pipeline --fuzz --fuzz-intensity 1 --security
Stress Testing --fuzz --fuzz-intensity 4-5
Compliance Check --security
# Comprehensive testing with both fuzzing and security
cargo run -- --file api.json --fuzz --fuzz-intensity 3 --security --generate-only

# Light testing for CI/CD
cargo run -- --file api.json --fuzz --fuzz-intensity 1 --security --generate-only

# Heavy stress + security testing
cargo run -- --file api.json --fuzz --fuzz-intensity 5 --security --kb knowledge-base.json

๐ŸŽฏ Test Data Fuzzing

Amalthea includes advanced fuzzing capabilities to test API robustness and security with comprehensive vulnerability testing:

Fuzzing Strategies

Data Generation (20+ Strategies):

  • ๐Ÿ”ค String Fuzzing - Special characters, encoding attacks, format strings
  • ๐Ÿ”ข Number Fuzzing - Boundary values, overflow attempts, invalid formats
  • ๐Ÿ“ JSON Fuzzing - Malformed structures, type confusion, nested attacks
  • ๐ŸŒ Unicode Fuzzing - Multi-byte sequences, normalization attacks
  • ๐Ÿ“Š Array Fuzzing - Size attacks, type mixing, nested structures

Security-Focused Fuzzing (12+ Vulnerability Types):

  • ๐Ÿ’‰ SQL Injection - Various SQL attack vectors and bypasses
  • ๐Ÿšจ XSS (Cross-Site Scripting) - Script injection and encoding bypasses
  • ๐Ÿ’ป Command Injection - OS command execution attempts
  • ๐Ÿ“‚ Path Traversal - Directory traversal and file access attacks
  • ๐Ÿ“Š Buffer Overflow - Memory corruption and boundary attacks
  • ๐Ÿ”— LDAP/XPath Injection - Directory and XML query attacks
  • ๐Ÿ“‹ Template Injection - Server-side template attacks
  • ๐ŸŒ Header Injection - HTTP header manipulation
  • ๐Ÿ”„ Type Confusion - Data type mismatch attacks
  • ๐Ÿ“ฆ Deserialization - Object deserialization vulnerabilities

Fuzzing Usage

# Enable fuzzing mode
amalthea --provider openai --model gpt-4o-mini --file api.json --fuzz

# Fuzzing with custom intensity (1-5, default: 3)
amalthea --provider openai --model gpt-4o-mini --file api.json --fuzz --fuzz-intensity 5

# Fuzzing with security testing
amalthea --provider openai --model gpt-4o-mini --file api.json --fuzz --security

# Fuzzing with knowledge base for realistic base data
amalthea --provider openai --model gpt-4o-mini --file api.json --fuzz --kb knowledge-base.json

# Generate fuzzing data only (no execution)
amalthea --provider openai --model gpt-4o-mini --file api.json --fuzz --generate-only

# Fuzzing with HTML report
amalthea --provider openai --model gpt-4o-mini --file api.json --fuzz --security --html-report

Fuzzing Benefits

  • ๐Ÿ›ก๏ธ Security Hardening - Discover vulnerabilities before attackers do
  • ๐Ÿ” Edge Case Discovery - Find unexpected API behaviors and crashes
  • ๐Ÿ“Š Robustness Testing - Ensure APIs handle malformed input gracefully
  • ๐ŸŽฏ Targeted Testing - Focus on specific vulnerability types
  • ๐Ÿ“ˆ Scalable Testing - Adjustable intensity levels for different testing phases

๐Ÿงช Enhanced Test Generation

Comprehensive Test Coverage

Before (v0.2.2): 3-5 basic test cases After (v0.2.3): 8-12 comprehensive test cases covering:

  1. Success Scenarios (200/201/204) - 3+ cases
  2. Client Errors (400/401/403/404/422) - 3+ cases
  3. Server Errors (500/502/503) - 2+ cases
  4. Edge Cases (boundary values, special characters) - 2+ cases
  5. Security Scenarios (unauthorized access, injection attempts) - 2+ cases

Example Generated Test Case

{
  "name": "Create Invoice - Success with Current Date",
  "method": "POST",
  "url": "/api/v1/invoices",
  "headers": {
    "Content-Type": "application/json",
    "Authorization": "Bearer test-token",
    "User-Agent": "Amalthea-Test-Client"
  },
  "body": {
    "invoiceNumber": "INV-2025-001",
    "issueDate": "2025-10-01",
    "dueDate": "2025-11-01",
    "amount": 1250.00,
    "currency": "USD",
    "items": [
      {
        "description": "Software License",
        "quantity": 1,
        "unitPrice": 1250.00,
        "total": 1250.00
      }
    ]
  },
  "expected_status": 201,
  "description": "Create a new invoice with valid current date data and comprehensive item details"
}

๐Ÿš€ Quick Start

Installation

# Install from crates.io (recommended)
cargo install amalthea

# Or build from source
git clone https://github.com/KSD-CO/amalthea.git
cd amalthea
make build

# Via Docker (ready to use)
docker pull ksdco/amalthea:0.5.0
docker pull ksdco/amalthea:latest

# Pre-built binaries (GitHub Releases)
wget https://github.com/KSD-CO/amalthea/releases/download/v0.5.0/amalthea-linux-x86_64
chmod +x amalthea-linux-x86_64

Basic Usage

# Generate and execute test cases with OpenAI
amalthea --provider openai --model gpt-4o-mini --file api.json

# Generate only (no execution)
amalthea --provider openai --model gpt-4o-mini --file api.json --generate-only

# Use with local model (Ollama)
amalthea --provider local --model mistral:latest --file api.json

# Use with Claude
amalthea --provider anthropic --model claude-3-haiku --file api.json

# Use with Gemini
amalthea --provider google --model gemini-1.5-flash --file api.json

# Generate beautiful HTML report
amalthea --provider openai --model gpt-4o-mini --file api.json --format html --output report.html

# HTML report with security testing
amalthea --provider openai --model gpt-4o-mini --file api.json --security --html-report --output security-report.html

# Use knowledge base for realistic test data
amalthea --provider openai --model gpt-4o-mini --file api.json --kb knowledge-base.json --html-report

# Database integration testing (v0.4.0+)
make demo          # Quick database testing demo
make examples      # All database examples
make ci            # CI/CD pipeline simulation

# Enable AI-powered security vulnerability scanning (v0.5.0+)
amalthea --provider openai --model gpt-4o-mini --file api.json --ai-security-scan

# AI security scan with custom intensity and focus areas
amalthea --provider openai --model gpt-4o-mini --file api.json --ai-security-scan --ai-scan-intensity 5 --ai-scan-focus "sql,xss,auth"

# AI security scan with confidence threshold and JSON output
amalthea --provider openai --model gpt-4o-mini --file api.json --ai-security-scan --ai-scan-confidence 0.8 --json-output

# Enable fuzzing for security vulnerability testing
amalthea --provider openai --model gpt-4o-mini --file api.json --fuzz

# Fuzzing with custom intensity and security testing
amalthea --provider openai --model gpt-4o-mini --file api.json --fuzz --fuzz-intensity 5 --security

## ๐Ÿ” Authentication Support (v0.3.0+)

Amalthea now supports comprehensive authentication for secure API testing:

### Bearer Token Authentication
```bash
# Bearer token authentication
amalthea --provider openai --model gpt-4o-mini --file api.json --auth-type bearer --auth-token "your-bearer-token"

HTTP Basic Authentication

# Basic authentication with username/password
amalthea --provider openai --model gpt-4o-mini --file api.json --auth-type basic --auth-token "username" --auth-password "password"

API Key Authentication

# API key with custom header
amalthea --provider openai --model gpt-4o-mini --file api.json --auth-type api-key --auth-token "your-api-key" --auth-header "X-API-Key"

# API key with Authorization header (default)
amalthea --provider openai --model gpt-4o-mini --file api.json --auth-type api-key --auth-token "your-api-key"

JWT Authentication

# JWT token authentication with automatic Bearer prefix
amalthea --provider openai --model gpt-4o-mini --file api.json --auth-type jwt --auth-token "your-jwt-token"

OAuth2 Authentication

# OAuth2 access token
amalthea --provider openai --model gpt-4o-mini --file api.json --auth-type oauth2 --auth-token "your-access-token"

๐Ÿš€ Advanced Protocol Testing (v0.3.0+)

Test modern API protocols beyond traditional REST:

WebSocket Testing

# WebSocket endpoint testing
amalthea --provider openai --model gpt-4o-mini --file api.json --websocket --ws-url "wss://echo.websocket.org"

# WebSocket with authentication
amalthea --provider openai --model gpt-4o-mini --file api.json --auth-type bearer --auth-token "token" --websocket --ws-url "wss://secure.example.com/ws"

GraphQL Testing

# GraphQL API testing
amalthea --provider openai --model gpt-4o-mini --file api.json --graphql --graphql-url "https://api.github.com/graphql"

# GraphQL with JWT authentication
amalthea --provider openai --model gpt-4o-mini --file api.json --auth-type jwt --auth-token "jwt-token" --graphql --graphql-url "https://secure-graphql.example.com"

gRPC Testing

# gRPC service testing
amalthea --provider openai --model gpt-4o-mini --file api.json --grpc --grpc-url "grpc.example.com:443"

# gRPC with API key authentication
amalthea --provider openai --model gpt-4o-mini --file api.json --auth-type api-key --auth-token "grpc-key" --grpc --grpc-url "secure-grpc.example.com:443"

Server-Sent Events (SSE) Testing

# SSE endpoint testing
amalthea --provider openai --model gpt-4o-mini --file api.json --sse --sse-url "https://api.example.com/events"

# SSE with OAuth2 authentication
amalthea --provider openai --model gpt-4o-mini --file api.json --auth-type oauth2 --auth-token "access-token" --sse --sse-url "https://secure-events.example.com/stream"

Combined Testing

# Test multiple protocols with authentication
amalthea --provider openai --model gpt-4o-mini --file api.json \
  --auth-type bearer --auth-token "multi-protocol-token" \
  --websocket --ws-url "wss://api.example.com/ws" \
  --graphql --graphql-url "https://api.example.com/graphql" \
  --security --html-report

AI Security + Light fuzzing for CI/CD pipelines

amalthea --provider openai --model gpt-4o-mini --file api.json --ai-security-scan --ai-scan-intensity 2 --fuzz --fuzz-intensity 1 --security --generate-only

Comprehensive testing: AI Security + Fuzzing + Traditional Security + Knowledge Base + HTML Report

amalthea --provider openai --model gpt-4o-mini --file api.json --ai-security-scan --ai-scan-intensity 4 --fuzz --security --kb knowledge-base.json --html-report


## ๐Ÿค– AI-Powered Security Vulnerability Scanner (v0.5.0+)

Amalthea v0.5.0 introduces a revolutionary **AI-Powered Security Vulnerability Scanner** that uses OpenAI GPT-4 to intelligently detect complex security vulnerabilities beyond traditional pattern matching.

### ๐Ÿ” Key Features

#### **AI-Driven Intelligence**
- **GPT-4 Analysis**: Uses OpenAI's most advanced models for intelligent vulnerability detection
- **Business Logic Understanding**: Detects complex vulnerabilities that traditional scanners miss  
- **Contextual Analysis**: Understands API endpoints in business context for accurate assessment
- **Confidence Scoring**: AI-powered accuracy assessment (0.0-1.0) for each vulnerability

#### **Comprehensive Vulnerability Detection**
**14+ Vulnerability Types Supported:**
- ๐Ÿ’‰ **SQL Injection** - Database query manipulation attacks
- ๐Ÿšจ **Cross-Site Scripting (XSS)** - Script injection vulnerabilities  
- ๐Ÿ” **Authentication Bypass** - Authentication mechanism flaws
- ๐Ÿ›ก๏ธ **Authorization Flaws** - Access control vulnerabilities
- โฑ๏ธ **Rate Limiting** - Missing or inadequate rate limiting
- ๐Ÿ“‹ **Information Disclosure** - Unintended data exposure
- โœ… **Input Validation** - Insufficient input sanitization
- ๐Ÿ”‘ **Session Management** - Session handling vulnerabilities
- ๐Ÿ›ก๏ธ **CSRF Vulnerability** - Cross-site request forgery
- ๐Ÿ“ฆ **Insecure Deserialization** - Object deserialization flaws
- ๐Ÿ“„ **XXE Injection** - XML external entity attacks
- โš™๏ธ **Security Misconfiguration** - Configuration weaknesses
- ๐Ÿšซ **Broken Access Control** - Access control bypasses
- ๐Ÿ”’ **Cryptographic Failures** - Weak cryptography implementations

#### **Professional Security Reporting**
- **Colored Console Output**: Rich formatting with emoji indicators and severity colors
- **HTML Security Reports**: Professional assessment documents with charts and insights
- **JSON Export**: Machine-readable format for CI/CD integration and automation
- **OWASP & CWE Mapping**: Industry-standard vulnerability categorization
- **Strategic Recommendations**: Business-level security guidance and remediation timelines

### ๐Ÿš€ AI Security Scanner Usage

#### **Basic AI Security Scanning**
```bash
# Enable AI-powered security scanning
amalthea --provider openai --model gpt-4o-mini --file api.json --ai-security-scan

# Set OpenAI API key
export OPENAI_API_KEY="sk-proj-your-openai-key"
amalthea --provider openai --model gpt-4o-mini --file api.json --ai-security-scan

Advanced Configuration

# High-intensity AI security scan
amalthea --provider openai --model gpt-4o-mini --file api.json --ai-security-scan --ai-scan-intensity 5

# Focus on specific vulnerability types
amalthea --provider openai --model gpt-4o-mini --file api.json --ai-security-scan --ai-scan-focus "sql,xss,auth,rate"

# Set confidence threshold (higher = more accurate, fewer results)
amalthea --provider openai --model gpt-4o-mini --file api.json --ai-security-scan --ai-scan-confidence 0.8

# Generate JSON security report
amalthea --provider openai --model gpt-4o-mini --file api.json --ai-security-scan --json-output

# Comprehensive AI security assessment
amalthea --provider openai --model gpt-4o-mini --file api.json \
  --ai-security-scan \
  --ai-scan-intensity 4 \
  --ai-scan-focus "sql,xss,auth,rate,info,input" \
  --ai-scan-confidence 0.7 \
  --json-output

Security Testing

# Run comprehensive security tests
amalthea --provider openai --model gpt-4o-mini --file api.json --security

# Security testing with Postman collections
amalthea --provider openai --model gpt-4o-mini --file collection.json --security

# Security testing with custom base URL
amalthea --provider openai --model gpt-4o-mini --file api.json --security --base-url https://api.example.com

# Security testing only (no test generation)
amalthea --provider openai --model gpt-4o-mini --file api.json --security --generate-only

# Fuzzing mode for comprehensive security testing
amalthea --provider openai --model gpt-4o-mini --file api.json --fuzz --security

# Fuzzing with custom intensity level (1-5)
amalthea --provider openai --model gpt-4o-mini --file api.json --fuzz --fuzz-intensity 4

Universal AI Client

# Use universal client for automatic provider routing
amalthea --provider universal --model gpt-4o-mini --file api.json

# Universal client with security testing
amalthea --provider universal --model gpt-4o-mini --file api.json --security

# Universal client with different models
amalthea --provider universal --model claude-3-haiku --file api.json
amalthea --provider universal --model gemini-1.5-flash --file api.json

๐Ÿ—„๏ธ Database Integration Testing (v0.4.0+)

Amalthea now provides comprehensive database integration testing capabilities to validate database state after API calls:

Quick Start with Database Testing

# Build with database features
cargo build --features database

# Run practical database testing demo
make demo

# Run all database examples
make examples

# Test with specific database
make test-sqlite     # SQLite
make test-postgres   # PostgreSQL
make test-mysql      # MySQL

Database Configuration

use amalthea::database::{DatabaseTester, DatabaseConfig};

let mut db_tester = DatabaseTester::new();

// SQLite (easiest to get started)
let config = DatabaseConfig::sqlite("./test.db");
db_tester.add_config("main".to_string(), config);

// PostgreSQL
let config = DatabaseConfig::postgres("localhost", 5432, "testdb", "user", "password");
db_tester.add_config("postgres".to_string(), config);

// MySQL, MongoDB, Redis also supported

State Validation After API Calls

use amalthea::database::{StateValidation, SeedConfig, QueryTest};

// Test API endpoint
simulate_api_call("POST", "/api/users", json!({
    "email": "test@example.com",
    "name": "Test User",
    "active": true
}));

// Validate database state
let validations = vec![
    StateValidation::record_exists(
        "User created in database",
        "users",
        create_conditions("email", "test@example.com")
    ),
    StateValidation::field_value(
        "User is active",
        "users",
        "active", 
        json!(true),
        create_conditions("email", "test@example.com")
    ),
    StateValidation::not_null(
        "Created timestamp set",
        "users",
        "created_at",
        create_conditions("email", "test@example.com")
    )
];

Data Seeding & Cleanup

// Setup test data
let seed_config = SeedConfig::new()
    .add_seed_set(
        SeedSet::new("Test Users", "users")
            .add_record(
                SeedRecord::new(1)
                    .field("email", "user1@test.com")
                    .field("name", "Test User 1")
                    .field("active", true)
            )
    )
    .cleanup_order(vec!["orders".to_string(), "users".to_string()]);

// Seed data before tests
db_tester.seed_data(seed_config).await?;

// Tests run here...

// Automatic cleanup after tests

Query Performance Testing

// Test query performance
let query_test = QueryTest::select(
    "Get active users",
    "SELECT * FROM users WHERE active = true ORDER BY created_at DESC LIMIT 100"
).performance(PerformanceLimits {
    max_execution_time_ms: 500,
    warn_execution_time_ms: 100,
    ..Default::default()
});

// Complex queries with performance monitoring
let analytics_query = QueryTest::analysis(
    "User order statistics",
    r#"
    SELECT u.id, u.name, COUNT(o.id) as order_count, SUM(o.total) as total_spent
    FROM users u 
    LEFT JOIN orders o ON u.id = o.user_id 
    WHERE u.active = true
    GROUP BY u.id, u.name
    ORDER BY total_spent DESC
    "#
).performance(PerformanceLimits {
    max_execution_time_ms: 2000,
    warn_execution_time_ms: 500,
    ..Default::default()
});

CI/CD Integration

# Run CI/CD pipeline simulation
make ci

# With environment variables
TEST_ENV=ci cargo run --example ci_cd_database_testing --features database

# Generate test reports
# Creates: database-test-results.xml (JUnit)
#         database-test-results.json (JSON)

Supported Databases

  • PostgreSQL - Full SQL testing with sqlx
  • MySQL - Complete MySQL support
  • SQLite - Lightweight for development
  • MongoDB - Document database testing
  • Redis - Key-value store testing

Makefile Commands

# Development
make build-db        # Build with database features
make demo           # Run practical examples
make examples       # Run all database examples
make ci             # Full CI/CD simulation

# Testing
make test-db        # All database tests
make test-sqlite    # SQLite specific
make test-postgres  # PostgreSQL specific
make test-mysql     # MySQL specific
make test-all-db    # Test all database types

# Documentation
make help           # Show all available commands

Real-World Examples

The implementation includes complete examples for:

  • E-commerce API Testing - Product creation, order processing, inventory management
  • User Management - Registration, authentication, profile updates, soft deletes
  • Performance Testing - Query optimization, load testing, performance monitoring
  • CI/CD Integration - Automated pipeline with reporting and Docker support

See examples/ directory for complete working examples and DATABASE_USAGE_GUIDE.md for detailed documentation.

๐Ÿ”ง Configuration

Environment Variables

Create a .env file for API keys:

# OpenAI
OPENAI_API_KEY="sk-proj-your-openai-key"

# Anthropic Claude  
ANTHROPIC_API_KEY="sk-ant-your-claude-key"

# Google Gemini
GOOGLE_API_KEY="your-google-gemini-key"

# Local Ollama (optional)
OLLAMA_HOST="http://localhost:11434"

AI Provider Setup

๐Ÿค– OpenAI Models

# Set OpenAI API key
export OPENAI_API_KEY="sk-proj-your-openai-key"

# Use different OpenAI models
amalthea --provider openai --model gpt-4o-mini --file api.json      # Cost-effective
amalthea --provider openai --model gpt-4o --file api.json           # High performance
amalthea --provider openai --model gpt-4 --file api.json            # Most capable
amalthea --provider openai --model gpt-3.5-turbo --file api.json    # Fast & affordable

๐Ÿง  Anthropic Claude

# Set Claude API key
export ANTHROPIC_API_KEY="sk-ant-your-claude-key"

# Use different Claude models
amalthea --provider anthropic --model claude-3-haiku --file api.json     # Fast
amalthea --provider anthropic --model claude-3-sonnet --file api.json    # Balanced
amalthea --provider anthropic --model claude-3-opus --file api.json      # Most capable

๐ŸŒŸ Google Gemini

# Set Gemini API key
export GOOGLE_API_KEY="your-google-gemini-key"

# Use different Gemini models
amalthea --provider google --model gemini-1.5-flash --file api.json      # Fast
amalthea --provider google --model gemini-1.5-pro --file api.json        # High performance

๐Ÿ  Local Models (Ollama)

# Install and start Ollama
curl -fsSL https://ollama.ai/install.sh | sh
ollama serve

# Pull models
ollama pull mistral:latest
ollama pull llama3.2:latest
ollama pull codellama:latest

# Use local models
amalthea --provider local --model mistral:latest --file api.json        # Mistral 7B
amalthea --provider local --model llama3.2:latest --file api.json       # Llama 3.2
amalthea --provider local --model codellama:latest --file api.json      # Code Llama

# Custom base URL for local models
amalthea --provider local --model mistral:latest --base-url http://localhost:11434 --file api.json

๐Ÿงช Test Execution

Amalthea not only generates test cases but also executes them automatically:

# Generate and execute tests (default behavior)
amalthea --provider openai --model gpt-4o-mini --file api.json

# Generate test cases only
amalthea --provider openai --model gpt-4o-mini --file api.json --generate-only

# Execute with custom output file
amalthea --provider openai --model gpt-4o-mini --file api.json --output my_tests.json

# Combined: Generate tests + Security scan
amalthea --provider openai --model gpt-4o-mini --file api.json --security

๐Ÿ›ก๏ธ Security Testing

Amalthea includes comprehensive security vulnerability scanning:

Security Test Categories:

  • ๐Ÿ” SQL Injection detection
  • ๐Ÿšจ Cross-Site Scripting (XSS)
  • ๐Ÿ” Authentication bypass testing
  • ๐Ÿ›ก๏ธ Authorization flaw detection
  • โœ… Input validation analysis
  • ๐Ÿ“‹ Security headers check
  • โฑ๏ธ Rate limiting verification
  • ๐Ÿ“Š Information disclosure detection
# Run security tests only
amalthea --security --generate-only --file api.json

# Security tests with AI provider
amalthea --provider openai --model gpt-4o-mini --file api.json --security

# Example security report output:
# ๐Ÿ›ก๏ธ Security Test Report
# ==================================================
# 
# ๐Ÿ“‹ SQL Injection - /users/{id}
#    Status: ๐Ÿ”ด VULNERABLE
#    Severity: CRITICAL
#    Details: SQL error detected with payload: ' OR '1'='1
#    Recommendation: Use parameterized queries and input validation
# 
# ๐Ÿ“‹ Missing Security Headers - X-Frame-Options
#    Status: ๐ŸŸก WARNING
#    Severity: MEDIUM
#    Details: Header X-Frame-Options is missing
#    Recommendation: Add X-Frame-Options header
# 
# ๐Ÿ“Š Summary:
#    ๐Ÿ”ด Critical: 1
#    ๐ŸŸ  High: 2
#    ๐ŸŸก Medium: 3
#    ๐Ÿ”ต Low: 1

๐Ÿ”„ Universal AI Client

The Universal AI Client provides a unified interface for all AI providers, automatically routing requests to the appropriate provider:

# Universal client automatically detects provider from model
amalthea --provider universal --model gpt-4o-mini --file api.json       # Routes to OpenAI
amalthea --provider universal --model claude-3-haiku --file api.json    # Routes to Anthropic
amalthea --provider universal --model gemini-1.5-flash --file api.json  # Routes to Google

# Universal client with security testing
amalthea --provider universal --model gpt-4o-mini --file api.json --security

# Universal client with different configurations
amalthea --provider universal --model gpt-4o-mini --file api.json --temperature 0.5 --max-tokens 2048

Benefits:

  • ๐Ÿ”„ Automatic Provider Routing - No need to specify provider manually
  • ๐Ÿงฉ Consistent Interface - Same API across all providers
  • ๐Ÿ›ก๏ธ Error Handling - Graceful fallbacks and error management
  • โšก Performance - Optimized routing and connection pooling

๐Ÿ› ๏ธ Development

Build from Source

# Clone repository
git clone https://github.com/KSD-CO/amalthea.git
cd amalthea

# Build with Cargo
cargo build --release

# Run tests
cargo test

# Install locally
cargo install --path .

Using Make

# Build project
make build

# Run tests
make test

# Check code quality
make check

# Clean artifacts
make clean

# Complete development workflow
make dev

# Publish release (maintainers only)
make publish

Publishing Workflow

# Complete publishing workflow
make publish

# This will:
# 1. Build optimized binary for Linux x86_64
# 2. Publish to crates.io
# 3. Push Docker images (ksdco/amalthea:0.2.3, ksdco/amalthea:latest)

โš™๏ธ Advanced Configuration

Custom Prompts & Templates

Amalthea allows you to customize AI prompts for specific testing needs:

# Create custom prompt templates
mkdir -p ~/.amalthea/templates

# Custom OpenAPI prompt template
cat > ~/.amalthea/templates/openapi_custom.txt << 'EOF'
You are an expert API testing specialist. Generate comprehensive test cases for the OpenAPI specification.

Current date: {current_date}
Current year: {current_year}

Requirements:
- Generate {test_count} test cases per endpoint
- Use realistic data with current dates ({current_year}+)
- Include authentication scenarios
- Cover edge cases and error conditions
- Add performance considerations

Format: JSON test cases with detailed descriptions.
EOF

# Use custom template
amalthea --provider openai --model gpt-4o-mini --file api.json --template ~/.amalthea/templates/openapi_custom.txt

Advanced AI Provider Configuration

Fine-tuning Parameters

# Temperature control (creativity vs consistency)
amalthea --provider openai --model gpt-4o-mini --file api.json --temperature 0.2  # Conservative
amalthea --provider openai --model gpt-4o-mini --file api.json --temperature 0.7  # Balanced (default)
amalthea --provider openai --model gpt-4o-mini --file api.json --temperature 0.9  # Creative

# Token limits for cost control
amalthea --provider openai --model gpt-4o-mini --file api.json --max-tokens 1024   # Concise
amalthea --provider openai --model gpt-4o-mini --file api.json --max-tokens 4096   # Detailed (default)

# Request timeout and retries
amalthea --provider openai --model gpt-4o-mini --file api.json --timeout 30 --retries 3

Custom Model Endpoints

# Custom OpenAI-compatible endpoints
export OPENAI_BASE_URL="https://api.custom-provider.com/v1"
amalthea --provider openai --model custom-gpt-4 --file api.json

# Azure OpenAI configuration
export AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com/"
export AZURE_OPENAI_API_KEY="your-azure-key"
amalthea --provider azure --model gpt-4o-mini --file api.json

# Local model with custom parameters
amalthea --provider local --model llama3.2:latest \
  --base-url http://localhost:11434 \
  --temperature 0.5 \
  --max-tokens 2048 \
  --file api.json

Configuration Files

.amalthea.toml Configuration

Create a configuration file for persistent settings:

# .amalthea.toml
[general]
default_provider = "openai"
default_model = "gpt-4o-mini"
output_dir = "./test_results"
parallel_requests = 5

[providers]
[providers.openai]
api_key_env = "OPENAI_API_KEY"
base_url = "https://api.openai.com/v1"
timeout = 30
retries = 3

[providers.anthropic]
api_key_env = "ANTHROPIC_API_KEY"
timeout = 45
retries = 2

[providers.local]
base_url = "http://localhost:11434"
timeout = 60

[testing]
default_test_count = 12
include_security = true
generate_only = false

[security]
enabled_checks = [
  "sql_injection",
  "xss", 
  "auth_bypass",
  "rate_limiting",
  "security_headers"
]
severity_threshold = "medium"

Environment Configuration

# Create comprehensive .env file
cat > .env << 'EOF'
# AI Provider Keys
OPENAI_API_KEY=sk-proj-your-openai-key
ANTHROPIC_API_KEY=sk-ant-your-claude-key
GOOGLE_API_KEY=your-google-gemini-key

# Azure OpenAI (if using)
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
AZURE_OPENAI_API_KEY=your-azure-key
AZURE_OPENAI_API_VERSION=2024-02-15-preview

# Local Models
OLLAMA_HOST=http://localhost:11434

# Advanced Settings
AMALTHEA_LOG_LEVEL=info
AMALTHEA_OUTPUT_FORMAT=json
AMALTHEA_CACHE_DIR=~/.amalthea/cache
AMALTHEA_MAX_PARALLEL=5

# Testing Configuration
DEFAULT_TIMEOUT=30
DEFAULT_RETRIES=3
ENABLE_CACHE=true
EOF

๐Ÿ“š Knowledge Base & Best Practices

๐Ÿง  Knowledge Base Integration

Amalthea supports custom knowledge bases to generate more realistic and domain-specific test data. Knowledge bases contain valid data patterns, examples, and constraints specific to your API domain.

Creating a Knowledge Base

Create a knowledge-base.json file with your API's valid data patterns:

{
  "api_name": "E-Invoice API",
  "description": "Knowledge base for e-invoice API testing with valid data patterns and examples",
  "valid_data": {
    "invoice_id": {
      "description": "Valid invoice ID patterns for e-invoice system",
      "examples": [
        "INV-2024-001234",
        "INV-2024-005678",
        "INV-2025-000001"
      ],
      "data_type": "string",
      "pattern": "^INV-\\d{4}-\\d{6}$"
    },
    "customer_info": {
      "description": "Valid customer information structure",
      "examples": [
        {
          "customer_id": "CUST-001234",
          "name": "Cรดng ty TNHH ABC",
          "tax_code": "0123456789",
          "address": "123 ฤฦฐแปng ABC, Quแบญn 1, TP.HCM",
          "email": "contact@abc.com",
          "phone": "0901234567"
        }
      ],
      "data_type": "object"
    },
    "payment_method": {
      "description": "Valid payment methods",
      "examples": [
        "CASH",
        "BANK_TRANSFER", 
        "CREDIT_CARD",
        "E_WALLET"
      ],
      "data_type": "string"
    }
  }
}

Using Knowledge Base

# Generate tests with knowledge base
amalthea --provider openai --model gpt-4o-mini --file api.json --kb knowledge-base.json

# Combine with security testing
amalthea --provider openai --model gpt-4o-mini --file api.json --kb knowledge-base.json --security

# Generate HTML report with knowledge base data
amalthea --provider openai --model gpt-4o-mini --file api.json --kb knowledge-base.json --html-report

Knowledge Base Benefits

  • Realistic Test Data: Generate test cases with domain-specific, valid data patterns
  • Better Coverage: AI understands your data constraints and generates appropriate edge cases
  • Consistency: Ensure all test cases follow your API's data standards
  • Domain Expertise: Embed business logic and validation rules into test generation

API Testing Patterns

Common Test Scenarios

# E-commerce API Testing with Knowledge Base
amalthea --provider openai --model gpt-4o-mini --file ecommerce-api.json --kb ecommerce-kb.json

# Banking API Security Focus with Knowledge Base
amalthea --provider openai --model gpt-4o-mini --file banking-api.json --kb banking-kb.json --security

# Healthcare API with Compliance Data
amalthea --provider openai --model gpt-4o-mini --file healthcare-api.json --kb healthcare-kb.json --security

Test Case Categories Explained

  1. Success Scenarios (200/201/204)

    • Valid data with current timestamps
    • Different payload variations
    • Boundary value testing
    • Happy path flows
  2. Client Errors (400/401/403/404/422)

    • Invalid input validation
    • Authentication failures
    • Authorization checks
    • Missing required fields
  3. Server Errors (500/502/503)

    • Stress testing scenarios
    • Invalid server states
    • Dependency failures
    • Rate limiting responses
  4. Edge Cases

    • Extremely large/small values
    • Special characters and encoding
    • Concurrent request handling
    • Data format variations
  5. Security Scenarios

    • Injection attack attempts
    • Authentication bypass
    • Data exposure checks
    • Header security validation

Performance Optimization

Cost-Effective Testing

# Optimize for cost with smaller models
amalthea --provider openai --model gpt-3.5-turbo --file api.json --max-tokens 1024

# Use local models for development
amalthea --provider local --model mistral:7b --file api.json

# Batch process multiple APIs
for api in api1.json api2.json api3.json; do
  amalthea --provider openai --model gpt-4o-mini --file $api --output "results_$(basename $api)"
done

Caching Strategies

# Enable response caching
export AMALTHEA_ENABLE_CACHE=true
export AMALTHEA_CACHE_TTL=3600  # 1 hour

# Cache location
export AMALTHEA_CACHE_DIR=~/.amalthea/cache

# Clear cache when needed
rm -rf ~/.amalthea/cache/*

Integration Patterns

CI/CD Pipeline Integration

# .github/workflows/api-testing.yml
name: API Testing with Amalthea

on:
  push:
    branches: [ main, develop ]
  pull_request:
    branches: [ main ]

jobs:
  api-test:
    runs-on: ubuntu-latest
    
    steps:
    - uses: actions/checkout@v3
    
      - name: Install Amalthea
      run: |
        wget https://github.com/KSD-CO/amalthea/releases/download/v0.5.0/amalthea-linux-x86_64
        chmod +x amalthea-linux-x86_64
        sudo mv amalthea-linux-x86_64 /usr/local/bin/amalthea
    
    - name: Run AI Security Scan
      env:
        OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
      run: |
        amalthea --provider openai --model gpt-4o-mini --file api/openapi.json --ai-security-scan --ai-scan-intensity 3 --security --json-output    - name: Upload Test Results
      uses: actions/upload-artifact@v3
      with:
        name: api-test-results
        path: test_results.json

Docker Integration

# Dockerfile for API testing container
FROM rust:1.82-slim as builder

WORKDIR /app
COPY . .
RUN cargo build --release

FROM debian:bookworm-slim

RUN apt-get update && apt-get install -y \
    ca-certificates \
    curl \
    && rm -rf /var/lib/apt/lists/*

COPY --from=builder /app/target/release/amalthea /usr/local/bin/amalthea

# Create test script
COPY <<EOF /usr/local/bin/run-tests.sh
#!/bin/bash
set -e

echo "๐Ÿš€ Starting API Testing with Amalthea"

# Run tests with all providers
amalthea --provider openai --model gpt-4o-mini --file /data/api.json --security --output /results/openai-results.json
amalthea --provider anthropic --model claude-3-haiku --file /data/api.json --security --output /results/claude-results.json

echo "โœ… Testing completed! Results saved to /results/"
EOF

RUN chmod +x /usr/local/bin/run-tests.sh

ENTRYPOINT ["/usr/local/bin/run-tests.sh"]

Troubleshooting Guide

Common Issues

  1. API Key Issues

    # Verify API key format
    echo $OPENAI_API_KEY | grep -E "^sk-proj-"
    
    # Test API connectivity
    curl -H "Authorization: Bearer $OPENAI_API_KEY" https://api.openai.com/v1/models
    
  2. Local Model Issues

    # Check Ollama status
    ollama list
    ollama ps
    
    # Test model availability
    curl http://localhost:11434/api/generate -d '{"model":"mistral:latest","prompt":"test"}'
    
  3. Performance Issues

    # Monitor resource usage
    amalthea --provider openai --model gpt-4o-mini --file large-api.json --verbose
    
    # Use smaller models for large APIs
    amalthea --provider openai --model gpt-3.5-turbo --file large-api.json --max-tokens 1024
    

Debug Mode

# Enable detailed logging
export RUST_LOG=debug
amalthea --provider openai --model gpt-4o-mini --file api.json --verbose

# Save debug output
amalthea --provider openai --model gpt-4o-mini --file api.json --debug > debug.log 2>&1

๏ฟฝ CLI Reference

Complete Command Line Options

USAGE:
    amalthea [OPTIONS] --file <FILE>

OPTIONS:
    -f, --file <FILE>                    Input file (OpenAPI spec or Postman collection)
    -m, --model <MODEL>                  AI model to use [default: gpt-4o-mini]
    -p, --provider <PROVIDER>            AI provider (openai, anthropic, google, local, universal)
        --api-key <API_KEY>              API key for the AI provider
        --base-url <BASE_URL>            Base URL for API requests (for local models)
        --temperature <TEMPERATURE>      Temperature for AI responses (0.0-1.0) [default: 0.7]
        --max-tokens <MAX_TOKENS>        Maximum tokens in response [default: 4096]
        --timeout <TIMEOUT>              Request timeout in seconds [default: 30]
        --retries <RETRIES>              Number of retries for failed requests [default: 3]
    -o, --output <OUTPUT>                Output file for test results
        --kb <KB_FILE>                   Knowledge base file path for realistic test data generation
        --generate-only                  Generate test cases only (skip execution)
        --security                       Enable security vulnerability testing
        --ai-security-scan               Enable AI-powered security vulnerability scanning
        --ai-scan-intensity <LEVEL>      AI security scan intensity level (1-5, default: 3)
        --ai-scan-focus <TYPES>          Focus AI security scan on specific vulnerability types
        --ai-scan-confidence <THRESHOLD> AI security scan confidence threshold (0.0-1.0, default: 0.3)
        --json-output                    Output JSON report
        --generate-tests                 Generate tests mode - create test cases
        --fuzz                           Enable fuzzing mode - generate random/malicious test data
        --fuzz-intensity <LEVEL>         Fuzzing intensity level (1-5, default: 3)
        --scenarios <SCENARIOS>          Test scenario type (ecommerce, banking, realtime, etc.)
        --test-count <COUNT>             Number of test cases to generate per endpoint [default: 12]
        --parallel <PARALLEL>            Number of parallel requests [default: 5]
        --cache                          Enable response caching
        --cache-ttl <TTL>                Cache TTL in seconds [default: 3600]
        --template <TEMPLATE>            Custom prompt template file
        --config <CONFIG>                Configuration file path [default: .amalthea.toml]
        --verbose                        Enable verbose output
        --debug                          Enable debug mode
        --no-color                       Disable colored output
        --format <FORMAT>                Output format (json, yaml, xml, html) [default: json]
        --html-report                    Generate HTML report with visual charts and statistics
        --report-title <TITLE>           Custom title for HTML report [default: "API Test Report"]
    -h, --help                           Print help information
    -V, --version                        Print version information

EXAMPLES:
    # Basic usage
    amalthea --provider openai --model gpt-4o-mini --file api.json
    
    # With AI-powered security scanning
    amalthea --provider openai --model gpt-4o-mini --file api.json --ai-security-scan
    
    # AI security with custom intensity and focus
    amalthea --provider openai --model gpt-4o-mini --file api.json --ai-security-scan --ai-scan-intensity 5 --ai-scan-focus "sql,xss,auth"
    
    # With traditional security testing
    amalthea --provider openai --model gpt-4o-mini --file api.json --security
    
    # With knowledge base for realistic test data
    amalthea --provider openai --model gpt-4o-mini --file api.json --kb knowledge-base.json
    
    # Knowledge base + security testing + HTML report
    amalthea --provider openai --model gpt-4o-mini --file api.json --kb knowledge-base.json --security --html-report
    
    # Custom configuration
    amalthea --provider openai --model gpt-4o-mini --file api.json --test-count 15 --temperature 0.5
    
    # Local model with custom settings
    amalthea --provider local --model mistral:latest --base-url http://localhost:11434 --file api.json
    
    # Generate only with custom template
    amalthea --provider openai --model gpt-4o-mini --file api.json --generate-only --template custom.txt
    
    # Generate HTML report with visual charts
    amalthea --provider openai --model gpt-4o-mini --file api.json --format html --output report.html
    
    # Custom HTML report with title and security testing
    amalthea --provider openai --model gpt-4o-mini --file api.json --security --html-report --report-title "My API Security Report" --output security-report.html
    
    # Enable fuzzing for comprehensive security testing
    amalthea --provider openai --model gpt-4o-mini --file api.json --fuzz --security
    
    # Fuzzing with custom intensity and knowledge base
    amalthea --provider openai --model gpt-4o-mini --file api.json --fuzz --fuzz-intensity 5 --kb knowledge-base.json
    
    # Light fuzzing for development/CI pipelines
    amalthea --provider openai --model gpt-4o-mini --file api.json --fuzz --fuzz-intensity 1 --generate-only
    
    # Security-only testing
    amalthea --provider openai --model gpt-4o-mini --file api.json --security --generate-only

Environment Variables Reference

# AI Provider Configuration
OPENAI_API_KEY              # OpenAI API key
ANTHROPIC_API_KEY           # Anthropic Claude API key  
GOOGLE_API_KEY              # Google Gemini API key
AZURE_OPENAI_ENDPOINT       # Azure OpenAI endpoint
AZURE_OPENAI_API_KEY        # Azure OpenAI API key
AZURE_OPENAI_API_VERSION    # Azure OpenAI API version
OLLAMA_HOST                 # Ollama host URL

# Application Configuration
AMALTHEA_LOG_LEVEL          # Log level (error, warn, info, debug, trace)
AMALTHEA_OUTPUT_FORMAT      # Default output format (json, yaml, xml)
AMALTHEA_CACHE_DIR          # Cache directory path
AMALTHEA_MAX_PARALLEL       # Maximum parallel requests
AMALTHEA_ENABLE_CACHE       # Enable caching (true/false)
AMALTHEA_CACHE_TTL          # Cache TTL in seconds

# Testing Configuration  
DEFAULT_TIMEOUT             # Default request timeout
DEFAULT_RETRIES             # Default retry count
DEFAULT_TEMPERATURE         # Default AI temperature
DEFAULT_MAX_TOKENS          # Default max tokens
DEFAULT_TEST_COUNT          # Default test cases per endpoint

# Debug and Development
RUST_LOG                    # Rust logging configuration
RUST_BACKTRACE              # Enable Rust backtraces (1, full)

๏ฟฝ HTML Reports & Visualization

Beautiful HTML Reports

Amalthea generates stunning HTML reports with interactive charts and comprehensive test results:

# Generate HTML report with all features
amalthea --provider openai --model gpt-4o-mini --file api.json --security --format html --output report.html

# Custom HTML report with title
amalthea --provider openai --model gpt-4o-mini --file api.json --html-report --report-title "E-commerce API Test Report" --output ecommerce-report.html

# Security-focused HTML report
amalthea --provider openai --model gpt-4o-mini --file api.json --security --html-report --report-title "Security Vulnerability Assessment" --output security-report.html

HTML Report Features

๐Ÿ“ˆ Interactive Dashboard

  • Real-time Charts - Pass/fail rates, response times, error distributions
  • Test Coverage Matrix - Visual endpoint coverage with color-coded status
  • Security Risk Dashboard - Vulnerability severity breakdown with recommendations
  • Performance Metrics - Response time histograms and latency analysis

๐ŸŽจ Visual Elements

<!-- Example HTML Report Structure -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Amalthea API Test Report - {report_title}</title>
    <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body class="bg-gray-50">
    <!-- Header with Logo and Summary -->
    <header class="bg-blue-600 text-white p-6">
        <div class="flex items-center justify-between">
            <div class="flex items-center">
                <img src="https://amalthea.cloud/amalthea.png" alt="Amalthea" class="w-12 h-12 mr-4">
                <h1 class="text-3xl font-bold">{report_title}</h1>
            </div>
            <div class="text-right">
                <p class="text-sm">Generated: {current_date}</p>
                <p class="text-sm">Provider: {ai_provider} ({model})</p>
            </div>
        </div>
    </header>

    <!-- Executive Summary Cards -->
    <section class="p-6 grid grid-cols-1 md:grid-cols-4 gap-6">
        <div class="bg-white rounded-lg shadow p-6 text-center">
            <h3 class="text-lg font-semibold text-gray-600">Total Tests</h3>
            <p class="text-4xl font-bold text-blue-600">{total_tests}</p>
        </div>
        <div class="bg-white rounded-lg shadow p-6 text-center">
            <h3 class="text-lg font-semibold text-gray-600">Success Rate</h3>
            <p class="text-4xl font-bold text-green-600">{success_rate}%</p>
        </div>
        <div class="bg-white rounded-lg shadow p-6 text-center">
            <h3 class="text-lg font-semibold text-gray-600">Security Issues</h3>
            <p class="text-4xl font-bold text-red-600">{security_issues}</p>
        </div>
        <div class="bg-white rounded-lg shadow p-6 text-center">
            <h3 class="text-lg font-semibold text-gray-600">Avg Response</h3>
            <p class="text-4xl font-bold text-purple-600">{avg_response}ms</p>
        </div>
    </section>

    <!-- Interactive Charts Section -->
    <section class="p-6 grid grid-cols-1 lg:grid-cols-2 gap-6">
        <!-- Test Results Pie Chart -->
        <div class="bg-white rounded-lg shadow p-6">
            <h3 class="text-xl font-semibold mb-4">Test Results Distribution</h3>
            <canvas id="testResultsChart"></canvas>
        </div>
        
        <!-- Security Vulnerability Radar -->
        <div class="bg-white rounded-lg shadow p-6">
            <h3 class="text-xl font-semibold mb-4">Security Risk Assessment</h3>
            <canvas id="securityRadarChart"></canvas>
        </div>
        
        <!-- Response Time Timeline -->
        <div class="bg-white rounded-lg shadow p-6 lg:col-span-2">
            <h3 class="text-xl font-semibold mb-4">Response Time Analysis</h3>
            <canvas id="responseTimeChart"></canvas>
        </div>
    </section>
</body>
</html>

๐Ÿ“‹ Detailed Test Results

  • Endpoint Coverage Table - Complete list with status, method, response codes
  • Test Case Details - Expandable sections with request/response data
  • Error Analysis - Categorized failures with troubleshooting suggestions
  • Performance Insights - Slowest endpoints and optimization recommendations

๐Ÿ›ก๏ธ Security Report Section

<!-- Security Vulnerability Dashboard -->
<section class="p-6">
    <h2 class="text-2xl font-bold mb-6 text-red-600">๐Ÿ›ก๏ธ Security Assessment</h2>
    
    <!-- Severity Level Cards -->
    <div class="grid grid-cols-1 md:grid-cols-4 gap-4 mb-8">
        <div class="bg-red-100 border-l-4 border-red-500 p-4">
            <h4 class="font-semibold text-red-700">Critical</h4>
            <p class="text-3xl font-bold text-red-600">{critical_count}</p>
        </div>
        <div class="bg-orange-100 border-l-4 border-orange-500 p-4">
            <h4 class="font-semibold text-orange-700">High</h4>
            <p class="text-3xl font-bold text-orange-600">{high_count}</p>
        </div>
        <div class="bg-yellow-100 border-l-4 border-yellow-500 p-4">
            <h4 class="font-semibold text-yellow-700">Medium</h4>
            <p class="text-3xl font-bold text-yellow-600">{medium_count}</p>
        </div>
        <div class="bg-blue-100 border-l-4 border-blue-500 p-4">
            <h4 class="font-semibold text-blue-700">Low</h4>
            <p class="text-3xl font-bold text-blue-600">{low_count}</p>
        </div>
    </div>
    
    <!-- Detailed Vulnerability List -->
    <div class="space-y-4">
        <!-- SQL Injection Example -->
        <div class="bg-white rounded-lg shadow p-6 border-l-4 border-red-500">
            <div class="flex justify-between items-start">
                <div>
                    <h4 class="text-lg font-semibold text-red-700">๐Ÿ” SQL Injection Vulnerability</h4>
                    <p class="text-gray-600">Endpoint: /api/v1/users/{id}</p>
                    <p class="text-sm text-gray-500">Detected: {timestamp}</p>
                </div>
                <span class="bg-red-100 text-red-800 px-3 py-1 rounded-full text-sm font-medium">CRITICAL</span>
            </div>
            <div class="mt-4">
                <p class="text-gray-700"><strong>Details:</strong> SQL error detected with payload: ' OR '1'='1</p>
                <p class="text-gray-700"><strong>Risk:</strong> Potential data breach and unauthorized access</p>
                <p class="text-gray-700"><strong>Recommendation:</strong> Use parameterized queries and input validation</p>
            </div>
        </div>
    </div>
</section>

Interactive Features

๐ŸŽฏ Clickable Elements

  • Test Case Expansion - Click to view full request/response details
  • Filter by Status - Show only passed, failed, or security tests
  • Sort by Performance - Order endpoints by response time
  • Search Functionality - Find specific endpoints or test cases

๐Ÿ“ฑ Responsive Design

  • Mobile-Friendly - Optimized for phones and tablets
  • Print-Ready - Clean printing layout without interactive elements
  • Dark Mode Support - Toggle between light and dark themes
  • Export Options - Save charts as images or PDF

Advanced HTML Report Options

# Comprehensive report with all features
amalthea --provider openai --model gpt-4o-mini --file api.json \
  --security \
  --html-report \
  --report-title "Production API Security Audit" \
  --format html \
  --output comprehensive-report.html \
  --include-charts \
  --include-timeline \
  --dark-mode

# Performance-focused report
amalthea --provider openai --model gpt-4o-mini --file api.json \
  --html-report \
  --report-title "API Performance Analysis" \
  --format html \
  --output performance-report.html \
  --include-performance-metrics \
  --response-time-threshold 200

# Executive summary report (minimal details)
amalthea --provider openai --model gpt-4o-mini --file api.json \
  --security \
  --html-report \
  --report-title "Executive API Status Report" \
  --format html \
  --output executive-summary.html \
  --summary-only \
  --hide-technical-details

Report Customization

๐ŸŽจ Branding Options

# Custom branding and colors
amalthea --provider openai --model gpt-4o-mini --file api.json \
  --html-report \
  --report-title "Company API Testing Report" \
  --format html \
  --output branded-report.html \
  --logo "https://company.com/logo.png" \
  --primary-color "#1e40af" \
  --company-name "Your Company Name"

๐Ÿ“Š Chart Customization

  • Chart Types: Pie, bar, line, radar, doughnut charts
  • Color Schemes: Professional, colorful, monochrome themes
  • Data Visualization: Response times, success rates, security scores
  • Interactive Tooltips: Hover for detailed information

Sample HTML Report Output

When you run Amalthea with HTML output, you'll get a beautiful report like this:

๐Ÿ“Š Generated HTML Report: report.html
   
   ๐Ÿ“ˆ Dashboard Overview:
   โ”œโ”€โ”€ ๐Ÿงช Total Tests: 156
   โ”œโ”€โ”€ โœ… Success Rate: 87.2%
   โ”œโ”€โ”€ ๐Ÿ›ก๏ธ Security Issues: 3 Critical, 5 High
   โ””โ”€โ”€ โšก Avg Response: 245ms
   
   ๐Ÿ“‹ Detailed Sections:
   โ”œโ”€โ”€ ๐Ÿ“Š Interactive Charts (4 visualizations)
   โ”œโ”€โ”€ ๐Ÿ“‹ Test Results Table (12 endpoints)
   โ”œโ”€โ”€ ๐Ÿ›ก๏ธ Security Assessment (8 vulnerability types)
   โ”œโ”€โ”€ โšก Performance Analysis (response time breakdown)
   โ””โ”€โ”€ ๐Ÿ“„ Executive Summary (key findings)
   
   ๐ŸŒ Open in browser: file://./report.html

๏ฟฝ๐Ÿณ Advanced Docker Usage

Production Docker Setup

# Production-ready container with all features including AI security
docker run --rm \
  --name amalthea-testing \
  -e OPENAI_API_KEY="$OPENAI_API_KEY" \
  -e ANTHROPIC_API_KEY="$ANTHROPIC_API_KEY" \
  -e GOOGLE_API_KEY="$GOOGLE_API_KEY" \
  -v $(pwd)/apis:/data \
  -v $(pwd)/results:/results \
  -v $(pwd)/config:/config \
  ksdco/amalthea:0.5.0 \
  --provider universal --model gpt-4o-mini \
  --file /data/api.json \
  --ai-security-scan \
  --ai-scan-intensity 4 \
  --security \
  --config /config/.amalthea.toml \
  --output /results/test-results.json

# Multi-provider testing with Docker Compose
cat > docker-compose.yml << 'EOF'
version: '3.8'

services:
  amalthea-openai:
    image: ksdco/amalthea:0.5.0
    environment:
      - OPENAI_API_KEY=${OPENAI_API_KEY}
    volumes:
      - ./apis:/data
      - ./results:/results
    command: >
      --provider openai --model gpt-4o-mini 
      --file /data/api.json 
      --ai-security-scan --ai-scan-intensity 4
      --security 
      --auth-type bearer --auth-token "${API_TOKEN}"
      --output /results/openai-results.json

  amalthea-claude:
    image: ksdco/amalthea:0.5.0
    environment:
      - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
    volumes:
      - ./apis:/data
      - ./results:/results
    command: >
      --provider anthropic --model claude-3-haiku 
      --file /data/api.json --security 
      --auth-type jwt --auth-token "${JWT_TOKEN}"
      --output /results/claude-results.json

  amalthea-local:
    image: ksdco/amalthea:0.3.0
    network_mode: host
    volumes:
      - ./apis:/data
      - ./results:/results
    command: >
      --provider local --model mistral:latest 
      --base-url http://localhost:11434
      --file /data/api.json --security 
      --output /results/local-results.json
    depends_on:
      - ollama

  ollama:
    image: ollama/ollama:latest
    ports:
      - "11434:11434"
    volumes:
      - ollama_data:/root/.ollama
    command: serve

volumes:
  ollama_data:
EOF

# Run multi-provider testing
docker-compose up --abort-on-container-exit

Kubernetes Deployment

# k8s/amalthea-job.yaml
apiVersion: batch/v1
kind: Job
metadata:
  name: api-testing-job
spec:
  template:
    spec:
      containers:
      - name: amalthea
        image: ksdco/amalthea:0.2.3
        command: ["/usr/local/bin/amalthea"]
        args:
          - --provider
          - openai
          - --model
          - gpt-4o-mini
          - --file
          - /data/api.json
          - --security
          - --output
          - /results/test-results.json
        env:
        - name: OPENAI_API_KEY
          valueFrom:
            secretKeyRef:
              name: ai-keys
              key: openai-key
        volumeMounts:
        - name: api-specs
          mountPath: /data
        - name: results
          mountPath: /results
      volumes:
      - name: api-specs
        configMap:
          name: api-specifications
      - name: results
        persistentVolumeClaim:
          claimName: test-results-pvc
      restartPolicy: Never
  backoffLimit: 3

---
apiVersion: v1
kind: Secret
metadata:
  name: ai-keys
type: Opaque
data:
  openai-key: <base64-encoded-openai-key>
  anthropic-key: <base64-encoded-anthropic-key>
  google-key: <base64-encoded-google-key>

Custom Docker Images

# Dockerfile.custom - Custom image with additional tools
FROM ksdco/amalthea:0.3.0

USER root

# Install additional testing tools
RUN apt-get update && apt-get install -y \
    jq \
    curl \
    git \
    python3 \
    python3-pip \
    && rm -rf /var/lib/apt/lists/*

# Install Python tools for result processing
RUN pip3 install \
    requests \
    jsonschema \
    pyyaml \
    tabulate

# Add custom scripts
COPY scripts/ /usr/local/scripts/
RUN chmod +x /usr/local/scripts/*.sh

# Custom entrypoint with pre/post processing
COPY <<EOF /usr/local/bin/custom-entrypoint.sh
#!/bin/bash
set -e

echo "๐Ÿš€ Starting Custom API Testing Pipeline"

# Pre-processing
/usr/local/scripts/preprocess.sh

# Main testing
amalthea "$@"

# Post-processing
/usr/local/scripts/postprocess.sh

echo "โœ… Testing pipeline completed!"
EOF

RUN chmod +x /usr/local/bin/custom-entrypoint.sh

ENTRYPOINT ["/usr/local/bin/custom-entrypoint.sh"]

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guide for details.

Quick Contribution Steps

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐ŸŒŸ Support


Built with โค๏ธ by KSD.CO using Rust ๐Ÿฆ€

Dependencies

~18โ€“49MB
~703K SLoC