Skip to content

Commit

Permalink
⭐️ Adding consent settings - ms365 (#4633)
Browse files Browse the repository at this point in the history
* ⭐️ Adding consent settings

Signed-off-by: Hossein Rouhani <[email protected]>

* rebase and add missing files

Signed-off-by: Hossein Rouhani <[email protected]>

---------

Signed-off-by: Hossein Rouhani <[email protected]>
  • Loading branch information
HRouhani authored Sep 26, 2024
1 parent 870c8c9 commit 045aa0e
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
3 changes: 3 additions & 0 deletions providers/ms365/resources/ms365.lr
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,11 @@ microsoft.policies {
adminConsentRequestPolicy() dict
// Permission grant policies
permissionGrantPolicies() []dict
// Consent policy settings
consentPolicySettings() dict
}


// Deprecated: use `microsoft.roles` instead
microsoft.rolemanagement {
// Deprecated: use `microsoft.roles` instead
Expand Down
14 changes: 14 additions & 0 deletions providers/ms365/resources/ms365.lr.go

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

4 changes: 4 additions & 0 deletions providers/ms365/resources/ms365.lr.manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,12 @@ resources:
min_mondoo_version: 9.0.0
microsoft.policies:
fields:
ConsentPolicySettings:
min_mondoo_version: 9.0.0
adminConsentRequestPolicy: {}
authorizationPolicy: {}
consentPolicySettings:
min_mondoo_version: 9.0.0
identitySecurityDefaultsEnforcementPolicy: {}
permissionGrantPolicies: {}
min_mondoo_version: 5.15.0
Expand Down
37 changes: 37 additions & 0 deletions providers/ms365/resources/policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,40 @@ func (a *mqlMicrosoftPolicies) permissionGrantPolicies() ([]interface{}, error)
}
return convert.JsonToDictSlice(newPermissionGrantPolicies(resp.GetValue()))
}

// https://learn.microsoft.com/en-us/graph/api/groupsetting-get?view=graph-rest-1.0&tabs=http

func (a *mqlMicrosoftPolicies) consentPolicySettings() (interface{}, error) {
conn := a.MqlRuntime.Connection.(*connection.Ms365Connection)
graphClient, err := conn.GraphClient()
if err != nil {
return nil, err
}

ctx := context.Background()

groupSettings, err := graphClient.GroupSettings().Get(ctx, nil)
if err != nil {
return nil, transformError(err)
}

actualSettingsMap := make(map[string]map[string]interface{})
for _, setting := range groupSettings.GetValue() {
displayName := setting.GetDisplayName()
if displayName != nil {
if _, exists := actualSettingsMap[*displayName]; !exists {
actualSettingsMap[*displayName] = make(map[string]interface{})
}

for _, settingValue := range setting.GetValues() {
name := settingValue.GetName()
value := settingValue.GetValue()
if name != nil && value != nil {
actualSettingsMap[*displayName][*name] = *value
}
}
}
}

return convert.JsonToDict(actualSettingsMap)
}

0 comments on commit 045aa0e

Please sign in to comment.