How oktaliem/websecurityscanningsample works
Project Type and Purpose
• This is a Java-based test-automation project (Maven) that integrates with OWASP ZAP to perform automated security scanning (active and passive) against an external web application (DVWA running in Docker).
• Its main goal is to demonstrate a ZAP scanning lifecycle (Spider → AJAX Spider → Active/Passive Scan → Alerts → HTML Report) via Java code (SecurityTest & SecurityScanner).
File Structure Analysis
• Top-level files:
• pom.xml – Maven config, dependencies (ZAP API, JUnit).
• README.md – usage and workflows.
• .gitignore – standard ignores.
• src/main/resources/auth-dvwa.js – ZAP authentication script for DVWA.
• src/test/java/com/oktaliem/
• SecurityScanner.java – wrapper around ZAP API calls (spider, AJAX spider, scans, report generation).
• SecurityTest.java – JUnit tests driving different scan workflows (with/without auth, active/passive).
Key Insights from README
• Explains two scanning workflows (active vs. passive, auth vs. no-auth).
• Precondition: DVWA must be running in Docker on localhost:3000 and ZAP must be up.
• Test commands: mvn clean test -Dtest=SecurityTest#…
Main Components
a. Test Runner (Maven CLI/JUnit)
b. Java Test Code
– SecurityTest (test cases)
– SecurityScanner (ZAP API client)
– auth-dvwa.js (ZAP script)
c. OWASP ZAP Proxy Server
d. Application Under Test (DVWA in Docker)
e. Reports (HTML output)
Relationships & Data Flow
1. Developer invokes Maven CLI →
2. JUnit launches SecurityTest →
3. SecurityScanner uses ZAP Java API to:
• Load auth-dvwa.js into ZAP (for authenticated workflows)
• Configure target to http://localhost:3000
• Run Spider → AJAX Spider → Active/Passive Scan
4. ZAP proxies all HTTP requests to DVWA container → collects alerts
5. ZAP generates HTML report → saved to the local file system
Architectural Patterns & Principles
• Proxy pattern: ZAP intercepts traffic between test code and DVWA.
• Test automation: separation of test definitions (SecurityTest) and scanning logic (SecurityScanner).
• Configuration as code: auth-dvwa.js externalizes login steps.
• Maven-driven lifecycle: build/test phases integrate scanning.
Essential Elements to Capture
• Authentication script injection before scanning.
• Two scan modes and how they plug into the same pipeline.
• Storage/location of the generated HTML report.
• Sequence of interactions (spider → AJAX → active/passive scan).