Lesson 4 of 9 · 25m
Scanner Integration: Ingest, Normalize, Correlate
Vulnerability and network scanners produce overlapping, inconsistent truth; build ingestion pipelines that normalize evidence without flattening away meaning.
Every scanner is confident, and every scanner is incomplete. One sees authenticated package data, another exposed services, another cloud configuration, and all describe the same asset using different names. Scanner integration means combining partial truth without manufacturing certainty.
Start with the scanner's own object model
Do not scrape a UI or parse a PDF unless there is no alternative. Tenable exposes scan results through its API, OpenVAS/GVM speaks GMP over XML, Qualys has XML/CSV exports, and Nmap produces machine-readable XML with nmap -sV -Pn -oX scan-results.xml 10.24.0.0/22. For Nmap XML, use the XML parser, not regular expressions:
import xml.etree.ElementTree as ET
def parse_nmap_xml(path):
root = ET.parse(path).getroot()
for host in root.findall("host"):
address = host.find("address").get("addr")
for port in host.findall("ports/port"):
service = port.find("service")
yield {"host": address, "port": int(port.get("portid")),
"service": service.get("name") if service is not None else None}This preserves details flat CSV often loses: protocol, scan state, service confidence, hostnames, and script output.
Normalize into a finding schema
Scanner output is input. Your schema is the product. Identify the asset, finding, evidence, observer, and observation time separately.
{
"asset_key": "ip:10.24.8.19",
"finding_key": "tenable:216643:tcp/443",
"source": "tenable.io",
"severity": "high",
"observed_at": "2026-11-30T18:41:12Z",
"attributes": {"cve": ["CVE-2024-0727"], "service": "nginx"}
}Separate asset identity from finding identity. A scanner finding the same vulnerability twice is one finding observed twice, not two vulnerabilities.
Correlation is evidence-weighted, not string matching
Hosts appear as IP addresses, DNS names, cloud instance IDs, serial numbers, and agent names. A cloud instance ID is strong evidence; reverse DNS is mutable; a hostname like web01 is a rumor.
IDENTITY_PRIORITY = ["cloud_instance_id", "serial", "agent_id", "ip", "fqdn"]
def candidate_keys(asset: dict) -> list[str]:
return [f"{kind}:{asset[kind]}" for kind in IDENTITY_PRIORITY if asset.get(kind)]Keep candidate keys on the asset record and score the match. When records merge, record why; when they split later, you need the original evidence. Rescan logic closes the loop: a vulnerability is closed because a scanner or direct check observes it gone, not because a ticket says so.
Field notes
- Scanner APIs paginate aggressively; cursors and page tokens are correctness, not plumbing.
- Do not merge assets solely by IP address in cloud environments — addresses are recycled.
last_seenandfirst_seenbeat a single timestamp; absence of evidence is not evidence of absence.- Keep plugin metadata versions because vendors revise detections.
- Rate limits are not optional reading; a bad export loop can be more disruptive than the scan.
Was this lesson helpful?