Skip to content

fix(graph): skip invalid LDAP identities - #4047

Open
IgorPolyakov wants to merge 1 commit into
opencloud-eu:mainfrom
IgorPolyakov:fix/graph-invalid-ldap-identities
Open

IgorPolyakov wants to merge 1 commit into
opencloud-eu:mainfrom
IgorPolyakov:fix/graph-invalid-ldap-identities

Conversation

@IgorPolyakov

Copy link
Copy Markdown

Description

Skip malformed LDAP external identity values when converting LDAP entries to Graph user models.

The LDAP identity attribute is expected to contain three $-separated parts. The previous implementation accessed the parsed parts without validating their number, which could cause an
index-out-of-range panic.

The conversion now validates the attribute structure and required identity fields. Invalid values are logged and skipped, while valid identities remain attached to the user.

A regression test covering malformed and empty identity values has been added.

Related Issue

  • Fixes - No issue

Motivation and Context

An LDAP user with an empty or malformed external identity attribute could crash the Graph service while the user was being processed.

A single invalid identity should not prevent the user or their remaining valid identities from being returned. This change prevents the panic and safely ignores only malformed identity
values.

How Has This Been Tested?

  • Test environment: local Linux development environment

  • Ran:

    go test ./services/graph/pkg/identity
    

• Verified that identity values with missing $ separators are skipped without a panic.
• Verified that identities with an empty issuer or issuer-assigned ID are skipped.
• Verified that valid identities are still included in the resulting Graph user model.

Screenshots (if appropriate):

Not applicable.

Types of changes

  • 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)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation added

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

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.

1 participant