: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
from typing import Optional, cast
from products.warehouse_sources.sources.intruder._config import IntruderSourceConfig
from products.warehouse_sources.sources.intruder.intruder import (
IntruderResumeConfig,
intruder_source,
validate_credentials as validate_intruder_credentials,
)
from products.warehouse_sources.sources.intruder.settings import ENDPOINTS, INCREMENTAL_FIELDS
from products.warehouse_sources.sources.sdk import (
NOT_DETECTABLE,
CanonicalDescriptions,
DataWarehouseSourceCategory,
ExternalDataSourceType,
FieldType,
ReleaseStatus,
ResumableSource,
ResumableSourceManager,
SourceConfig,
SourceFieldInputConfig,
SourceFieldInputConfigType,
SourceInputs,
SourceRegistry,
SourceResponse,
SourceSchema,
build_endpoint_schemas,
)
@SourceRegistry.register
class IntruderSource(ResumableSource[IntruderSourceConfig, IntruderResumeConfig]):
codebase_detection = NOT_DETECTABLE
lists_tables_without_credentials = True # static endpoint catalog — safe for public docs
supported_versions = ("v1",)
default_version = "v1"
api_docs_url = "https://developers.intruder.io/docs/versioning"
@property
def source_type(self) -> ExternalDataSourceType:
return ExternalDataSourceType.INTRUDER
@property
def get_source_config(self) -> SourceConfig:
return SourceConfig(
name=ExternalDataSourceType.INTRUDER,
category=DataWarehouseSourceCategory.ENGINEERING___MONITORING,
label="Intruder",
releaseStatus=ReleaseStatus.BETA,
caption="""Enter your Intruder API access token to pull your attack-surface and vulnerability data into the PostHog Data warehouse.
Create an access token under **My account > API Access Tokens** in your [Intruder account](https://portal.intruder.io/). The token is shown only once, so copy it immediately. API scanning of targets requires the appropriate Intruder plan license.""",
iconPath="/static/services/intruder.png",
docsUrl="https://posthog.com/docs/cdp/sources/intruder",
fields=cast(
list[FieldType],
[
SourceFieldInputConfig(
name="access_token",
label="API access token",
type=SourceFieldInputConfigType.PASSWORD,
required=True,
placeholder="",
secret=True,
),
],
),
)
def get_canonical_descriptions(self) -> CanonicalDescriptions:
from products.warehouse_sources.sources.intruder.canonical_descriptions import (
CANONICAL_DESCRIPTIONS, # noqa: PLC0415
)
return CANONICAL_DESCRIPTIONS
def get_non_retryable_errors(self) -> dict[str, str | None]:
return {
# An invalid or expired access token surfaces as a requests HTTPError when the client
# calls `raise_for_status()`. Retrying can never satisfy a credential problem, so stop the
# sync. Match the stable status text and base host, not the per-request path.
"401 Client Error: Unauthorized for url: https://api.intruder.io": "Your Intruder access token is invalid or has expired. Create a new token under My account > API Access Tokens in Intruder, then reconnect.",
"403 Client Error: Forbidden for url: https://api.intruder.io": "Your Intruder access token does not have permission to read this data. Check the token's permissions in Intruder, then reconnect.",
}
def get_schemas(
self,
config: IntruderSourceConfig,
team_id: int,
with_counts: bool = False,
names: list[str] | None = None,
force_refresh: bool = False,
api_version: str | None = None,
) -> list[SourceSchema]:
# Intruder is full refresh only: no list endpoint exposes a verifiable server-side
# created/updated-after cursor we can persist between runs, so nothing supports incremental
# (empty INCREMENTAL_FIELDS → supports_incremental/append both False).
return build_endpoint_schemas(ENDPOINTS, INCREMENTAL_FIELDS, names)
def validate_credentials(
self,
config: IntruderSourceConfig,
team_id: int,
schema_name: Optional[str] = None,
api_version: str | None = None,
) -> tuple[bool, str | None]:
if validate_intruder_credentials(config.access_token):
return True, None
return False, "Invalid Intruder API access token"
def get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[IntruderResumeConfig]:
return ResumableSourceManager[IntruderResumeConfig](inputs, IntruderResumeConfig)
def source_for_pipeline(
self,
config: IntruderSourceConfig,
resumable_source_manager: ResumableSourceManager[IntruderResumeConfig],
inputs: SourceInputs,
) -> SourceResponse:
return intruder_source(
access_token=config.access_token,
endpoint=inputs.schema_name,
team_id=inputs.team_id,
job_id=inputs.job_id,
resumable_source_manager=resumable_source_manager,
)