:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(data-warehouse): add 4 missing tables to the QualysVmdr source (#116460)
Tom Owersf4dc69a876b8
diff --git a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt b/posthog/test/repo_invariants/dataclass_frozen_baseline.txtindex 17d63327349f..a2c71227e1d0 100644--- a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt+++ b/posthog/test/repo_invariants/dataclass_frozen_baseline.txt@@ -949,7 +949,6 @@1 products/warehouse_sources/backend/temporal/data_imports/sources/qualaroo/qualaroo.py1 products/warehouse_sources/backend/temporal/data_imports/sources/qualaroo/settings.py1 products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/qualys_vmdr.py-1 products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/settings.py1 products/warehouse_sources/backend/temporal/data_imports/sources/railway/railway.py1 products/warehouse_sources/backend/temporal/data_imports/sources/railway/settings.py1 products/warehouse_sources/backend/temporal/data_imports/sources/ramp/ramp.pydiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.mdindex f96db29cfb4c..6f1c54c236ea 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md@@ -9880,14 +9880,14 @@ Note: The official Stoplight operation index and individual operation schemas we## QualysVmdr — gaps-Today (4): `host_list_detection`, `hosts`, `knowledge_base`, `scans`+Today (8): `appliances`, `asset_groups`, `host_list_detection`, `hosts`, `ips`, `knowledge_base`, `reports`, `scans`Diffed against: <https://cdn2.qualys.com/docs/qualys-api-vmpc-user-guide.pdf>-- [ ] `GET /api/2.0/fo/asset/group/ (action=list)` — asset group lookup that resolves the group IDs/names hosts are organized by - the main grouping dimension for vulnerability reporting (high)-- [ ] `GET /api/2.0/fo/report/ (action=list, and action=fetch for a report's rows)` — the report inventory and generated report output, including scorecard and remediation reports (medium)-- [ ] `GET /api/2.0/fo/appliance/ (action=list)` — scanner appliance lookup that names the appliance referenced on each scan row (medium)-- [ ] `GET /api/2.0/fo/asset/ip/ (action=list)` — the subscription's tracked IP inventory, including IPs never yet scanned - gives coverage denominators (medium)+- [x] `GET /api/2.0/fo/asset/group/ (action=list)` — asset group lookup that resolves the group IDs/names hosts are organized by - the main grouping dimension for vulnerability reporting (high)+- [x] `GET /api/2.0/fo/report/ (action=list, and action=fetch for a report's rows)` — the report inventory and generated report output, including scorecard and remediation reports (medium)+- [x] `GET /api/2.0/fo/appliance/ (action=list)` — scanner appliance lookup that names the appliance referenced on each scan row (medium)+- [x] `GET /api/2.0/fo/asset/ip/ (action=list)` — the subscription's tracked IP inventory, including IPs never yet scanned - gives coverage denominators (medium)- [ ] `GET /api/2.0/fo/activity_log/ (action=list)` — user activity log for who ran or changed what, the audit dimension of the platform (medium)- [ ] `GET /api/2.0/fo/schedule/scan/ (action=list)` — scheduled scan definitions that explain the cadence behind the scans table (low)- [ ] `GET /api/2.0/fo/compliance/posture/info/ (action=list)` — per-host control pass/fail posture for Policy Compliance subscriptions (low)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/canonical_descriptions.pyindex 7e787c64f33c..0478dd122807 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/canonical_descriptions.py@@ -70,4 +70,62 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"last_service_modification_datetime": "When Qualys last modified the vulnerability definition.",},},+ "asset_groups": {+ "description": "Asset groups: one row per asset group, with its owner, the IPs and hosts it contains, and its scanner appliances.",+ "docs_url": _API_DOCS_URL,+ "columns": {+ "id": "Unique ID of the asset group.",+ "title": "Title of the asset group.",+ "owner_user_id": "ID of the Qualys user who owns the asset group.",+ "owner_user_name": "Name of the Qualys user who owns the asset group.",+ "last_update": "When the asset group was last updated.",+ "business_impact": "Business impact level assigned to the asset group.",+ "default_appliance_id": "ID of the default scanner appliance of the asset group (joins to the appliances table).",+ "appliance_ids": "Comma-separated IDs of the scanner appliances assigned to the asset group.",+ "ip_set": "IP addresses and IP ranges in the asset group (JSON).",+ "host_ids": "Comma-separated IDs of the hosts in the asset group (joins to the hosts table).",+ "assigned_user_ids": "Comma-separated IDs of the users the asset group is assigned to.",+ "assigned_unit_ids": "Comma-separated IDs of the business units the asset group is assigned to.",+ },+ },+ "reports": {+ "description": "Report inventory: one row per report saved in Report Share, including scorecard reports. Holds report metadata, not report contents.",+ "docs_url": _API_DOCS_URL,+ "columns": {+ "id": "Unique ID of the report.",+ "title": "Title of the report.",+ "type": "Report type (for example Scan or Scorecard).",+ "user_login": "Qualys user who launched the report.",+ "launch_datetime": "When the report was launched.",+ "output_format": "Output format of the report (for example PDF, CSV, or XML).",+ "size": "Size of the report file, as display text.",+ "status": "Report status, with the state Running, Finished, Submitted, Canceled, or Errors (JSON).",+ "expiration_datetime": "When the report expires from Report Share.",+ },+ },+ "appliances": {+ "description": "Scanner appliances: one row per physical, virtual, or containerized scanner appliance with its status and configuration.",+ "docs_url": _API_DOCS_URL,+ "columns": {+ "id": "Unique ID of the scanner appliance.",+ "uuid": "UUID of the scanner appliance.",+ "name": "Friendly name of the scanner appliance.",+ "software_version": "Software version that runs on the scanner appliance.",+ "running_scan_count": "Number of scans that currently run on the scanner appliance.",+ "status": "Heartbeat check status: Online or Offline.",+ "model_number": "Model number of the scanner appliance.",+ "type": "Scanner appliance type (for example Physical or Virtual).",+ "serial_number": "Serial number of the scanner appliance.",+ "interface_settings": "Network interface settings of the scanner appliance (JSON).",+ },+ },+ "ips": {+ "description": "Tracked IP inventory: one row per single IP address or IP range in the Qualys subscription, including IPs not yet scanned.",+ "docs_url": _API_DOCS_URL,+ "columns": {+ "ip_range": "The entry as Qualys returns it: a single IP address, or a range written as start-end.",+ "start_ip": "First IP address of the entry.",+ "end_ip": "Last IP address of the entry. Equal to start_ip for a single IP address.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/qualys_vmdr.py b/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/qualys_vmdr.pyindex 4d844fd22156..394efec41f75 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/qualys_vmdr.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/qualys_vmdr.py@@ -1,7 +1,7 @@import jsonimport timeimport dataclasses-from collections.abc import Iterator+from collections.abc import Container, Iteratorfrom datetime import UTC, date, datetimefrom typing import Any, Optionalfrom urllib.parse import urlencode, urlsplit, urlunsplit@@ -281,7 +281,7 @@ def _element_to_value(element: Element) -> Any:return result-def _element_to_row(element: Element, skip_tags: set[str] | None = None) -> dict[str, Any]:+def _element_to_row(element: Element, skip_tags: Container[str] | None = None) -> dict[str, Any]:"""Convert one record element to a flat row dict.Scalar children become string columns. Nested children (CVE_LIST, DNS_DATA, TAGS, ...) are@@ -300,8 +300,17 @@ def _element_to_row(element: Element, skip_tags: set[str] | None = None) -> dictdef _extract_rows(root: Element, config: QualysVmdrEndpointConfig) -> Iterator[dict[str, Any]]:for item in root.iter(config.item_tag):+ if config.flatten_ip_set:+ for entry in item:+ value = (entry.text or "").strip()+ if entry.tag not in ("IP", "IP_RANGE") or not value:+ continue+ start_ip, _, end_ip = value.partition("-")+ yield {"ip_range": value, "start_ip": start_ip, "end_ip": end_ip or start_ip}+ continue+if not config.flatten_host_detections:- yield _element_to_row(item)+ yield _element_to_row(item, skip_tags=config.drop_tags)continue# One row per (host, detection): host scalars prefixed host_* merged with thediff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/settings.pyindex 6e657f77e2f4..b4fc09d88ac9 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/settings.py@@ -1,6 +1,8 @@-from dataclasses import dataclass, field+from dataclasses import fieldfrom typing import Optional+from posthog.dataclasses import frozen+from products.warehouse_sources.backend.types import IncrementalField, IncrementalFieldType# Opaque vendor version labels — never parsed or ordered. Only the KnowledgeBase Vulnerability API@@ -15,7 +17,7 @@ QUALYS_VMDR_SUPPORTED_VERSIONS = (QUALYS_VMDR_API_VERSION_2_0, QUALYS_VMDR_API_VQUALYS_VMDR_DEFAULT_VERSION = QUALYS_VMDR_API_VERSION_4_0-@dataclass+@frozenclass QualysVmdrEndpointConfig:name: strpath: str # version-independent request path, e.g. "/api/2.0/fo/asset/host/"@@ -32,6 +34,11 @@ class QualysVmdrEndpointConfig:truncation_limit: Optional[int] = None# Flatten each HOST's DETECTION_LIST into one row per detection (Host List Detection only).flatten_host_detections: bool = False+ # Emit one row per IP / IP_RANGE entry of each `item_tag` element (IP List only), because the+ # entries are bare text nodes with no fields of their own.+ flatten_ip_set: bool = False+ # Child elements left out of the row.+ drop_tags: frozenset[str] = frozenset()should_sync_default: bool = True# Per-version path overrides for endpoints whose route moved between vendor versions. Absent# keys fall through to `path` — that is the correct version-independent route, not silent drift,@@ -137,6 +144,52 @@ QUALYS_VMDR_ENDPOINTS: dict[str, QualysVmdrEndpointConfig] = {path_overrides={QUALYS_VMDR_API_VERSION_4_0: "/api/4.0/fo/knowledge_base/vuln/"},jwt_versions=frozenset({QUALYS_VMDR_API_VERSION_4_0}),),+ # Asset groups: the grouping dimension for hosts and reports. No server-side "modified since"+ # filter exists, so this is full refresh. `show_attributes=ALL` adds the owner, last update,+ # host IDs and appliance IDs that the default output leaves out.+ "asset_groups": QualysVmdrEndpointConfig(+ name="asset_groups",+ path="/api/2.0/fo/asset/group/",+ item_tag="ASSET_GROUP",+ params={"action": "list", "show_attributes": "ALL"},+ primary_keys=["id"],+ truncation_limit=1000,+ ),+ # Report inventory (Report Share). Metadata only: `action=fetch` returns a rendered PDF/CSV/XML+ # file, not rows. Qualys retires the 2.0 Report API in favor of 3.0, which keeps basic auth and+ # the same output, so both source-level pins call 3.0. The list is not paginated.+ "reports": QualysVmdrEndpointConfig(+ name="reports",+ path="/api/3.0/fo/report/",+ item_tag="REPORT",+ params={"action": "list"},+ primary_keys=["id"],+ truncation_limit=None,+ should_sync_default=False,+ ),+ # Scanner appliances. `output_mode=full` adds type, model, network and capacity details to the+ # brief id/name/status output. The list is not paginated.+ "appliances": QualysVmdrEndpointConfig(+ name="appliances",+ path="/api/2.0/fo/appliance/",+ item_tag="APPLIANCE",+ params={"action": "list", "output_mode": "full"},+ primary_keys=["id"],+ truncation_limit=None,+ # The activation code registers a scanner to the subscription, so it stays out of the warehouse.+ drop_tags=frozenset({"ACTIVATION_CODE"}),+ ),+ # The subscription's tracked IP inventory, as the single IPs and ranges Qualys returns. The+ # entries carry no ID, so the entry text is the key. The list is not paginated.+ "ips": QualysVmdrEndpointConfig(+ name="ips",+ path="/api/2.0/fo/asset/ip/",+ item_tag="IP_SET",+ params={"action": "list"},+ primary_keys=["ip_range"],+ truncation_limit=None,+ flatten_ip_set=True,+ ),}ENDPOINTS = tuple(QUALYS_VMDR_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/source.pyindex 51938fd250b6..bf9786f04131 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/source.py@@ -149,6 +149,8 @@ The `knowledge_base` table additionally requires the KnowledgeBase download optidef _description(endpoint: str) -> str | None:if endpoint == "knowledge_base":return "Requires the KnowledgeBase download option enabled on your Qualys subscription"+ if endpoint == "reports":+ return "Requires the Report Share feature enabled on your Qualys subscription"return Noneschemas = [diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/tests/test_qualys_vmdr.py b/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/tests/test_qualys_vmdr.pyindex 897a2c3514ef..0b967792e628 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/tests/test_qualys_vmdr.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/qualys_vmdr/tests/test_qualys_vmdr.py@@ -131,6 +131,76 @@ KNOWLEDGE_BASE_PAGE = """<?xml version="1.0" encoding="UTF-8" ?></KNOWLEDGE_BASE_VULN_LIST_OUTPUT>"""+ASSET_GROUP_PAGE = """<?xml version="1.0" encoding="UTF-8" ?>+<ASSET_GROUP_LIST_OUTPUT>+ <RESPONSE>+ <DATETIME>2026-07-15T00:00:00Z</DATETIME>+ <ASSET_GROUP_LIST>+ <ASSET_GROUP>+ <ID>501</ID>+ <TITLE><![CDATA[Web servers]]></TITLE>+ <OWNER_USER_ID>77</OWNER_USER_ID>+ <IP_SET>+ <IP_RANGE>10.0.0.1-10.0.0.9</IP_RANGE>+ <IP>10.0.1.5</IP>+ </IP_SET>+ <HOST_IDS>1001, 1002</HOST_IDS>+ </ASSET_GROUP>+ </ASSET_GROUP_LIST>+ </RESPONSE>+</ASSET_GROUP_LIST_OUTPUT>"""++REPORT_PAGE = """<?xml version="1.0" encoding="UTF-8" ?>+<REPORT_LIST_OUTPUT>+ <RESPONSE>+ <DATETIME>2026-07-15T00:00:00Z</DATETIME>+ <REPORT_LIST>+ <REPORT>+ <ID>9001</ID>+ <TITLE><![CDATA[Weekly scan]]></TITLE>+ <TYPE>Scan</TYPE>+ <LAUNCH_DATETIME>2026-07-14T08:00:00Z</LAUNCH_DATETIME>+ <STATUS>+ <STATE>Finished</STATE>+ </STATUS>+ </REPORT>+ </REPORT_LIST>+ </RESPONSE>+</REPORT_LIST_OUTPUT>"""++APPLIANCE_PAGE = """<?xml version="1.0" encoding="UTF-8" ?>+<APPLIANCE_LIST_OUTPUT>+ <RESPONSE>+ <DATETIME>2026-07-15T00:00:00Z</DATETIME>+ <APPLIANCE_LIST>+ <APPLIANCE>+ <ID>301</ID>+ <NAME>scanner-a</NAME>+ <STATUS>Online</STATUS>+ <TYPE>Virtual</TYPE>+ <ACTIVATION_CODE>00000000000000</ACTIVATION_CODE>+ <INTERFACE_SETTINGS>+ <INTERFACE>lan</INTERFACE>+ <IP_ADDRESS>10.0.9.1</IP_ADDRESS>+ </INTERFACE_SETTINGS>+ </APPLIANCE>+ </APPLIANCE_LIST>+ </RESPONSE>+</APPLIANCE_LIST_OUTPUT>"""++IP_LIST_PAGE = """<?xml version="1.0" encoding="UTF-8" ?>+<IP_LIST_OUTPUT>+ <RESPONSE>+ <DATETIME>2026-07-15T00:00:00Z</DATETIME>+ <IP_SET>+ <IP>10.0.1.5</IP>+ <IP_RANGE>10.0.0.1-10.0.0.9</IP_RANGE>+ <IP> </IP>+ </IP_SET>+ </RESPONSE>+</IP_LIST_OUTPUT>"""++def _response(status_code: int = 200, text: str = "", headers: dict[str, str] | None = None) -> mock.MagicMock:response = mock.MagicMock()response.status_code = status_code@@ -205,6 +275,78 @@ class TestQualysVmdr:assert len(result.saved_states) == 1assert "id_min=1002" in result.saved_states[0].next_url+ @pytest.mark.parametrize(+ "endpoint,body,expected_path,expected_params,expected_rows",+ [+ (+ "asset_groups",+ ASSET_GROUP_PAGE,+ "/api/2.0/fo/asset/group/",+ {"action": "list", "show_attributes": "ALL", "truncation_limit": "1000"},+ [+ {+ "id": "501",+ "title": "Web servers",+ "owner_user_id": "77",+ "ip_set": '{"ip_range": "10.0.0.1-10.0.0.9", "ip": "10.0.1.5"}',+ "host_ids": "1001, 1002",+ }+ ],+ ),+ (+ "reports",+ REPORT_PAGE,+ "/api/3.0/fo/report/",+ {"action": "list", "truncation_limit": None},+ [+ {+ "id": "9001",+ "title": "Weekly scan",+ "type": "Scan",+ "launch_datetime": "2026-07-14T08:00:00Z",+ "status": '{"state": "Finished"}',+ }+ ],+ ),+ (+ "appliances",+ APPLIANCE_PAGE,+ "/api/2.0/fo/appliance/",+ {"action": "list", "output_mode": "full", "truncation_limit": None},+ [+ {+ "id": "301",+ "name": "scanner-a",+ "status": "Online",+ "type": "Virtual",+ "interface_settings": '{"interface": "lan", "ip_address": "10.0.9.1"}',+ }+ ],+ ),+ (+ "ips",+ IP_LIST_PAGE,+ "/api/2.0/fo/asset/ip/",+ {"action": "list", "truncation_limit": None},+ [+ {"ip_range": "10.0.1.5", "start_ip": "10.0.1.5", "end_ip": "10.0.1.5"},+ {"ip_range": "10.0.0.1-10.0.0.9", "start_ip": "10.0.0.1", "end_ip": "10.0.0.9"},+ ],+ ),+ ],+ )+ @pytest.mark.parametrize("api_version", ["2.0", "4.0"])+ def test_get_rows_lookup_endpoints_request_shape_and_rows(+ self, api_version, endpoint, body, expected_path, expected_params, expected_rows+ ):+ result = _drive(endpoint, [_xml(body)], api_version=api_version)++ assert result.raised is None+ assert result.paths == [expected_path]+ assert {name: result.params(name)[0] for name in expected_params} == expected_params+ assert result.rows == expected_rows+ assert result.requests[0].headers["authorization"].startswith("Basic ")+def test_get_rows_resumes_from_saved_state(self):resume_url = "https://qualysapi.qualys.com/api/2.0/fo/asset/host/?action=list&id_min=1002"