GoogleCloudPlatform / security-response-automation

Take automated actions against threats and vulnerabilities.
Apache License 2.0
208 stars 51 forks source link

Errors while deploying Cloud Functions #213

Open sripto opened 1 year ago

sripto commented 1 year ago

Environment: GCE VM running Debian 5.10.136 (amd64) Go: v1.16 (runtime chosen in GCP cloud functions)

After having installed all the required components and going past the error and fix identified in this issue, I'm encountering the following error:

Error: Error waiting for Creating CloudFunctions Function: Error code 3, message: Build failed: # cloud.google.com/go/storage
/layers/google.go.functions-framework/gopath/pkg/mod/cloud.google.com/go/storage@v1.22.1/bucket.go:1504:5: cannot use r.Condition.AgeInDays (type int64) as type *int64 in field value
/layers/google.go.functions-framework/gopath/pkg/mod/cloud.google.com/go/storage@v1.22.1/bucket.go:1592:5: cannot use rr.Condition.Age (type *int64) as type int64 in field value; Error ID: 975560ac

 with module.revoke_iam_grants.google_cloudfunctions_function.revoke_member_function,
 on cloudfunctions/iam/revoke/main.tf line 16, in resource "google_cloudfunctions_function" "revoke_member_function":
 16: resource "google_cloudfunctions_function" "revoke_member_function" {

The same error shows up for the following files:

cloudfunctions/bigquery/closepublicdataset/main.tf
cloudfunctions/cloud-sql/removepublic/main.tf
cloudfunctions/cloud-sql/requiressl/main.tf
cloudfunctions/cloud-sql/updatepassword/main.tf
cloudfunctions/filter/main.tf
cloudfunctions/gce/createsnapshot/main.tf
cloudfunctions/gce/openfirewall/main.tf
cloudfunctions/gce/removepublicip/main.tf
cloudfunctions/gcs/closebucket/main.tf
cloudfunctions/gcs/enablebucketonlypolicy/main.tf
cloudfunctions/gke/disabledashboard/main.tf
cloudfunctions/iam/enableauditlogs/main.tf
cloudfunctions/iam/revoke/main.tf
cloudfunctions/router/main.tf

Could someone point me in the right direction to get past this error? Is there any updated code base that fixes all outstanding bugs/issues?

Thank you for any help on this.

yashrath07 commented 1 year ago

I see the same error for all the cloud functions. I started encountering the same issue a few days back.

` Error: Error waiting for Creating CloudFunctions Function: Error code 3, message: Build failed: # cloud.google.com/go/storage /layers/google.go.functions-framework/gopath/pkg/mod/cloud.google.com/go/storage@v1.22.1/bucket.go:1504:5: cannot use r.Condition.AgeInDays (type int64) as type *int64 in field value

/layers/google.go.functions-framework/gopath/pkg/mod/cloud.google.com/go/storage@v1.22.1/bucket.go:1592:5: cannot use rr.Condition.Age (type *int64) as type int64 in field value; Error ID: 975560ac

with module.close_public_cloud_sql.google_cloudfunctions_function.close-cloud-sql, on cloudfunctions/cloud-sql/removepublic/main.tf line 14, in resource "google_cloudfunctions_function" "close-cloud-sql": 14: resource "google_cloudfunctions_function" "close-cloud-sql" {`

Any help on this is appreciated.

vFawzi commented 1 year ago

+1 here, I am getting below error (sample for one function)

Error: Error waiting for Creating CloudFunctions Function: Error code 3, message: Build failed: # golang.org/x/sys/unix │ /layers/google.go.functions-framework/gopath/pkg/mod/golang.org/x/sys@v0.8.0/unix/syscall.go:83:16: undefined: unsafe.Slice │ /layers/google.go.functions-framework/gopath/pkg/mod/golang.org/x/sys@v0.8.0/unix/syscall_linux.go:1018:20: undefined: unsafe.Slice │ /layers/google.go.functions-framework/gopath/pkg/mod/golang.org/x/sys@v0.8.0/unix/syscall_linux.go:2297:9: undefined: unsafe.Slice │ /layers/google.go.functions-framework/gopath/pkg/mod/golang.org/x/sys@v0.8.0/unix/syscall_unix.go:118:7: undefined: unsafe.Slice │ /layers/google.go.functions-framework/gopath/pkg/mod/golang.org/x/sys@v0.8.0/unix/sysvshm_unix.go:33:7: undefined: unsafe.Slice │ note: module requires Go 1.17; Error ID: 6fba28bd │ │ with module.filter.google_cloudfunctions_function.filter, │ on cloudfunctions/filter/main.tf line 15, in resource "google_cloudfunctions_function" "filter": │ 15: resource "google_cloudfunctions_function" "filter" {

vFawzi commented 1 year ago

Updating the tf runtime for Go to 119 solved the issue unsafe.Slice was added in Go 1.17 and Cloud Functions (frustratingly) hasn't evolved beyond Go 1.16. unsafe.Slice is returned by syscall.go:83.16

Source https://stackoverflow.com/questions/74049351/gcloud-functions-deploy-go-runtime-error-undefined-unsafe-slice-error-id-2f5