-
Notifications
You must be signed in to change notification settings - Fork 274
feat: add support for Group and User app role assignments in Azure App #2100
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
base: main
Are you sure you want to change the base?
feat: add support for Group and User app role assignments in Azure App #2100
Conversation
WalkthroughThe PR adds explicit handling for Group and User principal types in Azure app role assignment conversion, introduces Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/go/ein/azure.go (1)
299-331: Group/User → App AZGrant edges look consistent with existing schemaUsing
PrincipalIdas the source (typed asazure.Group/azure.User) andAppIdas the target (typed asazure.App) withazure.Grantaligns with howAZAppnodes are keyed (AppId) elsewhere and matches the PR’s goal of exposing which principals can access an app. Uppercasing IDs and usingNewIngestibleRelationshipkeeps this consistent with the rest of the converters.If you later need to distinguish specific app roles, you could optionally extend these helpers to incorporate
AppRoleIdinto theRelType(similar toRelationshipKindByAppRoleIDfor SP→SP), but that’s not required for the current feature.cmd/api/src/services/graphify/azure_convertors.go (1)
213-236: App role assignment branching by principal type looks correct; consider a constant for"Group"The new control flow in
convertAzureAppRoleAssignmentlooks solid:
- Returning immediately on JSON unmarshal error avoids processing a zero-valued
AppRoleAssignment.- Handling the MS Graph +
ServicePrincipalcase in its own branch (with an earlyreturn) keeps the SP↔MS Graph modeling clean and prevents user/group principals from being treated as service principals.- The new
GroupandUserbranches correctly delegate to the EIN helpers and only append relationships whenIsValid()passes, which matches patterns elsewhere.Two minor follow‑ups:
- For consistency with
PrincipalTypeServicePrincipal/PrincipalTypeUser, you might want aPrincipalTypeGroupconstant instead of the string literal"Group".- This function still ignores app role assignments where
PrincipalType == ServicePrincipalandAppId != azure.MSGraphAppUniversalID; if that’s intentional (same as previous behavior), nothing to change, but it’s worth double‑checking that no desired edges are being dropped.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
cmd/api/src/services/graphify/azure_convertors.go(1 hunks)packages/go/ein/azure.go(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
cmd/api/src/services/graphify/azure_convertors.go (1)
packages/go/ein/azure.go (4)
ConvertAzureAppRoleAssignmentToNodes(241-263)ConvertAzureAppRoleAssignmentToRel(265-297)ConvertAzureGroupAppRoleAssignmentToRel(299-314)ConvertAzureUserAppRoleAssignmentToRel(316-331)
packages/go/ein/azure.go (2)
packages/go/ein/models.go (4)
IngestibleRelationship(59-65)NewIngestibleRelationship(22-33)IngestibleEndpoint(45-49)IngestibleRel(51-54)packages/go/graphschema/azure/azure.go (4)
Group(34-34)App(30-30)Grant(67-67)User(41-41)
…ents Replace hardcoded "Group" string with PrincipalTypeGroup constant for consistency with other principal type checks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
cmd/api/src/services/graphify/azure_convertors.go (1)
227-237: Consider usingelse iffor mutual exclusivity and adding logging for unhandled types.The separate
ifstatements for Group and User handling work correctly but usingelse ifwould make the mutual exclusivity of principal types more explicit and prevent any theoretical edge case where both conditions could match.Additionally, consider adding a log warning for unhandled principal types (anything other than ServicePrincipal, Group, or User) to aid debugging and ensure visibility when unexpected data is encountered.
Apply this diff to use
else ifand add logging for unhandled types:if data.PrincipalType == PrincipalTypeGroup { if rel := ein.ConvertAzureGroupAppRoleAssignmentToRel(data); rel.IsValid() { converted.RelProps = append(converted.RelProps, rel) } - } - - if data.PrincipalType == PrincipalTypeUser { + } else if data.PrincipalType == PrincipalTypeUser { if rel := ein.ConvertAzureUserAppRoleAssignmentToRel(data); rel.IsValid() { converted.RelProps = append(converted.RelProps, rel) } + } else { + slog.Warn(fmt.Sprintf("Unhandled principal type in app role assignment: %s", data.PrincipalType)) }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
cmd/api/src/services/graphify/azure_convertors.go(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
cmd/api/src/services/graphify/azure_convertors.go (1)
packages/go/ein/azure.go (4)
ConvertAzureAppRoleAssignmentToNodes(241-263)ConvertAzureAppRoleAssignmentToRel(265-297)ConvertAzureGroupAppRoleAssignmentToRel(299-314)ConvertAzureUserAppRoleAssignmentToRel(316-331)
🔇 Additional comments (3)
cmd/api/src/services/graphify/azure_convertors.go (3)
39-39: LGTM! Constant follows existing pattern.The new
PrincipalTypeGroupconstant is consistent with the existingPrincipalTypeServicePrincipalandPrincipalTypeUserconstants.
214-217: Good defensive programming with early return.The early return on JSON deserialization error prevents continued execution with potentially invalid data. This is a solid improvement.
219-225: Explicit return improves control flow clarity.Adding the explicit return after ServicePrincipal handling makes it clear that this branch is terminal and prevents any unintended fall-through behavior.
|
CLA Assistant Lite bot: I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request |
Description
Being able to see which users, either via group assignment or direct user assignment, can access an azure application
Motivation and Context
Resolves 2099
currently there's no way to see which users have access to an azure application
How Has This Been Tested?
i tested and work well, can see the results in the graph
Screenshots (optional):
Types of changes
Checklist:
Summary by CodeRabbit
New Features
Bug Fixes / Reliability
✏️ Tip: You can customize this high-level summary in your review settings.