VScanX includes automated testing and continuous integration (CI) to verify code quality and report generation.
The project includes .github/workflows/ci.yml which:
- Runs on push and PRs to the
mainbranch - Installs dependencies including Python 3.11 and
requirements.txt - Runs unit tests (
pytest) to verify core functionality - Starts the vulnerable test server locally (
vulnerable_server.py) - Executes a smoke scan via CLI against the test server
- Verifies all report formats are produced (HTML, PDF, JSON, CSV, TXT)
- Uploads the
reports/directory as a workflow artifact for inspection
# Install test dependencies
pip install pytest reportlab
# Run all unit tests
pytest -q
# Run specific test module
pytest tests/test_report_exports.py -q
# Run specific test
pytest tests/test_integration_smoke.py::test_end_to_end_smoke -q -sThe integration test (tests/test_integration_smoke.py::test_end_to_end_smoke) is the end-to-end validation:
# Runs in isolation:
# 1. Starts vulnerable_server.py on http://127.0.0.1:8080
# 2. Executes VScanX CLI against the test server
# 3. Verifies reports (HTML, JSON, CSV, TXT) are generated
# 4. Cleans up server process and generated reports
pytest tests/test_integration_smoke.py::test_end_to_end_smoke -q -sYou can run the CLI directly against the local test server:
# Terminal 1: Start the test server
python vulnerable_server.py
# Terminal 2: Run VScanX
python vscanx.py -t "http://127.0.0.1:8080/search?q=test" -s web --skip-warning --format html,json,csv,txtThis creates reports/vscanx_127.0.0.1_web_*.{html,json,csv,txt}.
| Test | Coverage | Validates |
|---|---|---|
test_report_exports.py |
Report generation | HTML/JSON/CSV/TXT files created with correct metadata |
test_validate_mismatch() |
Sanity check | Catches summary/findings mismatch (fail-fast) |
test_orchestrator_summary_consistency() |
Orchestrator | Central ScanResult model consistency |
test_end_to_end_smoke |
Full pipeline | Server startup → CLI scan → all formats → cleanup |
When a GitHub Actions workflow runs:
- If all tests pass, the
reports/directory is uploaded asvscanx-ci-reportsartifact - Artifacts are available for 90 days (GitHub default)
- Download to inspect sample HTML report, JSON schema, CSV findings, etc.
Issue: UnicodeEncodeError on Windows console
Cause: CLI prints unicode characters (box-drawing, emoji) in cp1252 console
Fix: CLI now uses ASCII-safe banners; if you see errors, set PYTHONIOENCODING=utf-8
set PYTHONIOENCODING=utf-8
python vscanx.py -t http://127.0.0.1:8080/search?q=test -s web --skip-warningIssue: TimeoutError in integration test
Cause: Server takes too long to start or ports are in use
Fix: Ensure port 8080 is free and increase timeout in test_integration_smoke.py if needed
Issue: OSError: Address already in use
Cause: Leftover process from previous test run
Fix: Kill stray processes: lsof -ti :8080 | xargs kill -9 (Linux/Mac) or netstat -ano on Windows
- Code coverage: Add
pytest-covand enforce minimum coverage thresholds - Linting: Add
pylintorflake8to CI - Security scanning: Add
banditto check for vulnerable patterns - Performance testing: Benchmark scan times to catch regressions
- Docker CI: Build and test in containerized environment for consistency
The test suite validates the ScanResult and Finding dataclass contracts:
ScanResult.findingsis always populated whensummary.total_findings > 0- Each
Findinghas required fields:module,severity,description - JSON export schema matches the internal model structure
See core/scan_model.py for the dataclass definitions.