Skip to content

fix: Expand number of entries included in ConvertAzureRoleEligibilityScheduleInstanceToRel relationships (BED-6391)#2935

Open
dcairnsspecterops wants to merge 4 commits into
mainfrom
BED-6391-PIM-eligibility-incomplete-results
Open

fix: Expand number of entries included in ConvertAzureRoleEligibilityScheduleInstanceToRel relationships (BED-6391)#2935
dcairnsspecterops wants to merge 4 commits into
mainfrom
BED-6391-PIM-eligibility-incomplete-results

Conversation

@dcairnsspecterops

@dcairnsspecterops dcairnsspecterops commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Motivation and Context

A customer noticed that not all eligible user roles are being surfaced in their environment. Seems to be that is because in ConvertAzureRoleEligibilityScheduleInstanceToRel we skip the assignment of relationships if the DirectoryScoped is not "/"

This PR removes that gate, assigning relationships for all instances, not just those whose DirectoryScoped is /.

Resolves BED-6391

Why is this change required? What problem does it solve?

How Has This Been Tested?

Please describe in detail how you tested your changes.
Include details of your testing environment, and the tests you ran to
see how your change affects other areas of the code, etc.

Screenshots (optional):

Types of changes

  • Chore (a change that does not modify the application functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Database Migrations

Checklist:

Summary by CodeRabbit

  • Bug Fixes

    • Fixed Azure role eligibility schedule conversion to always create the Azure role eligibility relationship, including when the directory scope is non-root (previously it could be skipped for non-root scope).
  • Tests

    • Updated Azure role eligibility schedule conversion tests to expect exactly one relationship for non-root directory scopes, and to verify the relationship type and source/target values.

…duleInstanceToRel to widen eligible roles results list
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

ConvertAzureRoleEligibilityScheduleInstanceToRel now always appends an AZRoleEligible relationship, including for non-root DirectoryScopeId values. The related test now expects one relationship for that case.

Changes

Azure Role Eligibility Scope Fix

Layer / File(s) Summary
Converter and test expectations
packages/go/ein/azure.go, packages/go/ein/azure_test.go
Removes the directory-scope early return in the Azure role eligibility converter and updates the test to assert one emitted relationship for non-root scope.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: expanding relationships returned by ConvertAzureRoleEligibilityScheduleInstanceToRel.
Description check ✅ Passed The PR description covers the issue, motivation, and intended fix, with the required template mostly followed despite an unfilled testing section.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch BED-6391-PIM-eligibility-incomplete-results

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/go/ein/azure.go (1)

1959-1974: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Update the non-root scope test to match this widened behavior.

packages/go/ein/azure_test.go:33-61 still expects zero relationships for DirectoryScopeId: "abc123", so this change leaves the downstream assertion stale. Please update that case to expect the AZRoleEligible edge as well.

Suggested test update
diff --git a/packages/go/ein/azure_test.go b/packages/go/ein/azure_test.go
@@
 	expectedRels = ein.ConvertAzureRoleEligibilityScheduleInstanceToRel(testData)
-	require.Len(t, expectedRels, 0)
+	require.Len(t, expectedRels, 1)
+	expectedRel = expectedRels[0]
+	require.Equal(t, expectedRel.Target.Value, strings.ToUpper(fmt.Sprintf("%s@%s", testData.RoleDefinitionId, testData.TenantId)))
+	require.Equal(t, expectedRel.RelType, azure.AZRoleEligible)
+	require.Equal(t, expectedRel.Source.Value, strings.ToUpper(testData.PrincipalId))
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/go/ein/azure.go` around lines 1959 - 1974, The relationship-building
logic in the Azure ingestion path now emits an AZRoleEligible edge for non-root
directory scopes, so the existing test expectation is outdated. Update the
DirectoryScopeId "abc123" case in azure_test.go to assert the new relationship
produced by the code path in the azure.go relationship construction, using the
existing NewIngestibleRelationship/IngestibleEndpoint symbols as the reference
point.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@packages/go/ein/azure.go`:
- Around line 1959-1974: The relationship-building logic in the Azure ingestion
path now emits an AZRoleEligible edge for non-root directory scopes, so the
existing test expectation is outdated. Update the DirectoryScopeId "abc123" case
in azure_test.go to assert the new relationship produced by the code path in the
azure.go relationship construction, using the existing
NewIngestibleRelationship/IngestibleEndpoint symbols as the reference point.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 97d9b50b-869d-4468-81f1-35ef276840ed

📥 Commits

Reviewing files that changed from the base of the PR and between 6688fb0 and 3419494.

📒 Files selected for processing (1)
  • packages/go/ein/azure.go

@dcairnsspecterops dcairnsspecterops changed the title bug: Expand number of entries included in ConvertAzureRoleEligibilityScheduleInstanceToRel relationships fix: Expand number of entries included in ConvertAzureRoleEligibilityScheduleInstanceToRel relationships Jun 29, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/go/ein/azure_test.go`:
- Around line 63-79: Remove the stale zero-length assertion from
TestNonRootDirectoryScopeIdConvertAzureRoleEligibilityScheduleInstanceToRel so
the test only validates the single relationship returned by
ConvertAzureRoleEligibilityScheduleInstanceToRel for a non-root
DirectoryScopeId; keep the existing require.Len(..., 1) and the checks on
expectedRel.Target, expectedRel.RelType, and expectedRel.Source, and delete the
contradictory require.Len(..., 0) path.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 709b21ee-6776-4162-b27f-c054907f2077

📥 Commits

Reviewing files that changed from the base of the PR and between 3419494 and 8918ecc.

📒 Files selected for processing (1)
  • packages/go/ein/azure_test.go

Comment thread packages/go/ein/azure_test.go Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/go/ein/azure_test.go (1)

60-61: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the emitted relationship fields for the non-root case too.

This now proves non-root scopes are included, but it no longer verifies that the emitted relationship is still the expected source -> AZRoleEligible -> target. Mirroring the root-case assertions here would keep the widened contract covered.

Suggested test tightening
 	expectedRels = ein.ConvertAzureRoleEligibilityScheduleInstanceToRel(testData)
 	require.Len(t, expectedRels, 1)
+	expectedRel = expectedRels[0]
+	require.Equal(t, expectedRel.Target.Value, strings.ToUpper(fmt.Sprintf("%s@%s", testData.RoleDefinitionId, testData.TenantId)))
+	require.Equal(t, expectedRel.RelType, azure.AZRoleEligible)
+	require.Equal(t, expectedRel.Source.Value, strings.ToUpper(testData.PrincipalId))
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/go/ein/azure_test.go` around lines 60 - 61, The non-root case in
ConvertAzureRoleEligibilityScheduleInstanceToRel is only checking the
relationship count, so it no longer verifies the emitted source, type, and
target fields. Tighten the azure_test.go assertion by mirroring the root-case
checks for expectedRels[0] so the test confirms the relationship still resolves
to source -> AZRoleEligible -> target while covering non-root scopes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/go/ein/azure_test.go`:
- Around line 60-61: The non-root case in
ConvertAzureRoleEligibilityScheduleInstanceToRel is only checking the
relationship count, so it no longer verifies the emitted source, type, and
target fields. Tighten the azure_test.go assertion by mirroring the root-case
checks for expectedRels[0] so the test confirms the relationship still resolves
to source -> AZRoleEligible -> target while covering non-root scopes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: a58ee2b6-9301-46ca-a6a7-4d226d3df70b

📥 Commits

Reviewing files that changed from the base of the PR and between 8918ecc and b159ca2.

📒 Files selected for processing (1)
  • packages/go/ein/azure_test.go

@dcairnsspecterops dcairnsspecterops changed the title fix: Expand number of entries included in ConvertAzureRoleEligibilityScheduleInstanceToRel relationships fix: Expand number of entries included in ConvertAzureRoleEligibilityScheduleInstanceToRel relationships (BED-6391) Jun 29, 2026
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.

2 participants