-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⭐️ Adding conditional Access - Named location part
Signed-off-by: Hossein Rouhani <h_rouhani@hotmail.com>
- Loading branch information
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) Mondoo, Inc. | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
package resources | ||
|
||
import ( | ||
"context" | ||
"log" | ||
|
||
"github.com/microsoftgraph/msgraph-sdk-go/models" | ||
"go.mondoo.com/cnquery/v11/providers/ms365/connection" | ||
) | ||
|
||
func (a *mqlMicrosoftConditionalAccess) namedLocations() (string, error) { | ||
conn := a.MqlRuntime.Connection.(*connection.Ms365Connection) | ||
graphClient, err := conn.GraphClient() | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
// Make a request to get named locations | ||
ctx := context.Background() | ||
namedLocations, err := graphClient.Identity().ConditionalAccess().NamedLocations().Get(ctx, nil) | ||
if err != nil { | ||
return "", transformError(err) | ||
} | ||
|
||
// Check if any of the named locations exist and return the first one | ||
for _, location := range namedLocations.GetValue() { | ||
// Use type assertion to check for IP named locations | ||
if ipLocation, ok := location.(*models.IpNamedLocation); ok { | ||
displayName := ipLocation.GetDisplayName() | ||
if displayName != nil { | ||
return *displayName, nil | ||
} | ||
} | ||
} | ||
|
||
log.Println("No named locations are defined.") | ||
return "", nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters