Fix ReferentialIntegrityPlugin silently bypassing check-references on modify operations#600
Fix ReferentialIntegrityPlugin silently bypassing check-references on modify operations#600
Conversation
…for modify operations Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenDJ/sessions/294a922f-c00a-410a-bc78-529db303e337 Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenDJ/sessions/ab34f013-4824-4541-b086-32d55e871020 Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes Referential Integrity Plugin enforcement for check-references: true during modify operations so missing referenced entries (e.g., deleted users added to group membership attributes) correctly yield CONSTRAINT_VIOLATION instead of being silently accepted.
Changes:
- Fix
doPreOperation(PreOperationModifyOperation)to continue scanning modifications (not break early) and to validate the attribute values being added/replaced. - Add a regression test ensuring adding a missing
uniqueMembervia modify fails withCONSTRAINT_VIOLATION. - Add 2026 “Portions copyright …” headers to the modified source and test files.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java |
Corrects modify pre-op integrity checks to properly validate added/replaced reference values. |
opendj-server-legacy/src/test/java/org/opends/server/plugins/ReferentialIntegrityPluginTestCase.java |
Adds coverage for missing uniqueMember on modify when check-references is enabled. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java
Show resolved
Hide resolved
...erver-legacy/src/test/java/org/opends/server/plugins/ReferentialIntegrityPluginTestCase.java
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@copilot fix build error |
…() instead of getAttributeType() Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenDJ/sessions/e4c3f74e-8d96-4b8f-bdcc-91c814ffb791 Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
Fixed in commit |
|
@copilot fix build error |
|
@copilot Error: /home/runner/work/OpenDJ/OpenDJ/opendj-server-legacy/src/test/java/org/opends/server/plugins/ReferentialIntegrityPluginTestCase.java:[1878,40] error: cannot find symbol |
…ind symbol
symbol: method newModifyRequest(
Both compilation errors have been resolved: the Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
The error was already fixed in |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...erver-legacy/src/test/java/org/opends/server/plugins/ReferentialIntegrityPluginTestCase.java
Show resolved
Hide resolved
…he multi-modify Added a description attribute to ugroup to ensure DELETE modification succeeds.
Portions copyright 2026 3A Systems, LLCtoReferentialIntegrityPlugin.java(modified file)Portions copyright 2026 3A Systems, LLCtoReferentialIntegrityPluginTestCase.java(modified file)Original prompt
Problem
Fixes issue #579: When
check-references: trueis configured in the Referential Integrity Plugin, adding a deleted (non-existent) user to a group vialdapmodify(modifyinguniqueMemberormember) succeeds without throwing aCONSTRAINT_VIOLATIONerror. The check is silently bypassed.Root Cause
There are two bugs in the
doPreOperation(PreOperationModifyOperation modifyOperation)method in:opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.javaBug 1:
breakinstead ofcontinue(lines 1009–1013)If the first modification in the list is not
ADDorREPLACE(e.g.DELETE), the loop exits entirely and no integrity check is performed for any subsequentADDmodifications.Fix: Replace
breakwithcontinue.Bug 2: Reading attribute from the pre-modification entry instead of from the modification itself (line 1015)
Here
entry = modifyOperation.getModifiedEntry()is the current state of the entry before modifications are applied. If the attribute (e.g.uniqueMember) does not yet exist on the entry (first-time add to a group),getAttribute()returnsnull, theif (modifiedAttribute != null)check fails silently, and the integrity check is skipped entirely.Fix: Read the attribute directly from the modification (
mod.getAttribute()), which contains exactly the values being added/replaced.Required Fix
In
doPreOperation(PreOperationModifyOperation modifyOperation), replace:With:
Additional Notes
entryvariable (obtained viamodifyOperation.getModifiedEntry()) is no longer needed after this fix and can be removed (thoughentryDNstill needs to be obtained — it can come from the modification's attribute or from the operation itself viamodifyOperation.getEntryDN()).testEnforceIntegrityModifyGroupAddMissingMemberverified) that:uniqueMemberof a group.CONSTRAINT_VIOLATION.testEnforceIntegrityModifyGroupAddMissingMemberinReferentialIntegrityPluginTestCase.javaalready covers thememberattribute but should be extended to coveruniqueMemberas well, matching the user's configuration.Files to Modify
opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.javaopendj-server-legacy/src/test/java/org/opends/server/plugins/ReferentialIntegrityPluginTestCase.javaThe following is the prior conversation context from the user's chat exploration (may be truncated):
User: прокомментируй
Assistant: Вот подробный анализ баг-репорта на основе изучения исходного кода.
Анализ Issue #579
Суть проблемы
Пользователь настроил Referential Integrity Plugin с
check-references: true, ожидая, что при попытке добавить несуществующего пользователя в группу (uniqueMember) операция будет отклонена с ошибкой. Однакоldapmodifyзавершается успешно, и "мёртвая" ссылка попадает в атрибут.Причина: баг в
doPreOperation(PreOperationModifyOperation)В коде плагина есть критическая ошибка в обработке
modify-операций: