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

🧹 add extensions values to defender for containers resource #5042

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Changes from all 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
26 changes: 22 additions & 4 deletions providers/azure/resources/cloud_defender.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import (
"context"
"errors"
"fmt"
"strings"

"go.mondoo.com/cnquery/v11/llx"
"go.mondoo.com/cnquery/v11/providers-sdk/v1/plugin"
"go.mondoo.com/cnquery/v11/providers-sdk/v1/util/convert"
"go.mondoo.com/cnquery/v11/providers/azure/connection"
"go.mondoo.com/cnquery/v11/types"
"strings"

"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity"
Expand Down Expand Up @@ -373,11 +374,16 @@ func (a *mqlAzureSubscriptionCloudDefenderService) defenderForContainers() (inte
if err != nil {
return nil, err
}
type extension struct {
Name string `json:"name"`
IsEnabled bool `json:"isEnabled"`
}

type defenderForContainers struct {
DefenderDaemonSet bool `json:"defenderDaemonSet"`
AzurePolicyForKubernetes bool `json:"azurePolicyForKubernetes"`
Enabled bool `json:"enabled"`
DefenderDaemonSet bool `json:"defenderDaemonSet"`
AzurePolicyForKubernetes bool `json:"azurePolicyForKubernetes"`
Enabled bool `json:"enabled"`
Extensions []extension `json:"extensions"`
}

kubernetesDefender := false
Expand Down Expand Up @@ -418,11 +424,23 @@ func (a *mqlAzureSubscriptionCloudDefenderService) defenderForContainers() (inte
if containersPricing.Properties.PricingTier != nil {
enabled = *containersPricing.Properties.PricingTier == security.PricingTierStandard
}
extensions := []extension{}
for _, ext := range containersPricing.Properties.Extensions {
if ext.IsEnabled == nil || ext.Name == nil {
continue
}
e := false
if *ext.IsEnabled == security.IsEnabledTrue {
e = true
}
extensions = append(extensions, extension{Name: *ext.Name, IsEnabled: e})
}

def := defenderForContainers{
DefenderDaemonSet: arcDefender && kubernetesDefender,
AzurePolicyForKubernetes: arcPolicyExt && kubernetesPolicyExt,
Enabled: enabled,
Extensions: extensions,
}

return convert.JsonToDict(def)
Expand Down
Loading