Skip to content

Commit

Permalink
✨ Extend azure.subscription.policy.assignments to include `{paramet…
Browse files Browse the repository at this point in the history
…ers}` field (#5039)

* add azure.subscription.policy.assignment.parameters

Signed-off-by: Manuel Weber <manuel@mondoo.com>

* add azure.subscription.policy.assignment.parameters++

Signed-off-by: Manuel Weber <manuel@mondoo.com>

* add azure.subscription.policy.assignment.parameters+++

Signed-off-by: Manuel Weber <manuel@mondoo.com>

* add azure.subscription.policy.assignment.parameters++++

Signed-off-by: Manuel Weber <manuel@mondoo.com>

* add azure.subscription.policy.assignment.parameters+++++

Signed-off-by: Manuel Weber <manuel@mondoo.com>

* add azure.subscription.policy.assignment.parameters++++++

Signed-off-by: Manuel Weber <manuel@mondoo.com>

* add azure.subscription.policy.assignment.parameters+++++++

Signed-off-by: Manuel Weber <manuel@mondoo.com>

---------

Signed-off-by: Manuel Weber <manuel@mondoo.com>
  • Loading branch information
mm-weber authored Dec 26, 2024
1 parent 79c7fef commit 65de8c8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
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

0 comments on commit 65de8c8

Please sign in to comment.