Skip to content

Conversation

@ic0ns
Copy link
Contributor

@ic0ns ic0ns commented Jun 18, 2025

Summary

  • Fixed 3 EI_EXPOSE_REP2 issues and 2 EI_EXPOSE_REP issues identified by Spotbugs
  • Applied defensive copying to prevent exposing internal mutable state

Changes

EI_EXPOSE_REP2 fixes (prevent storing external mutable objects):

  • ByteArrayXorModification: Clone arrays in constructor and setXor()
  • ByteArrayAppendValueModification: Clone arrays in constructor and setBytesToAppend()
  • ByteArrayExplicitValueModification: Clone arrays in constructor and setExplicitValue()
  • ByteArrayInsertValueModification: Clone arrays in constructor and setBytesToInsert()
  • ByteArrayPrependValueModification: Clone arrays in constructor and setBytesToPrepend()
  • ByteArrayShuffleModification: Clone arrays in constructor and setShuffle()
  • ModifiableByteArray: Clone arrays in constructor, setOriginalValue(), and setAssertEquals()

EI_EXPOSE_REP fixes (prevent returning internal mutable objects):

  • All the above classes: Clone arrays in getters
  • ModifiableVariable: Return a copy of the modifications list in getModifications()
  • ComparableByteArray: Clone arrays in constructor, getArray(), and setArray()

Results

  • Reduced EI_EXPOSE_REP2 issues from 16 to 13 (3 fixed)
  • Reduced EI_EXPOSE_REP issues from 12 to 5 (7 fixed)

ic0ns added 2 commits June 18, 2025 05:20
- Clone arrays in constructors, getters, and setters to prevent exposing internal representation
- Applied to ByteArrayXorModification, ByteArrayAppendValueModification, ByteArrayExplicitValueModification, ByteArrayInsertValueModification, ByteArrayPrependValueModification, ByteArrayShuffleModification, and ModifiableByteArray
- Ensures defensive copying to prevent external modification of internal state
- ModifiableVariable.getModifications() now returns a copy of the list
- ComparableByteArray now clones arrays in constructor, getter, and setter
- Prevents exposing internal mutable state
@ic0ns ic0ns closed this Jun 18, 2025
@ic0ns ic0ns deleted the fix-spotbugs-issues branch June 18, 2025 07:43
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