From 9de84a029f8fe76eb796a13cbd6f6fc92371e0a7 Mon Sep 17 00:00:00 2001 From: vjeffrey Date: Thu, 9 Jan 2025 13:13:17 -0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20add=20encryption=20to=20gcp=20stora?= =?UTF-8?q?ge=20bucket=20resource=20(#5077)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- providers/gcp/resources/gcp.lr | 2 ++ providers/gcp/resources/gcp.lr.go | 12 ++++++++++++ providers/gcp/resources/gcp.lr.manifest.yaml | 2 ++ providers/gcp/resources/storage.go | 5 +++++ 4 files changed, 21 insertions(+) diff --git a/providers/gcp/resources/gcp.lr b/providers/gcp/resources/gcp.lr index d95163eff6..3cb337a610 100644 --- a/providers/gcp/resources/gcp.lr +++ b/providers/gcp/resources/gcp.lr @@ -934,6 +934,8 @@ private gcp.project.storageService.bucket @defaults("id") { iamConfiguration dict // Retention policy retentionPolicy dict + // Encryption + encryption dict } // Google Cloud (GCP) SQL resources diff --git a/providers/gcp/resources/gcp.lr.go b/providers/gcp/resources/gcp.lr.go index ca4a8612c5..1d74f7eaaa 100644 --- a/providers/gcp/resources/gcp.lr.go +++ b/providers/gcp/resources/gcp.lr.go @@ -1783,6 +1783,9 @@ var getDataFields = map[string]func(r plugin.Resource) *plugin.DataRes{ "gcp.project.storageService.bucket.retentionPolicy": func(r plugin.Resource) *plugin.DataRes { return (r.(*mqlGcpProjectStorageServiceBucket).GetRetentionPolicy()).ToDataRes(types.Dict) }, + "gcp.project.storageService.bucket.encryption": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlGcpProjectStorageServiceBucket).GetEncryption()).ToDataRes(types.Dict) + }, "gcp.project.sqlService.projectId": func(r plugin.Resource) *plugin.DataRes { return (r.(*mqlGcpProjectSqlService).GetProjectId()).ToDataRes(types.String) }, @@ -5827,6 +5830,10 @@ var setDataFields = map[string]func(r plugin.Resource, v *llx.RawData) bool { r.(*mqlGcpProjectStorageServiceBucket).RetentionPolicy, ok = plugin.RawToTValue[interface{}](v.Value, v.Error) return }, + "gcp.project.storageService.bucket.encryption": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlGcpProjectStorageServiceBucket).Encryption, ok = plugin.RawToTValue[interface{}](v.Value, v.Error) + return + }, "gcp.project.sqlService.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { r.(*mqlGcpProjectSqlService).__id, ok = v.Value.(string) return @@ -13217,6 +13224,7 @@ type mqlGcpProjectStorageServiceBucket struct { IamPolicy plugin.TValue[[]interface{}] IamConfiguration plugin.TValue[interface{}] RetentionPolicy plugin.TValue[interface{}] + Encryption plugin.TValue[interface{}] } // createGcpProjectStorageServiceBucket creates a new instance of this resource @@ -13320,6 +13328,10 @@ func (c *mqlGcpProjectStorageServiceBucket) GetRetentionPolicy() *plugin.TValue[ return &c.RetentionPolicy } +func (c *mqlGcpProjectStorageServiceBucket) GetEncryption() *plugin.TValue[interface{}] { + return &c.Encryption +} + // mqlGcpProjectSqlService for the gcp.project.sqlService resource type mqlGcpProjectSqlService struct { MqlRuntime *plugin.Runtime diff --git a/providers/gcp/resources/gcp.lr.manifest.yaml b/providers/gcp/resources/gcp.lr.manifest.yaml index e891429541..8c8a3c3947 100755 --- a/providers/gcp/resources/gcp.lr.manifest.yaml +++ b/providers/gcp/resources/gcp.lr.manifest.yaml @@ -2441,6 +2441,8 @@ resources: gcp.project.storageService.bucket: fields: created: {} + encryption: + min_mondoo_version: 9.0.0 iamConfiguration: {} iamPolicy: {} id: {} diff --git a/providers/gcp/resources/storage.go b/providers/gcp/resources/storage.go index 2c25cbe5a4..af0aebef7a 100644 --- a/providers/gcp/resources/storage.go +++ b/providers/gcp/resources/storage.go @@ -100,6 +100,10 @@ func (g *mqlGcpProjectStorageService) buckets() ([]interface{}, error) { if err != nil { return nil, err } + enc, err := convert.JsonToDict(bucket.Encryption) + if err != nil { + return nil, err + } mqlInstance, err := CreateResource(g.MqlRuntime, "gcp.project.storageService.bucket", map[string]*llx.RawData{ "id": llx.StringData(bucket.Id), @@ -114,6 +118,7 @@ func (g *mqlGcpProjectStorageService) buckets() ([]interface{}, error) { "updated": llx.TimeDataPtr(updated), "iamConfiguration": llx.DictData(iamConfigurationDict), "retentionPolicy": llx.DictData(retentionPolicy), + "encryption": llx.DictData(enc), }) if err != nil { return nil, err