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

✨ Extend azure.subscription.policy.assignments to include {parameters} field #5039

Merged
merged 7 commits into from
Dec 26, 2024
6 changes: 6 additions & 0 deletions providers/azure/resources/armsecurity.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ type PolicyAssignment struct {
AllowedSkus struct {
Value string `json:"value"`
} `json:"allowedSkus"`
Effect struct {
Value string `json:"value"`
} `json:"effect"`
ApprovedExtensions struct {
Value []string `json:"value"`
} `json:"approvedExtensions"`
} `json:"parameters"`
Scope string `json:"scope"`
NotScopes []interface{} `json:"notScopes"`
Expand Down
2 changes: 2 additions & 0 deletions providers/azure/resources/azure.lr
Original file line number Diff line number Diff line change
Expand Up @@ -2006,6 +2006,8 @@ private azure.subscription.policy.assignment @defaults("name enforcementMode") {
description string
// Policy enforcement Mode
enforcementMode string
// Policy parameters
parameters dict
}

// Azure IoT Hub Service
Expand Down
12 changes: 12 additions & 0 deletions providers/azure/resources/azure.lr.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions providers/azure/resources/azure.lr.manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2060,6 +2060,7 @@ resources:
enforcementMode: {}
id: {}
name: {}
parameters: {}
scope: {}
is_private: true
min_mondoo_version: 9.0.0
Expand Down
8 changes: 8 additions & 0 deletions providers/azure/resources/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import (
"context"
"errors"
"fmt"

"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"
)

Expand Down Expand Up @@ -43,13 +45,19 @@ func (a *mqlAzureSubscriptionPolicy) assignments() ([]interface{}, error) {

res := []interface{}{}
for _, assignment := range pas.PolicyAssignments {
parameters, err := convert.JsonToDict(assignment.Properties.Parameters)
if err != nil {
return nil, err
}

assignmentData := map[string]*llx.RawData{
"__id": llx.StringData(fmt.Sprintf("azure.subscription.policy/%s/%s", assignment.Properties.Scope, assignment.Properties.DisplayName)),
"id": llx.StringData(assignment.Properties.PolicyDefinitionID),
"name": llx.StringData(assignment.Properties.DisplayName),
"scope": llx.StringData(assignment.Properties.Scope),
"description": llx.StringData(assignment.Properties.Description),
"enforcementMode": llx.StringData(assignment.Properties.EnforcementMode),
"parameters": llx.DictData(parameters),
}

mqlAssignment, err := CreateResource(a.MqlRuntime, "azure.subscription.policy.assignment", assignmentData)
Expand Down
Loading