-
Notifications
You must be signed in to change notification settings - Fork 34
🐛 Fix nil pointer dereferences and panics across GCP provider #6942
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1028,6 +1028,9 @@ func (g *mqlGcpProjectGkeServiceClusterNetworkConfig) network() (*mqlGcpProjectC | |
|
|
||
| // Format is projects/project-1/global/networks/net-1 | ||
| params := strings.Split(networkPath, "/") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 suggestion — The bounds check |
||
| if len(params) < 2 { | ||
| return nil, errors.New("malformed network path: " + networkPath) | ||
| } | ||
| res, err := CreateResource(g.MqlRuntime, "gcp.project.computeService.network", map[string]*llx.RawData{ | ||
| "name": llx.StringData(params[len(params)-1]), | ||
| "projectId": llx.StringData(params[1]), | ||
|
|
@@ -1046,6 +1049,9 @@ func (g *mqlGcpProjectGkeServiceClusterNetworkConfig) subnetwork() (*mqlGcpProje | |
|
|
||
| // Format is projects/project-1/regions/us-central1/subnetworks/subnet-1 | ||
| params := strings.Split(subnetPath, "/") | ||
| if len(params) < 6 { | ||
| return nil, errors.New("malformed subnetwork path: " + subnetPath) | ||
| } | ||
| regionUrl := strings.SplitN(subnetPath, "/subnetworks", 2) | ||
| res, err := NewResource(g.MqlRuntime, "gcp.project.computeService.subnetwork", map[string]*llx.RawData{ | ||
| "name": llx.StringData(params[len(params)-1]), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 warning — The original code checked
if buckets == nilto guard against a nilbucketsvalue. The new codeif buckets.Error != nilwill panic ifbucketsitself is nil (i.e., ifGetBuckets()returns a nil plugin result). The original nil check was likely intentional — consider keeping a nil guard:Or verify that
GetBuckets()is guaranteed to never return a nil result struct.