Skip to content

Commit 4d9c42c

Browse files
tas50claude
andcommitted
🐛 Fix nil-safety issues found in review
- redis.go: Merge duplicate Internal struct into single definition - network.go: Guard lb.SKU and fw.Properties/SKU nil dereferences - iam.go: Skip nil permission entries in lazy-loaded permissions() Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 031b406 commit 4d9c42c

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

providers/azure/resources/iam.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ type mqlAzureSubscriptionAuthorizationServiceRoleDefinitionInternal struct {
105105
func (a *mqlAzureSubscriptionAuthorizationServiceRoleDefinition) permissions() ([]any, error) {
106106
res := []any{}
107107
for idx, p := range a.cachePermissions {
108+
if p == nil {
109+
continue
110+
}
108111
id := fmt.Sprintf("%s/azure.subscription.authorizationService.roleDefinition.permission/%d", a.Id.Data, idx)
109112
permission, err := newMqlRolePermission(a.MqlRuntime, id, p)
110113
if err != nil {

providers/azure/resources/network.go

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -387,14 +387,19 @@ func (a *mqlAzureSubscriptionNetworkService) loadBalancers() ([]any, error) {
387387
if err != nil {
388388
return nil, err
389389
}
390+
var lbSkuName, lbSkuTier *string
391+
if lb.SKU != nil {
392+
lbSkuName = (*string)(lb.SKU.Name)
393+
lbSkuTier = (*string)(lb.SKU.Tier)
394+
}
390395
mqlAzure, err := CreateResource(a.MqlRuntime, "azure.subscription.networkService.loadBalancer",
391396
map[string]*llx.RawData{
392397
"id": llx.StringDataPtr(lb.ID),
393398
"name": llx.StringDataPtr(lb.Name),
394399
"location": llx.StringDataPtr(lb.Location),
395400
"etag": llx.StringDataPtr(lb.Etag),
396-
"sku": llx.StringDataPtr((*string)(lb.SKU.Name)),
397-
"skuTier": llx.StringDataPtr((*string)(lb.SKU.Tier)),
401+
"sku": llx.StringDataPtr(lbSkuName),
402+
"skuTier": llx.StringDataPtr(lbSkuTier),
398403
"tags": llx.MapData(convert.PtrMapStrToInterface(lb.Tags), types.String),
399404
"type": llx.StringDataPtr(lb.Type),
400405
"properties": llx.DictData(lbProps),
@@ -2277,6 +2282,15 @@ func azureFirewallToMql(runtime *plugin.Runtime, fw network.AzureFirewall) (*mql
22772282
if err != nil {
22782283
return nil, err
22792284
}
2285+
var fwSkuTier, fwSkuName, fwProvisioningState, fwThreatIntelMode *string
2286+
if fw.Properties != nil {
2287+
fwProvisioningState = (*string)(fw.Properties.ProvisioningState)
2288+
fwThreatIntelMode = (*string)(fw.Properties.ThreatIntelMode)
2289+
if fw.Properties.SKU != nil {
2290+
fwSkuTier = (*string)(fw.Properties.SKU.Tier)
2291+
fwSkuName = (*string)(fw.Properties.SKU.Name)
2292+
}
2293+
}
22802294
args := map[string]*llx.RawData{
22812295
"id": llx.StringDataPtr(fw.ID),
22822296
"name": llx.StringDataPtr(fw.Name),
@@ -2285,10 +2299,10 @@ func azureFirewallToMql(runtime *plugin.Runtime, fw network.AzureFirewall) (*mql
22852299
"tags": llx.MapData(convert.PtrMapStrToInterface(fw.Tags), types.String),
22862300
"etag": llx.StringDataPtr(fw.Etag),
22872301
"properties": llx.DictData(props),
2288-
"skuTier": llx.StringDataPtr((*string)(fw.Properties.SKU.Tier)),
2289-
"skuName": llx.StringDataPtr((*string)(fw.Properties.SKU.Name)),
2290-
"provisioningState": llx.StringDataPtr((*string)(fw.Properties.ProvisioningState)),
2291-
"threatIntelMode": llx.StringDataPtr((*string)(fw.Properties.ThreatIntelMode)),
2302+
"skuTier": llx.StringDataPtr(fwSkuTier),
2303+
"skuName": llx.StringDataPtr(fwSkuName),
2304+
"provisioningState": llx.StringDataPtr(fwProvisioningState),
2305+
"threatIntelMode": llx.StringDataPtr(fwThreatIntelMode),
22922306
}
22932307
mqlFw, err := CreateResource(runtime, "azure.subscription.networkService.firewall", args)
22942308
if err != nil {

providers/azure/resources/redis.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ type mqlAzureSubscriptionCacheServiceRedisInstanceInternal struct {
2626
// cacheEncryptionKeyURI stores the customer-managed key URI for encryption.
2727
// Note: armredis/v3 does not expose encryption fields on Properties.
2828
// This will be populated when the SDK adds support for CMK encryption configuration.
29-
cacheEncryptionKeyURI string
29+
cacheEncryptionKeyURI string
30+
cachePrivateEndpointConnections []*armredis.PrivateEndpointConnection
3031
}
3132

3233
func (a *mqlAzureSubscriptionCacheServiceRedisInstance) id() (string, error) {
@@ -213,10 +214,6 @@ func createRedisInstanceRawData(runtime *plugin.Runtime, cache *armredis.Resourc
213214
}, nil
214215
}
215216

216-
type mqlAzureSubscriptionCacheServiceRedisInstanceInternal struct {
217-
cachePrivateEndpointConnections []*armredis.PrivateEndpointConnection
218-
}
219-
220217
func (a *mqlAzureSubscriptionCacheServiceRedisInstance) privateEndpointConnections() ([]any, error) {
221218
res := []any{}
222219
for _, pec := range a.cachePrivateEndpointConnections {

0 commit comments

Comments
 (0)