Skip to content

: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.

feat(data-warehouse): add four missing gitguardian tables (#109102)

Tom Owers50661919ad65
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.md
index dea295346240..ed970be21f9d 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
@@ -3602,10 +3602,10 @@ Today (6): `honeytokens`, `members`, `secret_incidents`, `secret_occurrences`, `
Diffed against: <https://api.gitguardian.com/v1/openapi.json>
-- [ ] `/v1/secret_detectors` — lookup resolving the detector name/family stamped on every incident and occurrence we already sync (high)
-- [ ] `/v1/incidents/secrets/{incident_id}/activity-logs` — incident state-transition history — remediation MTTR cannot be computed from current status alone (high)
-- [ ] `/v1/honeytokens_events` — honeytoken trigger events across the org; honeytokens are synced but the events they exist to capture are not (high)
-- [ ] `/v1/teams/{team_id}/team_memberships` — join table between the members and teams we already sync (high)
+- [x] `/v1/secret_detectors` — lookup resolving the detector name/family stamped on every incident and occurrence we already sync (high)
+- [x] `/v1/incidents/secrets/{incident_id}/activity-logs` — incident state-transition history — remediation MTTR cannot be computed from current status alone (high)
+- [x] `/v1/honeytokens_events` — honeytoken trigger events across the org; honeytokens are synced but the events they exist to capture are not (high)
+- [x] `/v1/teams/{team_id}/team_memberships` — join table between the members and teams we already sync (high)
- [ ] `/v1/incidents/secrets/{incident_id}/notes` — analyst remediation notes attached to each incident (medium)
- [ ] `/v1/custom_tags` — lookup resolving the custom tag IDs applied to incidents (medium)
- [ ] `/v1/audit_logs` — org-wide audit trail of who changed what in GitGuardian (medium)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gitguardian/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gitguardian/canonical_descriptions.py
index 63a273dabcc6..95bd847e4f72 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gitguardian/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gitguardian/canonical_descriptions.py
@@ -106,4 +106,63 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"gitguardian_url": "Link to the team in the GitGuardian dashboard.",
},
},
+ "team_memberships": {
+ "description": "A membership of a workspace member in a team, with the permissions the member holds in that team.",
+ "docs_url": "https://api.gitguardian.com/docs#tag/Team-Memberships",
+ "columns": {
+ "id": "Unique identifier of the team membership.",
+ "team_id": "Identifier of the team.",
+ "member_id": "Identifier of the workspace member.",
+ "is_team_leader": "Whether the member is a leader of the team.",
+ "team_permission": "Deprecated in favor of is_team_leader; whether the member can manage the team (can_manage, cannot_manage).",
+ "incident_permission": "Permission of the member on the team's incidents (can_view, can_edit, full_access).",
+ },
+ },
+ "honeytoken_events": {
+ "description": "An event recorded when someone uses one of your honeytokens, with the origin IP address and the action performed.",
+ "docs_url": "https://api.gitguardian.com/docs#tag/Honeytokens-Events",
+ "columns": {
+ "id": "Unique identifier of the honeytoken event.",
+ "honeytoken_id": "Identifier of the honeytoken that was triggered.",
+ "triggered_at": "Date and time the honeytoken was triggered.",
+ "gitguardian_url": "Link to the event in the GitGuardian dashboard.",
+ "status": "Triage status of the event (open, closed).",
+ "ip_address": "IP address the event originates from.",
+ "action": "Action performed with the honeytoken.",
+ "data": "Additional data related to the event.",
+ "tags": "Tags attached to the event (e.g. publicly_exposed).",
+ },
+ },
+ "secret_incident_activity_logs": {
+ "description": "One entry in the activity history of a secret incident: a system action (assignment, status change, ...) or a user note, in chronological order.",
+ "docs_url": "https://api.gitguardian.com/docs#tag/Secret-Incidents",
+ "columns": {
+ "id": "Unique identifier of the activity log entry.",
+ "incident_id": "Identifier of the secret incident the entry belongs to.",
+ "member": "Workspace member at the origin of the entry (id, name, email, access_level). Null for system actions.",
+ "api_token_id": "Identifier of the API token at the origin of the entry, if it came through the API.",
+ "created_at": "Date and time the entry was created.",
+ "updated_at": "Date and time the entry was last updated. Null if it was never modified.",
+ "content": "Entry content: a user note (type note, comment) or a system action (type action, content_key, data).",
+ },
+ },
+ "secret_detectors": {
+ "description": "A secret detector GitGuardian uses to match secrets, with its category and the incident counts it produced in your workspace.",
+ "docs_url": "https://api.gitguardian.com/docs#tag/Secret-Detectors",
+ "columns": {
+ "name": "Unique name of the detector (e.g. aws_iam).",
+ "display_name": "Human-readable name of the detector.",
+ "type": "Type of the detector (specific, generic, custom).",
+ "category": "Category of the detector (e.g. Cloud Provider).",
+ "is_active": "Whether the detector is enabled on the workspace.",
+ "scans_code_only": "Whether the detector scans only VCS resources.",
+ "checkable": "Whether the detector has a validity checker.",
+ "use_with_validity_check_disabled": "Whether the detector is used when secret validity checks are disabled on the workspace.",
+ "frequency": "Number of secrets found per million commits in GitGuardian's open-source monitoring.",
+ "removed_at": "Date and time GitGuardian disabled the detector, if it did.",
+ "open_incidents_count": "Number of open secret incidents on the workspace for this detector.",
+ "ignored_incidents_count": "Number of ignored secret incidents on the workspace for this detector.",
+ "resolved_incidents_count": "Number of resolved secret incidents on the workspace for this detector.",
+ },
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gitguardian/gitguardian.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gitguardian/gitguardian.py
index afa5e24f10f8..93d97dba3ab4 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gitguardian/gitguardian.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gitguardian/gitguardian.py
@@ -2,12 +2,14 @@ import dataclasses
from collections.abc import Iterator
from datetime import UTC, date, datetime
from typing import Any, Optional
-from urllib.parse import urlencode, urljoin, urlsplit
+from urllib.parse import quote, urlencode, urljoin, urlsplit
import requests
from structlog.types import FilteringBoundLogger
from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_exponential_jitter
+from posthog.dataclasses import frozen
+
from products.warehouse_sources.backend.temporal.data_imports.sources.common.http import make_tracked_session
from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponse
@@ -161,7 +163,9 @@ def check_endpoint_access(api_key: str, base_url: str, endpoint: str) -> str | N
stay retryable, so they report the endpoint as reachable rather than blocking the schema.
"""
config = GITGUARDIAN_ENDPOINTS[endpoint]
- url = _build_url(base_url, config.path, {"per_page": 1})
+ # Fan-out children share their parent's scope, and their path needs a real parent id.
+ probe_path = GITGUARDIAN_ENDPOINTS[config.parent_endpoint].path if config.parent_endpoint else config.path
+ url = _build_url(base_url, probe_path, {"per_page": 1})
try:
# capture=False keeps GitGuardian security metadata (repo names, file paths, secret hashes)
# out of the HTTP sample bucket — the name-based scrubbers can't recognise these fields.
@@ -179,6 +183,76 @@ def check_endpoint_access(api_key: str, base_url: str, endpoint: str) -> str | N
return f"Your API token is missing the `{config.required_scope}` scope required for this table."
+def _list_params(config: GitGuardianEndpointConfig) -> dict[str, Any]:
+ params: dict[str, Any] = {"per_page": config.page_size}
+ if config.ordering:
+ params["ordering"] = config.ordering
+ return params
+
+
+@frozen
+class _GitGuardianPage:
+ url: str
+ rows: list[dict[str, Any]]
+
+
+def _iter_pages(
+ session: requests.Session,
+ url: str,
+ headers: dict[str, str],
+ base_url: str,
+ endpoint: str,
+ logger: FilteringBoundLogger,
+) -> Iterator[_GitGuardianPage]:
+ """Walk the Link-header cursor from `url`, yielding each page's fetch URL and rows."""
+ while True:
+ response = _fetch_page(session, url, headers, logger)
+ rows = response.json()
+ if not isinstance(rows, list):
+ # Every GitGuardian list endpoint returns a plain JSON array; anything else means the
+ # URL walked somewhere unexpected. Bail loudly rather than yield garbage rows.
+ raise ValueError(f"GitGuardian returned a non-list response for {endpoint}: {type(rows).__name__}")
+ next_url = _next_page_url(response)
+
+ yield _GitGuardianPage(url=url, rows=rows)
+
+ if not next_url:
+ break
+ url = _ensure_same_origin(next_url, base_url)
+
+
+def _get_fan_out_rows(
+ session: requests.Session,
+ headers: dict[str, str],
+ base_url: str,
+ config: GitGuardianEndpointConfig,
+ parent: GitGuardianEndpointConfig,
+ logger: FilteringBoundLogger,
+) -> Iterator[list[dict[str, Any]]]:
+ parent_url = _build_url(base_url, parent.path, _list_params(parent))
+
+ for page in _iter_pages(session, parent_url, headers, base_url, parent.name, logger):
+ for parent_row in page.rows:
+ parent_id = parent_row.get("id")
+ if parent_id is None:
+ continue
+ path = config.path.format(parent_id=quote(str(parent_id), safe=""))
+ try:
+ for page in _iter_pages(
+ session, _build_url(base_url, path, _list_params(config)), headers, base_url, config.name, logger
+ ):
+ if page.rows:
+ yield page.rows
+ except requests.HTTPError as e:
+ # The parent can be deleted between listing it and fetching its children.
+ if e.response is not None and e.response.status_code == 404:
+ logger.info(
+ f"GitGuardian {parent.name} {parent_id} not found while syncing {config.name}; skipping"
+ )
+ continue
+ raise
+
+
def get_rows(
api_key: str,
base_url: str,
@@ -196,9 +270,12 @@ def get_rows(
# (repo names, file paths, secret hashes) out of the HTTP sample bucket.
session = make_tracked_session(allow_redirects=False, capture=False)
- params: dict[str, Any] = {"per_page": config.page_size}
- if config.ordering:
- params["ordering"] = config.ordering
+ if config.parent_endpoint:
+ parent = GITGUARDIAN_ENDPOINTS[config.parent_endpoint]
+ yield from _get_fan_out_rows(session, headers, base_url, config, parent, logger)
+ return
+
+ params = _list_params(config)
if should_use_incremental_field and db_incremental_field_last_value is not None:
value = db_incremental_field_last_value
if isinstance(value, datetime | date) and config.incremental_lookback:
@@ -214,32 +291,23 @@ def get_rows(
resume = (
resumable_source_manager.load_state() if config.resumable and resumable_source_manager.can_resume() else None
)
- url = (
- _ensure_same_origin(resume.url, base_url)
- if resume and resume.url
- else _build_url(base_url, config.path, params)
- )
-
- while True:
- response = _fetch_page(session, url, headers, logger)
- rows = response.json()
- if not isinstance(rows, list):
- # Every GitGuardian list endpoint returns a plain JSON array; anything else means the
- # URL walked somewhere unexpected. Bail loudly rather than yield garbage rows.
- raise ValueError(f"GitGuardian returned a non-list response for {endpoint}: {type(rows).__name__}")
- next_url = _next_page_url(response)
-
- if rows:
- if config.excluded_fields:
- rows = [{k: v for k, v in row.items() if k not in config.excluded_fields} for row in rows]
- yield rows
- # Checkpoint the CURRENT page's URL after yielding, so a crash re-fetches this page.
- if config.resumable:
- resumable_source_manager.save_state(GitGuardianResumeConfig(url=url))
-
- if not next_url:
- break
- url = _ensure_same_origin(next_url, base_url)
+ if resume and resume.url:
+ urls = [_ensure_same_origin(resume.url, base_url)]
+ elif config.statuses:
+ urls = [_build_url(base_url, config.path, params | {"status": status}) for status in config.statuses]
+ else:
+ urls = [_build_url(base_url, config.path, params)]
+
+ for url in urls:
+ for page in _iter_pages(session, url, headers, base_url, endpoint, logger):
+ rows = page.rows
+ if rows:
+ if config.excluded_fields:
+ rows = [{k: v for k, v in row.items() if k not in config.excluded_fields} for row in rows]
+ yield rows
+ # Checkpoint the CURRENT page's URL after yielding, so a crash re-fetches this page.
+ if config.resumable:
+ resumable_source_manager.save_state(GitGuardianResumeConfig(url=page.url))
# The walk finished cleanly, so drop the checkpoint. Otherwise a retry that re-runs extract
# after a completed walk would resume from the final page and skip everything before it.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gitguardian/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gitguardian/settings.py
index 7d2de4b76908..900057af6b1b 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gitguardian/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gitguardian/settings.py
@@ -6,7 +6,7 @@ from typing import Optional
from products.warehouse_sources.backend.types import IncrementalField, IncrementalFieldType
-@dataclass
+@dataclass(frozen=True)
class GitGuardianEndpointConfig:
name: str
path: str
@@ -37,6 +37,11 @@ class GitGuardianEndpointConfig:
# (e.g. `share_url`, which grants secret access without a GitGuardian account) that would
# otherwise leak the very secrets this data is meant to help remediate.
excluded_fields: AbstractSet[str] = field(default_factory=frozenset)
+ # Fan-out: walk this parent endpoint and fetch `path` once per parent row, substituting the
+ # parent's `id` into the `{parent_id}` placeholder. The probe for scope checks hits the parent
+ # instead, since the child path can't be requested without a real id.
+ parent_endpoint: Optional[str] = None
+ statuses: tuple[str, ...] = ()
_DATE_INCREMENTAL_FIELD: list[IncrementalField] = [
@@ -111,6 +116,52 @@ GITGUARDIAN_ENDPOINTS: dict[str, GitGuardianEndpointConfig] = {
required_scope="teams:read",
incremental_fields=[],
),
+ # Team memberships: the member <-> team join table, fanned out per team. The row carries
+ # `team_id` itself, so it leads the key to keep it unique across the fanned-out teams.
+ "team_memberships": GitGuardianEndpointConfig(
+ name="team_memberships",
+ path="/v1/teams/{parent_id}/team_memberships",
+ parent_endpoint="teams",
+ primary_keys=["team_id", "id"],
+ required_scope="teams:read",
+ incremental_fields=[],
+ ),
+ # Honeytoken events: every trigger of every honeytoken. `triggered_at` is immutable and the
+ # endpoint accepts `ordering=triggered_at`, but there is no server-side time filter and
+ # `status` mutates on triage, so full refresh.
+ "honeytoken_events": GitGuardianEndpointConfig(
+ name="honeytoken_events",
+ path="/v1/honeytokens_events",
+ partition_key="triggered_at",
+ ordering="triggered_at",
+ required_scope="honeytokens:read",
+ incremental_fields=[],
+ statuses=("open", "archived", "allowed"),
+ ),
+ # Incident activity logs: the state-transition and notes history of each secret incident,
+ # fanned out per incident. There is no server-side time filter, so full refresh. Off by
+ # default because it costs at least one request per incident.
+ "secret_incident_activity_logs": GitGuardianEndpointConfig(
+ name="secret_incident_activity_logs",
+ path="/v1/incidents/secrets/{parent_id}/activity-logs",
+ parent_endpoint="secret_incidents",
+ partition_key="created_at",
+ ordering="created_at",
+ primary_keys=["incident_id", "id"],
+ required_scope="incidents:read",
+ should_sync_default=False,
+ incremental_fields=[],
+ ),
+ # Secret detectors: lookup for the detector stamped on incidents and occurrences. Keyed by
+ # `name` (the API has no numeric id); open/resolved counts mutate, so full refresh.
+ "secret_detectors": GitGuardianEndpointConfig(
+ name="secret_detectors",
+ path="/v1/secret_detectors",
+ ordering="name",
+ primary_keys=["name"],
+ required_scope="incidents:read",
+ incremental_fields=[],
+ ),
}
ENDPOINTS = tuple(GITGUARDIAN_ENDPOINTS.keys())
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gitguardian/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gitguardian/source.py
index 30f38db38e77..4b6105b1eabc 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gitguardian/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gitguardian/source.py
@@ -57,7 +57,7 @@ class GitguardianSource(ResumableSource[GitguardianSourceConfig, GitGuardianResu
category=DataWarehouseSourceCategory.ENGINEERING___MONITORING,
label="GitGuardian",
releaseStatus=ReleaseStatus.ALPHA,
- caption="""Enter a GitGuardian API token to sync your secret incidents, occurrences, monitored sources, honeytokens, members, and teams into the PostHog Data warehouse.
+ caption="""Enter a GitGuardian API token to sync your secret incidents, occurrences, incident activity logs, secret detectors, monitored sources, honeytokens, honeytoken events, members, teams, and team memberships into the PostHog Data warehouse.
Create a service account token (recommended for unattended syncs) or a personal access token in your [GitGuardian API settings](https://dashboard.gitguardian.com/api). Grant the read scopes for the tables you want to sync: `incidents:read`, `sources:read`, `honeytokens:read`, `members:read`, and `teams:read`. Reading incidents requires a token with at least the Manager access level.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gitguardian/tests/test_gitguardian.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gitguardian/tests/test_gitguardian.py
index 037db6a5d6d1..1f5fa0f13670 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gitguardian/tests/test_gitguardian.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gitguardian/tests/test_gitguardian.py
@@ -1,5 +1,6 @@
+from collections.abc import Sequence
from datetime import UTC, date, datetime
-from typing import Any
+from typing import Any, NamedTuple
from urllib.parse import parse_qs, urlsplit
import pytest
@@ -48,19 +49,28 @@ class _FakeManager:
self.cleared = True
+class _GetRowsResult(NamedTuple):
+ rows: list[dict]
+ fetched: list[str]
+ manager: _FakeManager
+
+
def _run_get_rows(
monkeypatch: Any,
endpoint: str,
- responses: list[MagicMock],
+ responses: Sequence[MagicMock | Exception],
manager: _FakeManager | None = None,
**kwargs: Any,
-) -> tuple[list[dict], list[str], _FakeManager]:
+) -> _GetRowsResult:
fetched: list[str] = []
resp_iter = iter(responses)
def fake_fetch(session: Any, url: str, headers: dict[str, str], logger: Any) -> MagicMock:
fetched.append(url)
- return next(resp_iter)
+ response = next(resp_iter)
+ if isinstance(response, Exception):
+ raise response
+ return response
monkeypatch.setattr(gitguardian, "_fetch_page", fake_fetch)
monkeypatch.setattr(gitguardian, "make_tracked_session", lambda *a, **k: MagicMock())
@@ -76,7 +86,7 @@ def _run_get_rows(
**kwargs,
):
rows.extend(page)
- return rows, fetched, manager
+ return _GetRowsResult(rows, fetched, manager)
def _query(url: str) -> dict[str, list[str]]:
@@ -134,6 +144,11 @@ class TestLinkHeaderPagination:
assert [r["id"] for r in rows] == [1, 2, 3]
assert fetched == [f"{BASE_URL}/v1/incidents/secrets?per_page=100&ordering=date", next_url]
+ def test_honeytoken_events_fetch_every_status(self, monkeypatch: Any) -> None:
+ responses = [_page([]), _page([]), _page([])]
+ _, fetched, _ = _run_get_rows(monkeypatch, "honeytoken_events", responses)
+ assert [_query(url)["status"] for url in fetched] == [["open"], ["archived"], ["allowed"]]
+
def test_first_sync_sends_ordering_but_no_date_filter(self, monkeypatch: Any) -> None:
# No watermark => full backfill, but ordering must still be explicit so sort_mode="asc" holds.
responses = [_page([{"id": 1}])]
@@ -202,6 +217,57 @@ class TestLinkHeaderPagination:
assert rows == [{"id": 1, "date": "2026-01-01"}]
+def _http_error(status_code: int) -> requests.HTTPError:
+ response = MagicMock()
+ response.status_code = status_code
+ return requests.HTTPError(f"{status_code} Client Error", response=response)
+
+
+class TestFanOut:
+ def test_walks_every_parent_page_and_each_childs_pages(self, monkeypatch: Any) -> None:
+ teams_next = f"{BASE_URL}/v1/teams?cursor=t2&per_page=100"
+ child_next = f"{BASE_URL}/v1/teams/1/team_memberships?cursor=m2&per_page=100"
+ responses = [
+ _page([{"id": 1}], next_url=teams_next),
+ _page([{"id": 10, "team_id": 1}], next_url=child_next),
+ _page([{"id": 11, "team_id": 1}]),
+ _page([{"id": 2}]),
+ _page([{"id": 20, "team_id": 2}]),
+ ]
+ rows, fetched, manager = _run_get_rows(monkeypatch, "team_memberships", responses)
+ assert [r["id"] for r in rows] == [10, 11, 20]
+ assert fetched == [
+ f"{BASE_URL}/v1/teams?per_page=100",
+ f"{BASE_URL}/v1/teams/1/team_memberships?per_page=100",
+ child_next,
+ teams_next,
+ f"{BASE_URL}/v1/teams/2/team_memberships?per_page=100",
+ ]
+ assert manager.saved == []
+
+ def test_child_requests_keep_their_own_ordering(self, monkeypatch: Any) -> None:
+ responses = [_page([{"id": 7}]), _page([{"id": 70, "incident_id": 7}])]
+ _, fetched, _ = _run_get_rows(monkeypatch, "secret_incident_activity_logs", responses)
+ assert fetched == [
+ f"{BASE_URL}/v1/incidents/secrets?per_page=100&ordering=date",
+ f"{BASE_URL}/v1/incidents/secrets/7/activity-logs?per_page=100&ordering=created_at",
+ ]
+
+ def test_parent_deleted_mid_sync_is_skipped(self, monkeypatch: Any) -> None:
+ responses: Sequence[MagicMock | Exception] = [
+ _page([{"id": 1}, {"id": 2}]),
+ _http_error(404),
+ _page([{"id": 20, "team_id": 2}]),
+ ]
+ rows, _, _ = _run_get_rows(monkeypatch, "team_memberships", responses)
+ assert [r["id"] for r in rows] == [20]
+
+ def test_child_denial_is_not_swallowed(self, monkeypatch: Any) -> None:
+ responses: Sequence[MagicMock | Exception] = [_page([{"id": 1}]), _http_error(403)]
+ with pytest.raises(requests.HTTPError):
+ _run_get_rows(monkeypatch, "team_memberships", responses)
+
+
class TestResumeCheckpoints:
def test_resumes_from_saved_url(self, monkeypatch: Any) -> None:
saved_url = f"{BASE_URL}/v1/incidents/secrets?cursor=abc&per_page=100"
@@ -323,6 +389,23 @@ class TestCheckEndpointAccess:
def test_network_error_does_not_block_the_table(self) -> None:
assert self._probe(requests.ConnectionError("boom")) is None
+ @parameterized.expand(
+ [
+ ("team_memberships", "/v1/teams"),
+ ("secret_incident_activity_logs", "/v1/incidents/secrets"),
+ ]
+ )
+ def test_fan_out_endpoints_probe_their_parent(self, endpoint: str, parent_path: str) -> None:
+ # The child path needs a real parent id; probing the placeholder would 404 and hide a
+ # missing scope. The parent carries the same scope.
+ response = MagicMock()
+ response.status_code = 200
+ session = MagicMock()
+ session.get.return_value = response
+ with patch.object(gitguardian, "make_tracked_session", return_value=session):
+ check_endpoint_access("gg_sat_x", BASE_URL, endpoint)
+ assert urlsplit(session.get.call_args.args[0]).path == parent_path
+
class TestFetchPageRetries:
@parameterized.expand(
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gitguardian/tests/test_gitguardian_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gitguardian/tests/test_gitguardian_source.py
index b23339c80018..df21f5c979ff 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gitguardian/tests/test_gitguardian_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gitguardian/tests/test_gitguardian_source.py
@@ -5,7 +5,18 @@ from parameterized import parameterized
from products.warehouse_sources.backend.temporal.data_imports.sources.gitguardian import source as source_module
from products.warehouse_sources.backend.temporal.data_imports.sources.gitguardian.source import GitguardianSource
-ALL_ENDPOINTS = {"secret_incidents", "secret_occurrences", "sources", "honeytokens", "members", "teams"}
+ALL_ENDPOINTS = {
+ "secret_incidents",
+ "secret_occurrences",
+ "secret_incident_activity_logs",
+ "secret_detectors",
+ "sources",
+ "honeytokens",
+ "honeytoken_events",
+ "members",
+ "teams",
+ "team_memberships",
+}
class TestGitguardianSourceConfig:
@@ -25,7 +36,7 @@ class TestGitguardianSchemas:
for name in ("secret_incidents", "secret_occurrences"):
assert schemas[name].supports_incremental is True
assert [f["field"] for f in schemas[name].incremental_fields] == ["date"]
- for name in ("sources", "honeytokens", "members", "teams"):
+ for name in ALL_ENDPOINTS - {"secret_incidents", "secret_occurrences"}:
assert schemas[name].supports_incremental is False
def test_names_filter(self) -> None: