<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->
<!-- NERF is a trademark of defconxt. -->
# Vulnerability Trend Analysis — API Reference

## Tenable.io Analytics API

```bash
# Vulnerability count over time
curl -s "https://cloud.tenable.com/workbenches/vulnerabilities" \
  -H "X-ApiKeys: accessKey=$AK; secretKey=$SK" | \
  jq '[.vulnerabilities[] | .severity] | group_by(.) | map({(.[0] | tostring): length}) | add'

# Asset vulnerability summary
curl -s "https://cloud.tenable.com/workbenches/assets" \
  -H "X-ApiKeys: accessKey=$AK; secretKey=$SK" | \
  jq '.assets[] | {id, fqdn: .fqdn[0], severities: .severities}'

# Export vulnerability data for trending
curl -s -X POST "https://cloud.tenable.com/vulns/export" \
  -H "X-ApiKeys: accessKey=$AK; secretKey=$SK" \
  -H "Content-Type: application/json" \
  -d '{"filters": {"severity": ["critical", "high"]}, "num_assets": 5000}'
```

## Qualys VMDR Reporting API

```bash
# Vulnerability trend data
curl -s "https://qualysapi.qualys.com/api/2.0/fo/report/" \
  -u "$QUALYS_USER:$QUALYS_PASS" \
  -d "action=launch&template_id=TREND_TEMPLATE&report_type=Scan"

# Asset count by vulnerability severity
curl -s "https://qualysapi.qualys.com/api/2.0/fo/asset/host/" \
  -u "$QUALYS_USER:$QUALYS_PASS" \
  -d "action=list&show_asset_id=1"
```

## DefectDojo Metrics API

```bash
# Product-level metrics
curl -s "https://defectdojo.internal/api/v2/metrics/?product_id=1" \
  -H "Authorization: Token $DD_TOKEN"

# Finding counts by severity
curl -s "https://defectdojo.internal/api/v2/findings/?active=true&limit=0" \
  -H "Authorization: Token $DD_TOKEN" | jq '.count'
```

## Key Metrics Formulas

| Metric | Formula | Unit |
|--------|---------|------|
| MTTR | `avg(remediation_date - discovery_date)` | Hours/Days |
| SLA Compliance | `(remediated_within_sla / total_remediated) * 100` | Percentage |
| Vuln Density | `total_vulns / total_assets` | Ratio |
| Scan Coverage | `(scanned_assets / total_assets) * 100` | Percentage |
| Recurrence Rate | `(reappeared_vulns / total_remediated) * 100` | Percentage |
| Risk Reduction | `(current_risk - previous_risk) / previous_risk * 100` | Percentage |
