- Git History: Removed sensitive files from repository history
- Used
git-filter-repoto rewrite history and eliminate sensitive data exposure
- Used
.gitignore: Enhanced to prevent committing sensitive configuration files- Deduplicated entries and organized into logical sections
- Added patterns to exclude sensitive mapping files:
config/test_mapping.json,config/*_mapping.json - Added patterns to exclude archive files:
config/*.zip - Consolidated Python, testing, and environment-specific ignores
- Ensured
config/auth.json,config/*.local.json, andconfig/private/are properly excluded
- Logging: Fixed KeyError when logging script arguments in
log_script_start()function- Changed
argsparameter toscript_argsto avoid conflict with Python's LogRecord.args attribute - Resolves "Attempt to overwrite 'args' in LogRecord" error when running scripts with logging
- All scripts now start successfully without logging errors
fetch_specs_with_auth.py: Made OAuth configuration platform-agnostic and environment-driven- Replaced
--tenant-token-urlwith--oauth-token-urlfor clarity - Added
OAUTH_TOKEN_URLenvironment variable support for any OAuth 2.0 provider - Removed Microsoft-specific defaults and invalid URL fallbacks
- Added validation to ensure OAuth token URL is configured when needed
- Replaced
batch_fetch_register_scan.py: Added OAuth token URL support for batch workflows- Added
--oauth-token-urlparameter to pass through tofetch_specs_with_auth.py - Updated usage examples to show OAuth environment variable and CLI usage
- Enables complete batch automation with OAuth-protected APIs
- Added
- Documentation: Updated chaining recipes with new OAuth authentication patterns
- Added OAuth setup section showing
OAUTH_TOKEN_URLenvironment variable usage - Updated config examples to remove deprecated
tokenUrlfield - Added Python batch automation section with OAuth examples
- Added OAuth setup section showing
- Updated integration tests to reflect new parameter names and behavior
- Changed
- Integration Tests: Fixed 14 failing integration tests to properly validate coded integration contracts
fetch_specs_with_auth.py: Added missing--debugargument and updated test expectations to match resilient script behaviorregister_app_with_host_and_spec.py: Fixed output directory security guard issues in tests- All 220 integration tests now passing ✅
- CONTRIBUTING.md: Fixed broken documentation links
- Explained how receipts system works w example
- Validated 100% compliance with architectural standards
- Documented updates including new chaining recipes
- New troubleshooting guide:
docs/Troubleshooting_Git_Pull.md- Documents the Pythonic way to resolve
uv.lockconflicts duringgit pull - Explains why lock file conflicts are normal and expected
- Provides best practices for lock file management
- Includes prevention strategies with pre-commit hooks
- Documents the Pythonic way to resolve
- Added git pull troubleshooting reference to
docs/QUICK_START.md - New validation script:
scripts/validate_chain.py- Validates chaining workflow components without requiring VPN/API access
- Checks that all required scripts exist and are accessible
- Validates receipt file structure and JSON format
- Enables offline validation of fetch → register → scan chain
- New batch automation script:
scripts/examples/batch_fetch_register_scan.py- Complete Python automation for fetch → register → scan workflow
- One-command execution with proper error handling and progress tracking
- Supports
importAPI.jsonconfig files for multiple APIs - Generates audit receipts and machine-readable JSON output
- Replaces shell scripting with robust Python implementation
- Enhanced Makefile: Added comprehensive targets for all workflows
- New batch automation targets:
batch-automation,fetch-specs - Utility targets:
validate-chain,list-instances,delete-app,setup-app - Organized help system with clear sections and examples
- Support for
CONFIG_FILEvariable for batch operations
- New batch automation targets:
Breaking Changes:
- Output location changed from
./tmp/tooutput/directory --debugflag replaced with--verboseflag- Script now outputs JSON envelope to stdout (was integer exit code)
Eight Critical Fixes Applied:
-
Output Directory Pattern ✅
- Changed from hardcoded
./tmp/to properoutput/directory - Uses
ensure_output_dir()fromlib/common.py - Respects
APISEC_OUTPUT_DIRenvironment variable - Added
--output-dirflag for custom locations - Added
--forceflag for security guard bypass
- Changed from hardcoded
-
Receipt Pattern Implementation ✅
- Creates timestamped receipts:
fetch_specs_with_auth-YYYYMMDDTHHMMSSZ.json - Uses
write_receipt()fromlib/common.py - Contains: config file, success/failure counts, fetched spec metadata
- Enables audit trail and batch processing validation
- Creates timestamped receipts:
-
JSON Envelope Output ✅
- Outputs
ok_json()envelope to stdout (machine-parseable) - Proper
err_json()for all error conditions - Includes: successes, failures, total, fetched_specs, output_dir, receipt_file
- Enables pipeline chaining with jq and other tools
- Outputs
-
Enhanced Error Handling ✅
- Config file not found → actionable
err_json()with file path - Invalid JSON → parse error details with suggestions
- No API entries → validation error with configuration guidance
- All errors include: code, message, why, suggestion, exit_code
- Config file not found → actionable
-
Security Logging ✅
- All API keys sanitized before logging via
sanitize_token() - Client secrets sanitized in OAuth flows
- Access tokens sanitized after acquisition
- Uses
log_script_start(),log_script_complete(),log_script_error() - Correlation IDs propagated through all operations
- All API keys sanitized before logging via
-
Integration with Common Library ✅
- Uses
ensure_output_dir()for directory management - Uses
write_receipt()for audit trails - Uses
ok_json()anderr_json()for structured output - Uses
get_env()for environment variable handling - Follows patterns from
register_app_from_spec.py
- Uses
-
Enhanced Spec Tracking ✅
- Tracks metadata: index, URL, auth_type, output_file, name
- Logs file size for each saved spec
- Consistent JSON formatting with indent=2
- All data available in receipt and final output envelope
-
Improved Configuration Loading ✅
- Robust
load_config()with correlation_id tracking - FileNotFoundError → structured error with actionable message
- JSONDecodeError → parse error details with suggestions
- Type validation → specific guidance for fixes
- Robust
Impact:
- Enables batch processing of 6-30+ protected OpenAPI specs
- Creates full audit trail via receipts
- Enables pipeline chaining and automation
- Provides actionable error messages for troubleshooting
- Security team can audit operations without credential exposure
Complete modernization reflecting all improvements:
-
Structure and Organization
- Updated to 2025-10-03 with script metadata
- Clear purpose statement with key features list
- Three-tier output documentation (stdout, stderr, files)
- Added "what this is NOT" section
-
Configuration Section Enhanced
- Detailed authentication type explanations (API Key, OAuth 2.0)
- Example configuration with both apikey and oauth
- Batch processing guidance (6-30+ endpoints)
- Configuration notes with scope patterns
-
Usage Examples Modernized
- Basic usage with
uv run(recommended approach) - Custom OAuth tenant URL examples with MICROSOFT_LOGIN_GUID
- Custom output directory examples
- Verbose logging with LOG_LEVEL environment variable
- Traditional venv activation for backwards compatibility
- Basic usage with
-
Output Documentation Comprehensive
- JSON envelope format with complete example
- Operational logs description with structured logging
- File outputs (specs and receipts) with paths
- Receipt structure documentation
- All three output channels clearly explained
-
Common Outcomes Table
- Structured table format for quick reference
- Status, meaning, and action columns
- All major HTTP status codes covered (200, 400, 401, 403, 500)
- WAF detection guidance
-
Pipeline Chaining Section (NEW)
- Extract fetched spec files with jq examples
- Process specs programmatically with receipt files
- Register specs into APIsec (next step workflow)
- Integration with
register_app_from_spec.py - Demonstrates machine-readable output value
-
Troubleshooting Greatly Enhanced
- WAF/Network issues with curl verification commands
- OAuth authentication failures with detailed solutions
- API key authentication failures with test commands
- Invalid JSON/OpenAPI document diagnostics
- Debug logging with LOG_LEVEL=DEBUG examples
-
FAQ Section Expanded
- Network access requirements clarification
- APIsec integration vs spec fetching distinction
- Batch processing guidance (100+ endpoints)
- Partial failure handling explanation
- Credential storage and security best practices
- Token sanitization guarantees
-
Security Notes Section (NEW)
- Token sanitization guarantees documented
- Credential protection in output explained
- Directory traversal prevention details
- Force flag security implications warning
- .gitignore recommendations for config files
- Enhanced logging with token sanitization throughout all authentication flows
- Support for mixed case authType values ("oauth", "oAuth", "OAuth" all work)
- Redundant config field handling (all auth fields can exist, only relevant ones used)
- Aligned
fetch_specs_with_auth.pywith project architectural patterns:- Standalone by Design ✅
- JSON Envelope Pattern ✅
- Receipt Pattern ✅
- Security by Default ✅
- Separation of Concerns ✅
- Followed all logging standards from
.cursor/rules/logging-standards.mdc - Followed all development standards from
.cursor/rules/development_standards.mdc - Consistent with reference implementation in
register_app_from_spec.py
If you're upgrading from v0.0.2:
- Update output references: Change
./tmp/tooutput/in scripts/docs - Replace
--debugflag: Use--verboseinstead - Update automation: Consume stdout JSON envelope instead of exit codes
- Add environment variables (optional):
export APISEC_OUTPUT_DIR="output" # Default, can customize export LOG_LEVEL="INFO" # or DEBUG for verbose
- Update pipelines: Use jq to extract data from JSON envelope:
# Old way (doesn't work anymore) python scripts/fetch_specs_with_auth.py --config config.json # New way uv run python scripts/fetch_specs_with_auth.py --config config.json | \ jq -r '.data.fetched_specs[].output_file'
- New scripts for spec fetching and authentication:
scripts/fetch_spec.py- Download OpenAPI specs from URLs with authenticationscripts/fetch_specs_with_auth.py- Fetch multiple protected specs
- Authentication configuration examples in
config/auth-examples/:- API Key, Basic Auth, Bearer Login, OAuth2, Custom Headers
- Shared constants module
lib/constants.py - Example manifest
config/example.importAPI.jsonfor batch operations - Sample OpenAPI spec
openapi.json(crAPI) for testing
- Enhanced logging in scripts:
scripts/register_app_with_host_and_spec.py- Added structured loggingscripts/run_scan.py- Added correlation ID trackingscripts/update_app_and_instances.py- Added structured logging
- Security: Removed unnecessary
--forceflag bypasses in internal script callsregister_app_from_spec.py- temp directory already validated by parentrefresh_instance_spec.py- temp directory already validated by parent- Temp directories created inside validated output directory don't need force override
Core features
- Python standalone scripts for APIsec NG:
register_app_from_spec.py: Register an application from OpenAPI (file or URL). Automatically normalizes tokens and records a receipt tooutput/.register_app_with_host_and_spec.py: Register an app and explicitly add an instance using ahost-url.update_app_and_instances.py: Operational utilities:add-instance: Add instance via batch API.show-instance: Fetch instance details.show-app: Fetch application details.
refresh_instance_spec.py: Refresh an application's OpenAPI spec from file or URL.run_scan.py: Trigger a scan for an instance; supports--waitwith timeout and polling.
Dev UX and tooling
- Makefile with convenience targets mirroring the above scripts:
reg-file,reg-url,refresh-file,scan-wait- Defaults are overridable (e.g.,
APP_NAME,SPEC_FILE,SPEC_URL)
- Shell aliases in
scripts/aliases.sh:apisec_reg_file,apisec_reg_url,apisec_refresh_file,apisec_scan_wait- Designed for quick interactive usage; mirror Makefile behavior
uvas the Python runner for reproducible, dependency-light execution
Documentation
- Quick Start (
docs/QUICK_START.md) with bothuv runcommands and Makefile/alias usage README.mdupdated to referencemake helpand aliasesconfig/.exampleenvwith environment variables for easy setup
Enterprise-readiness and quality
- Consistent JSON envelope across all scripts for pipeline-friendly parsing:
- Fields:
script,version,timestamp,request_id,status,data|error
- Fields:
- Actionable error handling via structured JSON responses; non-zero exit codes for CI signaling
- Output receipts written to
output/with timestamped filenames for auditability - Guardrails on filesystem writes to avoid accidental writes outside
examples/python-scriptsunless--forceis provided - Token normalization automatically handles raw tokens and
Bearerprefix - Verbose mode surfaces curl stderr for diagnostics; dry-run where appropriate
- Strong typing where helpful and clear function boundaries in
lib/common.py
CI/CD readiness
- Commands suitable for use in GitHub Actions and other CI runners
- Deterministic CLI surfaces with explicit required flags and sane defaults
Housekeeping
- Valid
CITATION.cff pyproject.tomlcleaned of unsupporteduvfields; addsreadme,license, andauthors