Demo Data Generation
This guide explains how to generate demonstration data for testing and development purposes.
Overview
The generate_demo_data.py script creates realistic test data based on a University/Faculty theme, including:
Users: Admin and regular users (Profs, Students, IT Support)
LDAP Users: Demo directory users in the local development LDAP server, when available
Contact Persons: Departments and individuals with IP and CIDR assignments
Hosts: Servers with rich metadata (OS, Hostnames)
Scans: Vulnerability reports (XML, PDF, HTML) with linked products, locations, and sources.
Institution Ownership: Findings are assigned through the configured institution IP mappings, just like real imported reports.
Linked Reports: Scenarios where XML, PDF, and HTML reports share the same report ID/filename.
Master XML Matches: Matched, pending, and ambiguous per-host visual reports for the filename-pattern matching workflow, including disputes for visual reports that still need XML/host assignment.
Trend Data: Historical scan data generated daily for the last 30 days
Access Logs: Simulated usage history
Prerequisites
The script must be run inside the Docker backend container to access the database.
To also seed LDAP users, start the stack with the Docker Compose dev profile
so the local LDAP server is available:
docker compose --profile dev up -d
The development LDAP server is reachable from containers at ldap://ldap:389
and from the host at ldap://localhost:1389. Its default bind credentials are
cn=admin,dc=example,dc=org / admin.
Running the Script
Basic Usage
docker exec vulnerability-scanner-backend-1 python /app/generate_demo_data.py
First-Time Setup
If the script is not yet in the container (e.g. if you modified it locally), copy it first:
docker cp src/backend/generate_demo_data.py vulnerability-scanner-backend-1:/app/
docker exec vulnerability-scanner-backend-1 python /app/generate_demo_data.py
Generated Data
Users
The script creates the following demo users.
Default Password: DemoPass123456!
Username |
Full Name |
Role |
|
|---|---|---|---|
prof_mueller |
Prof. Dr. Thomas Müller |
Admin |
|
dr_schmidt |
Dr. Anna Schmidt |
User |
|
stud_weber |
Maximilian Weber |
User |
|
admin_fischer |
Klaus Fischer |
Admin |
|
user_bib |
Bibliothek EDV |
User |
|
user_rz |
IT Support RZ |
Admin |
LDAP Users
When the local dev LDAP server is reachable, the script creates an
ou=users,dc=example,dc=org organizational unit, seeds the following LDAP
users, and stores an enabled Demo LDAP Directory connection in the
application:
Default LDAP Password: DemoPass123456!
Username |
Full Name |
|
|---|---|---|
ldap_informatik_admin |
LDAP Informatik Administration |
|
ldap_physik_ops |
LDAP Physik Operations |
|
ldap_rz_security |
LDAP RZ Security |
|
ldap_bibliothek |
LDAP Bibliothek Support |
|
ldap_student_helpdesk |
LDAP Student Helpdesk |
|
ldap_guest_network |
LDAP Guest Network Owner |
If LDAP is not running, the script skips only the LDAP seeding step and continues creating the regular database demo data.
Contact Persons
Contact persons are created to demonstrate IP and CIDR ownership:
Prof. Dr. Thomas Müller - IPs:
192.0.2.10,192.0.2.11, …IT Rechenzentrum - CIDR:
192.0.2.0/24,198.51.100.0/24,203.0.113.0/24(Network Wide)Fakultät Informatik - IPs:
203.0.113.1,203.0.113.2- CIDR:203.0.113.0/24Bibliothek - IPs:
198.51.100.40
Hosts & Metadata
Hosts are enriched with realistic metadata:
Hostname: e.g.,
webserver01.informatik.uni.eduOS: e.g.,
Ubuntu 22.04 LTS,Debian 11,Windows Server 2019
Linked Data:
- Products: OpenSSH 8.2p1, Apache/2.4.41, etc.
- Locations: tcp/80, tcp/443, etc.
- Sources: NVT Feed, CVE Feed
Historical Trend Data
To populate the Vulnerability Trend dashboard, the script generates:
Daily Scans: For the last 30 days
Target:
Fakultät für Informatik(webserver01)Varying Severity: Random mix of High/Medium/Low vulnerabilities to show trend lines.
Scan Scenarios
Specific scenarios are created to test logic:
Unaccessed Report: A report created 1 day ago that has never been opened (testing notifications).
Linked Reports: A full set (XML, PDF, HTML) for
Rechenzentrumto test UI grouping.Orphan Reports: Standalone PDF or HTML files (e.g.
Legacy_Scan_2023.pdf) to test individual file handling.Fallback Institution: A report for an IP (
192.0.2.199) that is not mapped to any institution, so the configurable fallback institution is used.Legacy Scan: Old scan from >30 days ago.
Resetting Demo Data
The script is idempotent for inserts (skips existing IDs/Emails), but for a clean slate:
# Stop containers
docker compose down -v
# Restart
docker compose --profile dev up -d
# Re-run script
docker exec vulnerability-scanner-backend-1 python /app/generate_demo_data.py
Troubleshooting
UnboundLocalError: If you see an error about vuln_objs, ensure you are using the latest version of the script where vulnerability creation is ordered before the trend data loop.