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

Fixed bug for MT.1005 and MT.1027 #130

Merged
merged 2 commits into from
Apr 24, 2024
Merged

Fixed bug for MT.1005 and MT.1027 #130

merged 2 commits into from
Apr 24, 2024

Conversation

tdcthosc
Copy link
Contributor

@tdcthosc tdcthosc commented Apr 24, 2024

MT.1005: Fix automatically detection of emergency access when no excluded users or groups exists in any conditional access policies

#20 (comment)

MT.1027: Fixed bug if no Service Principals with App Registrations exists, which causes the test to fail.

Below will return 'Bad Request' if '$PrivilegedAppIds' is null.

$PrincipalWithAppSecret = ($PrivilegedAppIds | ForEach-Object { Invoke-MtGraphRequest "applications(appId='$($_)')" -ApiVersion beta } | Where-Object { $null -ne $_.passwordCredentials }).appId

Fixed by checking if '$PrivilegedAppIds' has a value.

If ($PrivilegedAppIds) {
  $PrincipalWithAppSecret = ($PrivilegedAppIds | ForEach-Object { Invoke-MtGraphRequest "applications(appId='$($_)')" -ApiVersion beta } | Where-Object { $null -ne $_.passwordCredentials }).appId
}

Below will return the values of '$DirectAssignments' because '$_.Principal.AppId' does not exist and '$PrincipalWithSecrets' is null, which results in 'Where-Object' to find where 'null' is equal to 'null'.

$DirectAssignments | Where-Object { $_.Principal.AppId -in $PrincipalWithSecrets }

Fixed by checking if '$PrincipalWithSecrets' has a value.

If ($PrincipalWithSecrets) {
  $DirectAssignments | Where-Object { $_.Principal.AppId -in $PrincipalWithSecrets }
}

@tdcthosc tdcthosc changed the title [MT.1027] Fixed bug if no Service Principals with App Registrations exists Fixed bug for MT.1005 and MT.1027 Apr 24, 2024
@merill merill merged commit 4192d5a into maester365:main Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants