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

🧹 improve user resource handling in Microsoft 365 #4518

Merged
merged 4 commits into from
Aug 12, 2024

Conversation

chris-rock
Copy link
Member

@chris-rock chris-rock commented Aug 9, 2024

This PR improves the microsoft.user resource.

Simpler init functions

User can easily created by their object id and principal name now:

cnspec> microsoft.user(userPrincipalName: "ben@example.onmicrosoft.com")
microsoft.user: microsoft.user id="a692f8ff-42e3-4156-8ac2-523379d9b664" displayName="Ben Rockwood" userPrincipalName="ben@example.onmicrosoft.com"
cnspec> microsoft.user(id: "a692f8ff-42e3-4156-8ac2-523379d9b664")
microsoft.user: microsoft.user id="a692f8ff-42e3-4156-8ac2-523379d9b664" displayName="Ben Rockwood" userPrincipalName="ben@example.onmicrosoft.com"

Retrieve owner for application registration

We added a new owners field to microsoft.application which allows you to see all owners of your application:

cnspec> microsoft.application(name: "chris-testing") { name owners }
microsoft.application: {
  name: "chris-testing"
  owners: [
    0: microsoft.user id="efd9e3d3-eb7a-46f6-a560-09a894e00fdd" displayName="Christoph Hartmann" userPrincipalName="chris@example.onmicrosoft.com"
  ]
}

Group members

For groups, I it is essential to see all members. This can easily done now via:

cnspec> microsoft.groups { name members }

Copy link
Contributor

github-actions bot commented Aug 9, 2024

Test Results

   28 files  + 24    370 suites  +167   1m 22s ⏱️ -16s
3 097 tests +143  3 096 ✅ +146  1 💤 ±0  0 ❌  - 3 
3 097 runs  +144  3 096 ✅ +148  1 💤 ±0  0 ❌  - 4 

Results for commit 7548494. ± Comparison against base commit 8bab9f0.

This pull request removes 1 and adds 144 tests. Note that renamed tests count towards both.
TestMain
go.mondoo.com/cnquery/v11/providers/ansible/play ‑ TestPlaybookDecoding
go.mondoo.com/cnquery/v11/providers/ansible/play ‑ TestPlaybookDecoding/load_default_playbook
go.mondoo.com/cnquery/v11/providers/ansible/play ‑ TestPlaybookDecoding/load_playbook_with_blocks_and_errors
go.mondoo.com/cnquery/v11/providers/ansible/play ‑ TestPlaybookDecoding/load_playbook_with_multiple_plays
go.mondoo.com/cnquery/v11/providers/ansible/play ‑ TestPlaybookDecoding/load_playbook_with_roles
go.mondoo.com/cnquery/v11/providers/ansible/play ‑ TestPlaybookDecoding/load_playbook_with_serial
go.mondoo.com/cnquery/v11/providers/ansible/play ‑ TestPlaybookDecoding/load_playbook_with_vars
go.mondoo.com/cnquery/v11/providers/ansible/play ‑ TestTaskDecoding
go.mondoo.com/cnquery/v11/providers/ansible/play ‑ TestTaskDecoding/load_task_with_blocks
go.mondoo.com/cnquery/v11/providers/ansible/play ‑ TestTaskDecoding/load_task_with_vars
…

♻️ This comment has been updated with latest results.

@chris-rock chris-rock marked this pull request as ready for review August 11, 2024 10:55
providers/ms365/resources/groups.go Outdated Show resolved Hide resolved
// index users by id
idxUsersById map[string]*mqlMicrosoftUser
// index users by principal name
idxUsersByPrincipalName map[string]*mqlMicrosoftUser
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it doesnt seem we use this index to fetch users, can we remove it if thats the case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, lets remove it

chris-rock and others added 4 commits August 12, 2024 09:14
- new init for `microsoft.user`
- `micosoft.group.members` returns human users
- `microsoft.application.owner` returns all application owner
Co-authored-by: Tim Smith <tsmith84@gmail.com>
Co-authored-by: Preslav Gerchev <preslav@mondoo.com>
@chris-rock chris-rock merged commit 0f3ffcb into main Aug 12, 2024
15 checks passed
@chris-rock chris-rock deleted the chris-rock/ms-entra-users branch August 12, 2024 07:27
@github-actions github-actions bot locked and limited conversation to collaborators Aug 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants