Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix gcp platform family and nil bucket id panic #1883

Merged
merged 2 commits into from
Sep 26, 2023
Merged

Conversation

vjeffrey
Copy link
Contributor

fixes #1856

@vjeffrey vjeffrey changed the title Vj/gcpfix 🐛 fix gcp platform family and nil bucket id panic Sep 25, 2023
@czunker
Copy link
Contributor

czunker commented Sep 25, 2023

It still crashes with the query I tried:

cnquery run gcp project mondoo-dev-262313 -c "gcp.project.loggingservice.sink{*}" 
→ loaded configuration from /etc/opt/mondoo/mondoo.yml using source default
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x1376060]

goroutine 67 [running]:
go.mondoo.com/cnquery/providers/gcp/resources.(*mqlGcpProjectStorageServiceBucket).MqlID(0xb400000000000000?)
	/home/christian/workspace/mondoo/github.com/cnquery/providers/gcp/resources/gcp.lr.go:13019
go.mondoo.com/cnquery/llx.resource2result({0x190b200, 0x0}, {0xc001122060, 0x22})
	/home/christian/workspace/mondoo/github.com/cnquery/llx/data_conversions.go:313 +0x52
go.mondoo.com/cnquery/llx.raw2primitive({0x190b200, 0x0}, {0xc001122060, 0x22})
	/home/christian/workspace/mondoo/github.com/cnquery/llx/data_conversions.go:344 +0x142
go.mondoo.com/cnquery/llx.(*RawData).Result(0xc00111f6f8)
	/home/christian/workspace/mondoo/github.com/cnquery/llx/data_conversions.go:369 +0x77
go.mondoo.com/cnquery/providers-sdk/v1/plugin.(*TValue[...]).ToDataRes(0x1ba2270?, {0xc001122060?, 0x19d0b55?})
	/home/christian/workspace/mondoo/github.com/cnquery/providers-sdk/v1/plugin/runtime.go:185 +0x1e5
go.mondoo.com/cnquery/providers/gcp/resources.glob..func865({0x1bc5e60?, 0xc000cad320?})
	/home/christian/workspace/mondoo/github.com/cnquery/providers/gcp/resources/gcp.lr.go:3170 +0x6b
go.mondoo.com/cnquery/providers/gcp/resources.GetData({0x1bc5e60, 0xc000cad320}, {0xc001104010, 0xd}, 0xc000aca070?)
	/home/christian/workspace/mondoo/github.com/cnquery/providers/gcp/resources/gcp.lr.go:4017 +0x16b
go.mondoo.com/cnquery/providers/gcp/provider.(*Service).GetData(0x1759b20?, 0xc000aca070)
	/home/christian/workspace/mondoo/github.com/cnquery/providers/gcp/provider/provider.go:352 +0x3ea
go.mondoo.com/cnquery/providers-sdk/v1/plugin.(*GRPCServer).GetData(0x182a320?, {0xc000aca070?, 0x4d26e6?}, 0x0?)
	/home/christian/workspace/mondoo/github.com/cnquery/providers-sdk/v1/plugin/grpc.go:113 +0x1e
...

From the linked issue, I'm not sure whether this should be fixed or not. Perhaps this is a follow up issue.

@vjeffrey
Copy link
Contributor Author

no that should have fixed it, hm. it worked in the policy test, ill test on the shell and revisit

@vjeffrey
Copy link
Contributor Author

i think the query is a little different:

cnquery> gcp.project.logging.sinks { * }
gcp.project.logging.sinks: [
  0: {
    includeChildren: false
    destination: "logging.google
    ```

@czunker
Copy link
Contributor

czunker commented Sep 26, 2023

cnquery run gcp project mondoo-dev-262313 -c "gcp.project.loggingservice.sink{*}"

That query also works for me:

cnquery run gcp project mondoo-dev-262313 -c "gcp.project.logging.sinks{*}" 
→ loaded configuration from /etc/opt/mondoo/mondoo.yml using source default
gcp.project.logging.sinks: [
  0: {
    includeChildren: false
    destination: "logging.googleapis.com/projects/mondoo-dev-262313/locations/global/buckets/_Required"
    writerIdentity: ""
    projectId: "mondoo-dev-262313"
    filter: "LOG_ID(\"cloudaudit.googleapis.com/activity\") OR LOG_ID(\"externalaudit.googleapis.com/activity\") OR LOG_ID(\"cloudaudit.googleapis.com/system_event\") OR LOG_ID(\"externalaudit.googleapis.com/system_event\") OR LOG_ID(\"cloudaudit.googleapis.com/access_transparency\") OR LOG_ID(\"externalaudit.googleapis.com/access_transparency\")"
    storageBucket: null
    id: "_Required"
  }
...

It is the "s" at the end: "sink" vs. "sinks"

Copy link
Contributor

@czunker czunker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @vjeffrey

@czunker czunker merged commit 4ad834d into main Sep 26, 2023
10 checks passed
@czunker czunker deleted the vj/gcpfix branch September 26, 2023 07:18
@github-actions github-actions bot locked and limited conversation to collaborators Sep 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gcp scan compare results
2 participants