: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 aws macie resource profile and usage tables (#117711)
Tom Owersdbc76e459348
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 c8cd2971f35d..b42864aba8b9 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@@ -1236,10 +1236,10 @@ Today (4): `buckets`, `classification_jobs`, `findings`, `members`Diffed against: <https://raw.githubusercontent.com/boto/botocore/develop/botocore/data/macie2/2020-01-01/service-2.json>-- [ ] `Resource sensitivity profiles (GetResourceProfile, GET /resource-profiles)` — counts analyzed, sensitive, and skipped objects, which bucket inventory and findings cannot reconstruct (high)-- [ ] `Resource profile detections (ListResourceProfileDetections, GET /resource-profiles/detections)` — shows sensitive data types and occurrence counts for each bucket (high)-- [ ] `Resource profile artifacts (ListResourceProfileArtifacts, GET /resource-profiles/artifacts)` — shows selected objects and analysis outcomes, including skipped objects and objects without sensitive data (medium)-- [ ] `Usage statistics (GetUsageStatistics, POST /usage/statistics)` — reports classification usage, quotas, and estimated costs by account (medium)+- [x] `Resource sensitivity profiles (GetResourceProfile, GET /resource-profiles)` — counts analyzed, sensitive, and skipped objects, which bucket inventory and findings cannot reconstruct (high)+- [x] `Resource profile detections (ListResourceProfileDetections, GET /resource-profiles/detections)` — shows sensitive data types and occurrence counts for each bucket (high)+- [x] `Resource profile artifacts (ListResourceProfileArtifacts, GET /resource-profiles/artifacts)` — shows selected objects and analysis outcomes, including skipped objects and objects without sensitive data (medium)+- [x] `Usage statistics (GetUsageStatistics, POST /usage/statistics)` — reports classification usage, quotas, and estimated costs by account (medium)Note: Compared the official Macie V2 botocore operation model with the static endpoint map and extraction code. Findings already call GetFindings; bucket inventory already includes sensitivity scores, so scores alone are not a gap. Profile endpoints require bucket ARN traversal and automated discovery; artifacts expose a limited sample rather than a complete object inventory. Classification jobs currently contain list summaries; raw sensitive data retrieval, filters, and setup endpoints were excluded.diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/aws_macie/aws_macie.py b/products/warehouse_sources/backend/temporal/data_imports/sources/aws_macie/aws_macie.pyindex d08611706171..742de0c17b28 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/aws_macie/aws_macie.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/aws_macie/aws_macie.py@@ -16,9 +16,11 @@ from botocore.serialize import create_serializerfrom posthog.dataclasses import frozenfrom products.warehouse_sources.backend.temporal.data_imports.sources.aws_macie.settings import (+ BUCKET_PAGE_SIZE,ERROR_MESSAGES,MACIE_API_VERSION,MACIE_ENDPOINTS,+ USAGE_TIME_RANGE,)from products.warehouse_sources.backend.temporal.data_imports.sources.common.http import make_tracked_sessionfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.http.transport import BoundedRetry@@ -36,6 +38,10 @@ class AwsMacieResumeConfig:next_token: str | None = Nonesince_ms: int | None = Nonecompleted: bool = False+ # The bucket ARNs of the page in progress, so a resume does not re-fetch a page that changed.+ bucket_arns: tuple[str, ...] = ()+ bucket_offset: int = 0+ bucket_page_token: str | None = Noneclass AwsMacieError(Exception):@@ -125,8 +131,11 @@ def normalize_row(endpoint: str, item: dict[str, Any], region: str) -> dict[str,return row-def list_payload(endpoint: str, since_ms: int | None, page_size: int) -> dict[str, Any]:- payload: dict[str, Any] = {"maxResults": page_size}+def list_payload(endpoint: str, since_ms: int | None, page_size: int | None) -> dict[str, Any]:+ payload: dict[str, Any] = {} if page_size is None else {"maxResults": page_size}+ if endpoint == "usage_statistics":+ payload["timeRange"] = USAGE_TIME_RANGE+ payload["sortBy"] = {"key": "accountId", "orderBy": "ASC"}if endpoint == "members":payload["onlyAssociated"] = "false"if endpoint == "findings":@@ -136,6 +145,94 @@ def list_payload(endpoint: str, since_ms: int | None, page_size: int) -> dict[streturn payload+def bucket_page_payload(page_token: str | None, page_size: int = BUCKET_PAGE_SIZE) -> dict[str, Any]:+ payload: dict[str, Any] = {+ "maxResults": page_size,+ "sortCriteria": {"attributeName": "bucketName", "orderBy": "ASC"},+ }+ if page_token:+ payload["nextToken"] = page_token+ return payload+++def request_bucket_profile(+ client: AwsMacieClient, endpoint: str, bucket_arn: str, next_token: str | None, page_size: int | None+) -> dict[str, Any]:+ payload = {"resourceArn": bucket_arn, **list_payload(endpoint, None, page_size)}+ if next_token:+ payload["nextToken"] = next_token+ try:+ return client.request(MACIE_ENDPOINTS[endpoint].operation, payload)+ except AwsMacieError as error:+ # Macie has no profile for a bucket until automated discovery analyzes it.+ if error.code == "ResourceNotFoundException":+ return {}+ raise+++def get_bucket_rows(+ client: AwsMacieClient,+ endpoint: str,+ manager: ResumableSourceManager[AwsMacieResumeConfig],+ state: AwsMacieResumeConfig,+ region: str,+) -> Iterator[list[dict[str, Any]]]:+ setting = MACIE_ENDPOINTS[endpoint]+ bucket_arns = list(state.bucket_arns)+ offset, child_token = state.bucket_offset, state.next_token+ # With saved bucket ARNs this is the token after that page, otherwise the token of the page to fetch.+ page_token = state.bucket_page_token+ page_loaded = bool(bucket_arns)+ while True:+ if page_loaded:+ next_page_token = page_token+ else:+ manager.save_state(AwsMacieResumeConfig(bucket_page_token=page_token))+ manager.safe_point()+ page = client.request("DescribeBuckets", bucket_page_payload(page_token))+ next_page_token = page.get("nextToken") or None+ if next_page_token and next_page_token == page_token:+ raise AwsMacieError("RepeatedPaginationToken", "AWS returned the same page token twice.")+ bucket_arns = [bucket["bucketArn"] for bucket in page.get("buckets") or [] if bucket.get("bucketArn")]+ offset, child_token = 0, None+ page_loaded = False+ for index in range(offset, len(bucket_arns)):+ bucket_arn = bucket_arns[index]+ while True:+ response = request_bucket_profile(client, endpoint, bucket_arn, child_token, setting.page_size)+ if setting.result_key:+ items = response.get(setting.result_key) or []+ next_token = response.get("nextToken") or None+ else:+ items, next_token = ([response] if response else []), None+ if next_token and next_token == child_token:+ raise AwsMacieError("RepeatedPaginationToken", "AWS returned the same page token twice.")+ rows = [{**normalize_row(endpoint, item, region), "bucket_arn": bucket_arn} for item in items]+ if next_token or index + 1 < len(bucket_arns):+ resume = AwsMacieResumeConfig(+ next_token=next_token,+ bucket_arns=tuple(bucket_arns),+ bucket_offset=index if next_token else index + 1,+ bucket_page_token=next_page_token,+ )+ elif next_page_token:+ resume = AwsMacieResumeConfig(bucket_page_token=next_page_token)+ else:+ resume = AwsMacieResumeConfig(completed=True)+ manager.save_state(resume)+ if rows:+ yield rows+ manager.safe_point()+ child_token = next_token+ if next_token is None:+ break+ if next_page_token is None:+ break+ page_token = next_page_token+ manager.save_state(AwsMacieResumeConfig(completed=True))+ manager.safe_point()++def get_rows(config: AwsMacieSourceConfig,endpoint: str,@@ -151,6 +248,9 @@ def get_rows(returnclient = AwsMacieClient(config, api_version)try:+ if setting.per_bucket:+ yield from get_bucket_rows(client, endpoint, manager, state, config.region)+ returnwhile True:payload = list_payload(endpoint, state.since_ms, setting.page_size)if state.next_token:@@ -168,6 +268,8 @@ def get_rows(if next_token and next_token == state.next_token:raise AwsMacieError("RepeatedPaginationToken", "AWS returned the same page token twice.")rows = [normalize_row(endpoint, item, config.region) for item in items]+ if endpoint == "usage_statistics":+ rows = [{**row, "time_range": page.get("timeRange")} for row in rows]state = AwsMacieResumeConfig(next_token=next_token, since_ms=state.since_ms, completed=next_token is None)manager.save_state(state)if rows:@@ -190,6 +292,12 @@ def validate_credentials(except ValueError as error:return False, str(error)try:+ if MACIE_ENDPOINTS[endpoint].per_bucket:+ buckets = client.request("DescribeBuckets", bucket_page_payload(None, 1)).get("buckets") or []+ if buckets and buckets[0].get("bucketArn"):+ page_size = 1 if MACIE_ENDPOINTS[endpoint].page_size else None+ request_bucket_profile(client, endpoint, buckets[0]["bucketArn"], None, page_size)+ return True, Nonepage = client.request(MACIE_ENDPOINTS[endpoint].operation, list_payload(endpoint, None, 1))if schema_name == "findings" and page.get("findingIds"):client.request("GetFindings", {"findingIds": page["findingIds"][:1]})diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/aws_macie/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/aws_macie/canonical_descriptions.pyindex 51e7219661e5..22dd0b588bd9 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/aws_macie/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/aws_macie/canonical_descriptions.py@@ -65,4 +65,53 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"updated_at": "The UTC time when the account status or settings last changed.",},},+ "resource_profiles": {+ "description": "Sensitivity profiles that automated sensitive data discovery keeps for each S3 bucket.",+ "docs_url": "https://docs.aws.amazon.com/macie/latest/APIReference/resource-profiles.html",+ "columns": {+ "bucket_arn": "The Amazon Resource Name of the bucket.",+ "region": "The AWS region selected for this sync.",+ "profile_updated_at": "The UTC time when Macie last updated the bucket profile.",+ "sensitivity_score": "The current sensitivity score for the bucket, from -1 to 100.",+ "sensitivity_score_overridden": "Whether a user manually set the sensitivity score.",+ "statistics": "Counts of classified, sensitive, and skipped objects, bytes classified, and detections.",+ },+ },+ "resource_profile_detections": {+ "description": "Types and amounts of sensitive data that automated discovery found in each S3 bucket.",+ "docs_url": "https://docs.aws.amazon.com/macie/latest/APIReference/resource-profiles-detections.html",+ "columns": {+ "bucket_arn": "The Amazon Resource Name of the bucket.",+ "region": "The AWS region selected for this sync.",+ "id": "The managed or custom data identifier that detected the data.",+ "arn": "The Amazon Resource Name of the custom data identifier, for custom identifiers.",+ "name": "The name of the data identifier.",+ "type": "The identifier type: MANAGED or CUSTOM.",+ "count": "The total number of occurrences of the sensitive data.",+ "suppressed": "Whether the detection is excluded from the bucket sensitivity score.",+ },+ },+ "resource_profile_artifacts": {+ "description": "S3 objects that automated discovery selected for analysis in each bucket.",+ "docs_url": "https://docs.aws.amazon.com/macie/latest/APIReference/resource-profiles-artifacts.html",+ "columns": {+ "bucket_arn": "The Amazon Resource Name of the bucket.",+ "region": "The AWS region selected for this sync.",+ "arn": "The Amazon Resource Name of the S3 object.",+ "classification_result_status": "The analysis result: COMPLETE, PARTIAL, or SKIPPED.",+ "sensitive": "Whether Macie found sensitive data in the object.",+ },+ },+ "usage_statistics": {+ "description": "Macie usage, quotas, and estimated costs for each account.",+ "docs_url": "https://docs.aws.amazon.com/macie/latest/APIReference/usage-statistics.html",+ "columns": {+ "account_id": "The AWS account the usage applies to.",+ "region": "The AWS region selected for this sync.",+ "time_range": "The period the usage covers.",+ "usage": "Estimated cost, currency, quota, and usage type for each Macie feature.",+ "free_trial_start_date": "The UTC date when the Macie free trial started for the account.",+ "automated_discovery_free_trial_start_date": "The UTC date when the automated discovery free trial started.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/aws_macie/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/aws_macie/settings.pyindex cbc26301df1e..7c9fe758b42f 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/aws_macie/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/aws_macie/settings.py@@ -12,8 +12,10 @@ class MacieEndpoint:operation: strresult_key: strprimary_keys: tuple[str, ...]- page_size: int = 50+ page_size: int | None = 50timestamp_columns: tuple[str, ...] = ()+ # Called once per bucket from DescribeBuckets, with the bucket ARN as resourceArn.+ per_bucket: bool = FalseMACIE_ENDPOINTS = {@@ -42,7 +44,38 @@ MACIE_ENDPOINTS = {page_size=25,timestamp_columns=("invited_at", "updated_at"),),+ "resource_profiles": MacieEndpoint(+ operation="GetResourceProfile",+ result_key="",+ primary_keys=("bucket_arn",),+ page_size=None,+ timestamp_columns=("profile_updated_at",),+ per_bucket=True,+ ),+ "resource_profile_detections": MacieEndpoint(+ operation="ListResourceProfileDetections",+ result_key="detections",+ primary_keys=("bucket_arn", "id"),+ page_size=25,+ per_bucket=True,+ ),+ "resource_profile_artifacts": MacieEndpoint(+ operation="ListResourceProfileArtifacts",+ result_key="artifacts",+ primary_keys=("bucket_arn", "arn"),+ page_size=None,+ per_bucket=True,+ ),+ "usage_statistics": MacieEndpoint(+ operation="GetUsageStatistics",+ result_key="records",+ primary_keys=("region", "account_id"),+ page_size=25,+ timestamp_columns=("free_trial_start_date", "automated_discovery_free_trial_start_date"),+ ),}+BUCKET_PAGE_SIZE = 50+USAGE_TIME_RANGE = "MONTH_TO_DATE"ENDPOINTS = tuple(MACIE_ENDPOINTS)INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {"findings": [incremental_field("updated_at")]}ENDPOINT_DESCRIPTIONS = {@@ -50,11 +83,16 @@ ENDPOINT_DESCRIPTIONS = {"buckets": "S3 bucket inventory, with security settings, object counts, and discovery coverage.","classification_jobs": "Sensitive data discovery jobs, with their status and bucket selection settings.","members": "Accounts associated with the Macie administrator, including former members.",+ "resource_profiles": "Sensitivity profile for each S3 bucket, with counts of analyzed, sensitive, and skipped objects.",+ "resource_profile_detections": "Types of sensitive data that automated discovery found in each S3 bucket, with occurrence counts.",+ "resource_profile_artifacts": "S3 objects that automated discovery selected in each bucket, with the analysis result.",+ "usage_statistics": "Month-to-date Macie usage, quotas, and estimated costs for each account.",}PERMISSION_MESSAGE = ("Grant the required Macie read permissions: macie2:ListFindings, macie2:GetFindings, "- "macie2:DescribeBuckets, macie2:ListClassificationJobs, and macie2:ListMembers. "+ "macie2:DescribeBuckets, macie2:ListClassificationJobs, macie2:ListMembers, macie2:GetResourceProfile, "+ "macie2:ListResourceProfileDetections, macie2:ListResourceProfileArtifacts, and macie2:GetUsageStatistics. ""Enable Macie in the selected region.")ERROR_MESSAGES = {diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/aws_macie/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/aws_macie/source.pyindex 2bc3898993a5..7fe0700b37a9 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/aws_macie/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/aws_macie/source.py@@ -116,11 +116,14 @@ class AwsMacieSource(ResumableSource[AwsMacieSourceConfig, AwsMacieResumeConfig]category=DataWarehouseSourceCategory.ENGINEERING___MONITORING,label="AWS Macie",caption=(- "Sync Amazon Macie findings, S3 bucket inventory, discovery jobs, and member accounts. "- "Enable Macie in the region you select.\n\n"+ "Sync Amazon Macie findings, S3 bucket inventory, bucket sensitivity profiles, discovery jobs, "+ "member accounts, and usage. Enable Macie in the region you select.\n\n""Grant these IAM permissions for the tables you select: ""`macie2:ListFindings`, `macie2:GetFindings`, `macie2:DescribeBuckets`, "- "`macie2:ListClassificationJobs`, and `macie2:ListMembers`. "+ "`macie2:ListClassificationJobs`, `macie2:ListMembers`, `macie2:GetResourceProfile`, "+ "`macie2:ListResourceProfileDetections`, `macie2:ListResourceProfileArtifacts`, and "+ "`macie2:GetUsageStatistics`. "+ "The resource profile tables need automated sensitive data discovery turned on. ""Use credentials from the Macie administrator account to sync members."),iconPath="/static/services/aws_macie.png",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/aws_macie/tests/test_aws_macie.py b/products/warehouse_sources/backend/temporal/data_imports/sources/aws_macie/tests/test_aws_macie.pyindex 27fdea1408a0..5c794dd0c420 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/aws_macie/tests/test_aws_macie.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/aws_macie/tests/test_aws_macie.py@@ -179,6 +179,7 @@ def test_findings_filter_and_hydration(config: AwsMacieSourceConfig, session: Mo("buckets", "buckets", {"bucketArn": "arn:aws:s3:::example-bucket", "bucketCreatedAt": "2025-01-01T00:00:00Z"}),("classification_jobs", "items", {"jobId": "job-1", "createdAt": "2025-01-01T00:00:00Z"}),("members", "members", {"accountId": "111111111111", "updatedAt": "2025-01-01T00:00:00Z"}),+ ("usage_statistics", "records", {"accountId": "111111111111", "freeTrialStartDate": "2025-01-01T00:00:00Z"}),],)@pytest.mark.parametrize("terminal_token", [None, ""])@@ -208,10 +209,104 @@ def test_empty_page_continues_to_terminal_page("nextToken": ("page-two",),"onlyAssociated": ("false",),}+ elif endpoint == "usage_statistics":+ assert result.requests[1].json() == {+ "maxResults": 25,+ "nextToken": "page-two",+ "timeRange": "MONTH_TO_DATE",+ "sortBy": {"key": "accountId", "orderBy": "ASC"},+ }else:assert result.requests[1].json() == {"maxResults": 50, "nextToken": "page-two"}+BUCKET_A = "arn:aws:s3:::bucket-a"+BUCKET_B = "arn:aws:s3:::bucket-b"+BUCKET_C = "arn:aws:s3:::bucket-c"+NOT_FOUND = ScriptedResponse(+ json={"message": "Resource not found."},+ status=404,+ headers={"x-amzn-ErrorType": "ResourceNotFoundException:http://example.com"},+)+++def test_bucket_fan_out_walks_buckets_and_child_pages(driver: SourceDriver) -> None:+ result = driver.run(+ "resource_profile_detections",+ [+ ScriptedResponse(json={"buckets": [{"bucketArn": BUCKET_A}, {"bucketArn": BUCKET_B}], "nextToken": "b2"}),+ ScriptedResponse(json={"detections": [{"id": "CREDIT_CARD_NUMBER", "count": 3}], "nextToken": "d2"}),+ ScriptedResponse(json={"detections": [{"id": "AWS_CREDENTIALS", "count": 1}]}),+ NOT_FOUND,+ ScriptedResponse(json={"buckets": [{"bucketArn": BUCKET_C}]}),+ ScriptedResponse(json={"detections": [{"id": "CREDIT_CARD_NUMBER", "count": 7}]}),+ ],+ )+ assert result.raised is None+ assert [(row["bucket_arn"], row["id"], row["count"]) for row in result.rows] == [+ (BUCKET_A, "CREDIT_CARD_NUMBER", 3),+ (BUCKET_A, "AWS_CREDENTIALS", 1),+ (BUCKET_C, "CREDIT_CARD_NUMBER", 7),+ ]+ assert [request.path for request in result.requests] == [+ "/datasources/s3",+ "/resource-profiles/detections",+ "/resource-profiles/detections",+ "/resource-profiles/detections",+ "/datasources/s3",+ "/resource-profiles/detections",+ ]+ assert result.requests[0].json() == {+ "maxResults": 50,+ "sortCriteria": {"attributeName": "bucketName", "orderBy": "ASC"},+ }+ assert result.requests[2].query == {"resourceArn": (BUCKET_A,), "maxResults": ("25",), "nextToken": ("d2",)}+ assert result.requests[3].query == {"resourceArn": (BUCKET_B,), "maxResults": ("25",)}+ assert result.requests[4].json()["nextToken"] == "b2"+ assert [+ (tuple(state.bucket_arns), state.bucket_offset, state.bucket_page_token, state.next_token, state.completed)+ for state in result.saved_states+ ] == [+ ((), 0, None, None, False),+ ((BUCKET_A, BUCKET_B), 0, "b2", "d2", False),+ ((BUCKET_A, BUCKET_B), 1, "b2", None, False),+ ((), 0, "b2", None, False),+ ((), 0, "b2", None, False),+ ((), 0, None, None, True),+ ((), 0, None, None, True),+ ]+ assert result.final_state is not None and result.final_state.completed+++ "endpoint,body,expected",+ [+ (+ "resource_profiles",+ {"profileUpdatedAt": "2025-01-01T00:00:00Z", "statistics": {"totalItemsSkipped": 2}},+ {"profile_updated_at": dt.datetime(2025, 1, 1, tzinfo=dt.UTC), "statistics": {"totalItemsSkipped": 2}},+ ),+ (+ "resource_profile_artifacts",+ {"artifacts": [{"arn": f"{BUCKET_B}/key.csv", "classificationResultStatus": "SKIPPED"}]},+ {"arn": f"{BUCKET_B}/key.csv", "classification_result_status": "SKIPPED"},+ ),+ ],+)+def test_bucket_fan_out_resumes_from_saved_bucket_page(+ driver: SourceDriver, endpoint: str, body: dict[str, Any], expected: dict[str, Any]+) -> None:+ result = driver.run(+ endpoint,+ [ScriptedResponse(json=body)],+ resume_state=AwsMacieResumeConfig(bucket_arns=(BUCKET_A, BUCKET_B), bucket_offset=1),+ )+ assert result.raised is None+ assert [request.query for request in result.requests] == [{"resourceArn": (BUCKET_B,)}]+ assert result.rows == [{**expected, "bucket_arn": BUCKET_B, "region": "eu-west-1"}]+ assert result.final_state is not None and result.final_state.completed++def test_resume_preserves_original_filter(driver: SourceDriver) -> None:result = driver.run("findings",@@ -289,6 +384,30 @@ def test_access_denied_at_create_and_table_selection(assert len(network.requests_log) == 1+ "schema_name,child,expected",+ [+ ("resource_profile_artifacts", NOT_FOUND, True),+ (+ "resource_profiles",+ ScriptedResponse(+ json={"message": "Not authorized"},+ status=403,+ headers={"x-amzn-ErrorType": "AccessDeniedException"},+ ),+ False,+ ),+ ],+)+def test_bucket_profile_permission_probe(+ config: AwsMacieSourceConfig, schema_name: str, child: ScriptedResponse, expected: bool+) -> None:+ with scripted_network([ScriptedResponse(json={"buckets": [{"bucketArn": BUCKET_A}]}), child]) as network:+ valid, _ = validate_credentials(config, schema_name)+ assert valid is expected+ assert network.requests_log[1].query == {"resourceArn": (BUCKET_A,)}++def test_findings_permission_probe_reads_details(config: AwsMacieSourceConfig) -> None:with scripted_network([