: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 intruder issue_targets table (#113299)
Tom Owers003355d718d2
diff --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 922c5900a23d..b4c4c10a3bfd 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@@ -4429,13 +4429,13 @@ The main spec-verified diff is in [COVERAGE_GAPS.md](COVERAGE_GAPS.md#intercom--## Intruder — adequate-Today (7): `fixed_occurrences`, `issues`, `occurrences`, `scan_schedules`, `scans`, `tags`, `targets`+Today (8): `fixed_occurrences`, `issue_targets`, `issues`, `occurrences`, `scan_schedules`, `scans`, `tags`, `targets`Diffed against: <https://api.intruder.io/v1/swagger.json>-No material gaps found.+- [x] `GET /issues/{issue_id}/targets/` — targets affected by each issue (medium)-Note: Full OpenAPI 3.1.1 spec at https://api.intruder.io/v1/swagger.json (linked from the ReadMe docs). Every GET-able analytical collection is already synced: issues, issues/{id}/occurrences, occurrences/fixed, scans, scans/schedules, tags, targets. The only remaining GETs are /health/, /licenses/ (seat/billing), per-occurrence comments and scanner_output (large free-text blobs), and target authentications/api_schemas (scan configuration) — all config or plumbing.+Note: Full OpenAPI 3.1.1 spec at https://api.intruder.io/v1/swagger.json (linked from the ReadMe docs). Every GET-able analytical collection is already synced: issues, issues/{id}/occurrences, issues/{id}/targets, occurrences/fixed, scans, scans/schedules, tags, targets. The only remaining GETs are /health/, /licenses/ (seat/billing), per-occurrence comments and scanner_output (large free-text blobs), and target authentications/api_schemas (scan configuration) — all config or plumbing.## Invoiced — gapsdiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/intruder/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/intruder/canonical_descriptions.pyindex 0aec0271dba5..239a09176bb2 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/intruder/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/intruder/canonical_descriptions.py@@ -87,6 +87,17 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"cves": "CVE identifiers associated with the occurrence.",},},+ "issue_targets": {+ "description": "A target affected by an issue. Fanned out per issue and tagged with its parent issue_id.",+ "docs_url": "https://developers.intruder.io/reference/issues_targets_list",+ "columns": {+ "id": "Unique identifier for the target.",+ "issue_id": "Identifier of the parent issue that affects this target (added by the connector).",+ "address": "The target's address (hostname, IP, URL, or cloud account identifier).",+ "display_address": "Human-readable address (e.g. a cloud account name).",+ "target_type": "The kind of target (external, internal, cloud, or container_image).",+ },+ },"fixed_occurrences": {"description": "An occurrence of an issue that has since been resolved (remediated).","docs_url": "https://developers.intruder.io/reference/occurrences_fixed_list",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/intruder/intruder.py b/products/warehouse_sources/backend/temporal/data_imports/sources/intruder/intruder.pyindex 2a8c8d019538..9f9f20808ef3 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/intruder/intruder.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/intruder/intruder.py@@ -25,7 +25,7 @@ INTRUDER_BASE_URL = "https://api.intruder.io/v1"PAGE_SIZE = 100[email protected](frozen=True)class IntruderResumeConfig:# Full URL of the next page to fetch for a standard (non-fan-out) endpoint. Intruder returns a# ready-to-follow `next` URL on every paginated response. None means "start at the first page".@@ -33,7 +33,7 @@ class IntruderResumeConfig:# Legacy field from the hand-rolled fan-out bookmark, kept so state saved by an older build still# parses (ResumableSourceManager does dataclass(**saved)). No longer written.issue_id: int | None = None- # Framework fan-out resume state for the occurrences endpoint:+ # Framework fan-out resume state for the per-issue fan-out endpoints:# {"completed": [child_path, ...], "current": child_path | None, "child_state": {"next_url": ...} | None}.fanout_state: dict | None = None@@ -127,7 +127,7 @@ def _list_source(return _source_response(endpoint, config, resource)-def _occurrences_source(+def _issue_fan_out_source(access_token: str,endpoint: str,config: IntruderEndpointConfig,@@ -135,9 +135,9 @@ def _occurrences_source(job_id: str,resumable_source_manager: ResumableSourceManager[IntruderResumeConfig],) -> SourceResponse:- """Fan out over every issue, materializing its occurrences as rows tagged with `issue_id`.+ """Fan out over every issue, materializing the child endpoint's rows tagged with `issue_id`.- Each occurrence row gets the owning `issue_id` injected so the composite primary key+ Each child row gets the owning `issue_id` injected so the composite primary key[issue_id, id] stays unique table-wide. Full refresh only — re-pulled rows on resume are dedupedby the primary key on merge."""@@ -199,7 +199,7 @@ def intruder_source() -> SourceResponse:config = INTRUDER_ENDPOINTS[endpoint]if config.fan_out_over_issues:- return _occurrences_source(access_token, endpoint, config, team_id, job_id, resumable_source_manager)+ return _issue_fan_out_source(access_token, endpoint, config, team_id, job_id, resumable_source_manager)return _list_source(access_token, endpoint, config, team_id, job_id, resumable_source_manager)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/intruder/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/intruder/settings.pyindex 85c02aa983ec..a9f78d803178 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/intruder/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/intruder/settings.py@@ -3,7 +3,7 @@ from dataclasses import dataclass, fieldfrom products.warehouse_sources.backend.types import IncrementalField-@dataclass+@dataclass(frozen=True)class IntruderEndpointConfig:name: strpath: str@@ -13,7 +13,7 @@ class IntruderEndpointConfig:# every sync. `None` means the endpoint has no such field, so the table is left unpartitioned.partition_key: str | None = Noneshould_sync_default: bool = True- # Fan out over every issue, calling `/issues/{issue_id}/occurrences/` per issue. When True,+ # Fan out over every issue, calling an `/issues/{issue_id}/...` child endpoint per issue. When True,# `path` is a template with an `{issue_id}` placeholder and each row is tagged with its parent# `issue_id` so the composite primary key stays unique across the whole table.fan_out_over_issues: bool = False@@ -34,6 +34,13 @@ INTRUDER_ENDPOINTS: dict[str, IntruderEndpointConfig] = {partition_key="first_seen_at",fan_out_over_issues=True,),+ # Target ids are only unique within an issue's list, and the rows carry no timestamp to partition on.+ "issue_targets": IntruderEndpointConfig(+ name="issue_targets",+ path="/issues/{issue_id}/targets/",+ primary_keys=["issue_id", "id"],+ fan_out_over_issues=True,+ ),"fixed_occurrences": IntruderEndpointConfig(name="fixed_occurrences",path="/occurrences/fixed/",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/intruder/tests/test_intruder.py b/products/warehouse_sources/backend/temporal/data_imports/sources/intruder/tests/test_intruder.pyindex 2eeae8a07a3b..d80458bd5c69 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/intruder/tests/test_intruder.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/intruder/tests/test_intruder.py@@ -116,6 +116,7 @@ class TestSourceResponseShape:("scan_schedules", ["id"], None, None),("issues", ["id"], None, None),("occurrences", ["issue_id", "id"], "datetime", "first_seen_at"),+ ("issue_targets", ["issue_id", "id"], None, None),("fixed_occurrences", ["id"], "datetime", "first_seen_at"),("tags", ["name"], None, None),]@@ -203,17 +204,18 @@ class TestStandardPagination:class TestOccurrencesFanOut:- def test_injects_parent_issue_id_into_every_row(self) -> None:- # The occurrences response has no issue reference; without the injected issue_id the composite+ @parameterized.expand([("occurrences", "occurrences"), ("issue_targets", "targets")])+ def test_injects_parent_issue_id_into_every_row(self, endpoint: str, child_path: str) -> None:+ # The child response has no issue reference; without the injected issue_id the composite# primary key [issue_id, id] collapses to id and duplicate rows accumulate across issues.responses = {f"{BASE}/issues/?limit={PAGE_SIZE}": [_resp({"results": [{"id": 10}, {"id": 20}], "next": None})],- f"{BASE}/issues/10/occurrences/?limit={PAGE_SIZE}": [+ f"{BASE}/issues/10/{child_path}/?limit={PAGE_SIZE}": [_resp({"results": [{"id": 1}, {"id": 2}], "next": None})],- f"{BASE}/issues/20/occurrences/?limit={PAGE_SIZE}": [_resp({"results": [{"id": 3}], "next": None})],+ f"{BASE}/issues/20/{child_path}/?limit={PAGE_SIZE}": [_resp({"results": [{"id": 3}], "next": None})],}- rows, _params = _run("occurrences", responses, _make_manager())+ rows, _params = _run(endpoint, responses, _make_manager())assert rows == [{"id": 1, "issue_id": 10},{"id": 2, "issue_id": 10},