Skip to content

Commit

Permalink
šŸ› fix retrieval of azure monitor diagnostic settings and log profiles. (
Browse files Browse the repository at this point in the history
  • Loading branch information
preslavgerchev authored Oct 18, 2023
1 parent 29a6fdd commit a105797
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions providers/azure/resources/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package resources

import (
"context"
"errors"

"go.mondoo.com/cnquery/v9/llx"
"go.mondoo.com/cnquery/v9/providers-sdk/v1/plugin"
Expand Down Expand Up @@ -265,20 +266,30 @@ func (a *mqlAzureSubscriptionMonitorServiceActivityLog) alerts() ([]interface{},
return res, nil
}

// TODO: we should check how the plugin generic struct works when the value isn't set, can we rely on default value
// or need to use something else? goes for both storageAccount implementations
func (a *mqlAzureSubscriptionMonitorServiceLogprofile) storageAccount() (*mqlAzureSubscriptionStorageServiceAccount, error) {
if a.StorageAccountId.State&plugin.StateIsNull != 0 {
return nil, errors.New("diagnostic settings has no storage account")
}
if a.StorageAccountId.Error != nil {
return nil, a.StorageAccountId.Error
}
storageAccId := a.StorageAccountId.Data
if storageAccId == "" {
return nil, nil
return nil, errors.New("diagnostic settings has no storage account")
}
return getStorageAccount(storageAccId, a.MqlRuntime, a.MqlRuntime.Connection.(*connection.AzureConnection))
}

func (a *mqlAzureSubscriptionMonitorServiceDiagnosticsetting) storageAccount() (*mqlAzureSubscriptionStorageServiceAccount, error) {
if a.StorageAccountId.State&plugin.StateIsNull != 0 {
return nil, errors.New("diagnostic settings has no storage account")
}
if a.StorageAccountId.Error != nil {
return nil, a.StorageAccountId.Error
}
storageAccId := a.StorageAccountId.Data
if storageAccId == "" {
return nil, nil
return nil, errors.New("diagnostic settings has no storage account")
}
return getStorageAccount(storageAccId, a.MqlRuntime, a.MqlRuntime.Connection.(*connection.AzureConnection))
}
Expand Down

0 comments on commit a105797

Please sign in to comment.