Skip to content

[BUG] Potential Unhandled exception in PolarisEntityResolver.java  #327

Open
@dbosco

Description

@dbosco

Is this a possible security vulnerability?

  • This is NOT a possible security vulnerability

Describe the bug

In the following code:

PolarisEntityActiveRecord activeEntityRecord = activeRecordIt.next();

for (PolarisEntityCore resolveEntity : toResolve) {
  // get associate active record
  PolarisEntityActiveRecord activeEntityRecord = activeRecordIt.next();

  // if this entity has been dropped (null) or replaced (<> ids), then fail validation
  if (activeEntityRecord == null || activeEntityRecord.getId() != resolveEntity.getId()) {
    return false;
  }
}

If there are no elements in activeRecordIt, calling .next() will throw an exception before reaching the activeEntityRecord == null check.

Should we add a .hasNext() check before calling .next()?

If this is indeed an issue, it seems like a trivial fix, and I’d be happy to address it.

PolarisEntityActiveRecord activeEntityRecord = activeRecordIt.next();

` for (PolarisEntityCore resolveEntity : toResolve) {
// get associate active record
PolarisEntityActiveRecord activeEntityRecord = activeRecordIt.next();

  // if this entity has been dropped (null) or replaced (<> ids), then fail validation
  if (activeEntityRecord == null || activeEntityRecord.getId() != resolveEntity.getId()) {
    return false;
  }
}`

If there are no elements in activeRecordIt, then the .next() will throw an exception before reaching below.
activeEntityRecord == null
Should we check for .hasNext() before calling .next().

If it is indeed an issue, it seems to be an trivial fix and I am happy to do it. Please assign it to me.

To Reproduce

No response

Actual Behavior

No response

Expected Behavior

No response

Additional context

No response

System information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions