This directory contains the MongoDB integration for the Web Security Analysis Dashboard.
database/
├── models/ # Mongoose models
│ ├── Repository.js
│ ├── Analysis.js
│ └── Alert.js
├── config/ # Configuration files
│ └── connection.js
├── scripts/ # Data ingestion and utility scripts
│ ├── ingest-data.js
│ └── test-connection.js
└── package.json
cd database
npm install- Create a MongoDB Atlas account at https://www.mongodb.com/cloud/atlas
- Create a new cluster
- Configure network access (add your IP address or 0.0.0.0/0 for development)
- Create a database user
- Get your connection string
Copy .env.example to .env and fill in your MongoDB connection string:
cp .env.example .envEdit .env:
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/web-security-db?retryWrites=true&w=majority
GITHUB_TOKEN=your_github_token_here
GITHUB_ORG=Web-Security-Repos
node scripts/test-connection.jsFor detailed schema documentation, see SCHEMA.md.
- Stores repository metadata
- Links to analyses and alerts
- Tracks vulnerability types
- Stores CodeQL analysis results
- Links to repository
- Can store full SARIF data
- Stores individual security alerts
- Links to analysis and repository
- Tracks severity, state, and location
node scripts/ingest-data.jsThis script will:
- Fetch all repositories from the organization
- Fetch CodeQL analyses for each repository
- Store repository metadata
- Store analysis results
- Store individual alerts
Migration:
node scripts/migrate.jsUpdates database schema and indexes.
Cleanup (remove old data):
# Dry run (see what would be deleted)
node scripts/cleanup.js --days=90 --dry-run
# Actually delete analyses older than 90 days
node scripts/cleanup.js --days=90Backup:
# Backup to default ./backups directory
node scripts/backup.js
# Backup to custom directory
node scripts/backup.js /path/to/backupImportant: The dashboard doesn't run CodeQL scans - it fetches results from GitHub. CodeQL scans are run by GitHub Actions workflows in each repository.
To fetch latest scan results:
node scripts/ingest-data.jsTo trigger CodeQL workflows on GitHub:
# Trigger for a specific repository
node scripts/trigger-scan.js test-xss-nodejs
# Trigger for all repositories
node scripts/trigger-scan.js --allFor more details, see scripts/SCANNING.md.
name: Repository namefull_name: Full repository name (owner/repo)vulnerability_type: Type of vulnerability testedcodeql_enabled: Whether CodeQL is enabled
analysis_id: GitHub analysis IDrepository: Reference to Repositorycommit_sha: Commit SHA analyzedresults_count: Number of alerts foundsarif_data: Full SARIF report (optional)
alert_number: GitHub alert numberanalysis: Reference to Analysisrepository: Reference to Repositoryrule_id: CodeQL rule IDseverity: Alert severitysecurity_severity: Security severity levellocation: File path and line numbers