From 8f09e6e068ef9aee31bbae50b420334b92c24327 Mon Sep 17 00:00:00 2001 From: candiduslynx Date: Mon, 13 Feb 2023 09:43:50 +0200 Subject: [PATCH] Add `request_account_id` & `request_region` to `aws_securityhub_findings` PK --- .../docs/tables/aws_securityhub_findings.md | 11 ++++++----- .../services/securityhub/findings.go | 19 +++++++++++-------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/plugins/source/aws/docs/tables/aws_securityhub_findings.md b/plugins/source/aws/docs/tables/aws_securityhub_findings.md index 12447bf909d..af80bc34fca 100644 --- a/plugins/source/aws/docs/tables/aws_securityhub_findings.md +++ b/plugins/source/aws/docs/tables/aws_securityhub_findings.md @@ -1,9 +1,10 @@ # Table: aws_securityhub_findings -https://docs.aws.amazon.com/securityhub/1.0/APIReference/API_GetFindings.html. -The 'request_account_id' and 'request_region' columns are added to show the account and region of where the request was made from. This is useful when multi region and account aggregation is enabled. +https://docs.aws.amazon.com/securityhub/1.0/APIReference/API_GetFindings.html. +The `request_account_id` and `request_region` columns are added to show the account and region of where the request was made from. +This is useful when multi region and account aggregation is enabled. -The composite primary key for this table is (**aws_account_id**, **created_at**, **description**, **generator_id**, **id**, **product_arn**, **schema_version**, **title**, **region**). +The composite primary key for this table is (**request_account_id**, **request_region**, **aws_account_id**, **created_at**, **description**, **generator_id**, **id**, **product_arn**, **schema_version**, **title**, **region**). ## Columns @@ -13,8 +14,8 @@ The composite primary key for this table is (**aws_account_id**, **created_at**, |_cq_sync_time|Timestamp| |_cq_id|UUID| |_cq_parent_id|UUID| -|request_account_id|String| -|request_region|String| +|request_account_id (PK)|String| +|request_region (PK)|String| |aws_account_id (PK)|String| |created_at (PK)|String| |description (PK)|String| diff --git a/plugins/source/aws/resources/services/securityhub/findings.go b/plugins/source/aws/resources/services/securityhub/findings.go index 5127a6b9cba..4043f9ccdfc 100644 --- a/plugins/source/aws/resources/services/securityhub/findings.go +++ b/plugins/source/aws/resources/services/securityhub/findings.go @@ -10,21 +10,24 @@ import ( func Findings() *schema.Table { return &schema.Table{ Name: "aws_securityhub_findings", - Description: `https://docs.aws.amazon.com/securityhub/1.0/APIReference/API_GetFindings.html. -The 'request_account_id' and 'request_region' columns are added to show the account and region of where the request was made from. This is useful when multi region and account aggregation is enabled.`, + Description: `https://docs.aws.amazon.com/securityhub/1.0/APIReference/API_GetFindings.html. +` + "The `request_account_id` and `request_region` columns are added to show the account and region of where the request was made from." + ` +This is useful when multi region and account aggregation is enabled.`, Resolver: fetchFindings, Transform: transformers.TransformWithStruct(&types.AwsSecurityFinding{}, transformers.WithPrimaryKeys("AwsAccountId", "Region", "CreatedAt", "Description", "GeneratorId", "Id", "ProductArn", "SchemaVersion", "Title")), Multiplex: client.ServiceAccountRegionMultiplexer("securityhub"), Columns: []schema.Column{ { - Name: "request_account_id", - Type: schema.TypeString, - Resolver: client.ResolveAWSAccount, + Name: "request_account_id", + Type: schema.TypeString, + Resolver: client.ResolveAWSAccount, + CreationOptions: schema.ColumnCreationOptions{PrimaryKey: true}, }, { - Name: "request_region", - Type: schema.TypeString, - Resolver: client.ResolveAWSRegion, + Name: "request_region", + Type: schema.TypeString, + Resolver: client.ResolveAWSRegion, + CreationOptions: schema.ColumnCreationOptions{PrimaryKey: true}, }, }, }