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.

4.7 KB
Raw Blame
from typing import Optional

from products.warehouse_sources.sources.sdk import IncrementalField, frozen


@frozen
class SecureframeEndpointConfig:
    name: str
    path: str
    primary_key: str = "id"
    # Stable creation-time field used for datetime partitioning. Never an updated_at-style
    # field, which would rewrite partitions on every sync.
    partition_key: Optional[str] = None
    # Parent endpoints that each own a child list at `{parent path}/{parent id}{path}`. The rows of
    # every parent kind land in this one table.
    fanout_parents: tuple[str, ...] = ()


# Every list endpoint in the Secureframe public API paginates with `page`/`per_page`
# (per_page max 100) and wraps rows in JSON:API-style envelopes. The API exposes no
# server-side timestamp filter (only a Lucene `q` search whose date-range semantics are
# undocumented), so every endpoint is full refresh only.
SECUREFRAME_ENDPOINTS: dict[str, SecureframeEndpointConfig] = {
    "controls": SecureframeEndpointConfig(
        name="controls",
        path="/controls",
        partition_key="created_at",
    ),
    "tests": SecureframeEndpointConfig(
        name="tests",
        path="/tests",
        partition_key="created_at",
    ),
    "users": SecureframeEndpointConfig(
        name="users",
        path="/users",
        partition_key="created_at",
    ),
    "user_accounts": SecureframeEndpointConfig(
        name="user_accounts",
        path="/user_accounts",
        partition_key="created_at",
    ),
    "devices": SecureframeEndpointConfig(
        name="devices",
        path="/devices",
        partition_key="created_at",
    ),
    # The legacy vendor list. Its schema has no created_at, so no partitioning.
    "vendors": SecureframeEndpointConfig(
        name="vendors",
        path="/vendors",
    ),
    "tprm_vendors": SecureframeEndpointConfig(
        name="tprm_vendors",
        path="/tprm/vendors",
        partition_key="created_at",
    ),
    "frameworks": SecureframeEndpointConfig(
        name="frameworks",
        path="/frameworks",
        partition_key="created_at",
    ),
    "framework_requirements": SecureframeEndpointConfig(
        name="framework_requirements",
        path="/framework_requirements",
        partition_key="created_at",
    ),
    "risks": SecureframeEndpointConfig(
        name="risks",
        path="/risks",
        partition_key="created_at",
    ),
    "repositories": SecureframeEndpointConfig(
        name="repositories",
        path="/repositories",
        partition_key="created_at",
    ),
    # Integration connection schema exposes only id/name/status/vendor_name/updated_at.
    "integration_connections": SecureframeEndpointConfig(
        name="integration_connections",
        path="/integration_connections",
    ),
    "cloud_resources": SecureframeEndpointConfig(
        name="cloud_resources",
        path="/cloud_resources",
        partition_key="created_at",
    ),
    "poam_items": SecureframeEndpointConfig(
        name="poam_items",
        path="/poam_items",
        partition_key="created_at",
    ),
    "ssp_policies": SecureframeEndpointConfig(
        name="ssp_policies",
        path="/ssp_policies",
        partition_key="created_at",
    ),
    "comments": SecureframeEndpointConfig(
        name="comments",
        path="/comments",
        partition_key="created_at",
    ),
    "trust_center_requests": SecureframeEndpointConfig(
        name="trust_center_requests",
        path="/trust_center_requests",
        partition_key="created_at",
    ),
    "ssp_reports": SecureframeEndpointConfig(
        name="ssp_reports",
        path="/ssp_reports",
        partition_key="created_at",
    ),
    "ssp_report_sections": SecureframeEndpointConfig(
        name="ssp_report_sections",
        path="/ssp_report_sections",
        partition_key="created_at",
    ),
    # The section block schema has no created_at, so no partitioning.
    "ssp_report_section_blocks": SecureframeEndpointConfig(
        name="ssp_report_section_blocks",
        path="/ssp_report_section_blocks",
    ),
    "ssp_report_assessment_objectives": SecureframeEndpointConfig(
        name="ssp_report_assessment_objectives",
        path="/ssp_report_assessment_objectives",
        partition_key="created_at",
    ),
    # Secureframe lists framework scopes only per asset, so this fans out over every device, cloud
    # resource and repository. Each row carries its own asset_type and asset_id.
    "framework_asset_scopes": SecureframeEndpointConfig(
        name="framework_asset_scopes",
        path="/framework_asset_scopes",
        partition_key="created_at",
        fanout_parents=("devices", "cloud_resources", "repositories"),
    ),
}

ENDPOINTS = tuple(SECUREFRAME_ENDPOINTS.keys())

INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {}