spring-projects / spring-projects/spring-security

SEC-2817: ObjectIdentityImpl.equals method doesn't allow comparing ObjectIdentity instances from different classes

Open
#3,036 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

in: acl type: bug type: jira
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

Kenan Sevindik (Migrated from SEC-2817) said:

Inside ObjectIdentityImpl.equals(..) method, target arg object is expected of type ObjectIdentityImpl. However, we can have another implementation of ObjectIdentity interface and an instance of it can be passed into that equals method as well.

Let's say I create a CustomObjectIdentity class of type ObjectIdentity, have a domain object of type: x.y.Foo with id: Long(1), and create two ObjectIdentity instances representing that domain object.

  1. ObjectIdentity oid1 = new ObjectIdentityImpl(Foo.class,1L);
  2. ObjectIdentity oid2 = new CustomObjectIdentity(Foo.class,1L);

IMO, oid1.equals(oid2) should return true here. Instead of checking if target arg object is of type ObjectIdentityImpl within equals method, it should just check if target object is of type ObjectIdentity and obtain type and identifier values via getters to evaluate the equals method.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at ObjectIdentityImpl.equals and inspect the ObjectIdentity interface getters used to compare the object type and identifier. Verify the behavior with an ObjectIdentityImpl and another ObjectIdentity implementation representing the same domain object; done means the two instances compare equal.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
security
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.