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

Fixed nil fields being dereferenced for public ips #515

Merged
merged 5 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/providers/azure/publicips.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ func (pip *publicIPProvider) GetResource(ctx context.Context) (*schema.Resources
}

for _, ip := range ips {
// The IPAddress field can be nil and so we want to prevent from dereferencing
// a nil field in the struct
if ip.IPAddress == nil {
continue
}
list.Append(&schema.Resource{
Provider: providerName,
PublicIPv4: *ip.IPAddress,
Expand Down
6 changes: 6 additions & 0 deletions pkg/providers/azure/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ func (d *vmProvider) GetResource(ctx context.Context) (*schema.Resources, error)
for _, ipConfig := range ipconfigList {
privateIP := *ipConfig.PrivateIPAddress

// The PublicIPAddress field can be nil especially for SQL Server
// VMs that are pulled.
// In these cases, we just want to return an empty error
if ipConfig.PublicIPAddress == nil {
return nil, nil
thapr0digy marked this conversation as resolved.
Show resolved Hide resolved
}
res, err := azure.ParseResourceID(*ipConfig.PublicIPAddress.ID)
if err != nil {
return nil, err
Expand Down
Loading