Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<!-- scope: provided -->
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
<scope>provided</scope>
</dependency>
<!-- scope: test -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
Expand Down Expand Up @@ -174,6 +180,7 @@
<target>${maven.compiler.target}</target>
<compilerArgs>
<compilerArg>-proc:full</compilerArg>
<compilerArg>-Xlint:deprecation</compilerArg>
</compilerArgs>
</configuration>
</plugin>
Expand Down Expand Up @@ -266,10 +273,21 @@
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<configuration>
<excludeFilterFile>spotbugs-exclude.xml</excludeFilterFile>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<minimumTokens>150</minimumTokens>
<excludes>
<!-- Exclude shift modifications from CPD as duplication between Integer/Long is acceptable -->
<exclude>**/integer/*ShiftModification.java</exclude>
<exclude>**/longint/*ShiftModification.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
13 changes: 13 additions & 0 deletions spotbugs-exclude.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<!-- Ignore EI_EXPOSE_REP and EI_EXPOSE_REP2 warnings -->
<!-- These are intentionally ignored because this library is designed for runtime
modification of variables, and defensive copying would impact performance
without significant security benefits for this use case -->
<Match>
<Bug pattern="EI_EXPOSE_REP"/>
</Match>
<Match>
<Bug pattern="EI_EXPOSE_REP2"/>
</Match>
</FindBugsFilter>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
package de.rub.nds.modifiablevariable;

import de.rub.nds.modifiablevariable.util.ArrayConverter;
import de.rub.nds.modifiablevariable.util.DataConverter;
import de.rub.nds.modifiablevariable.util.ReflectionHelper;
import jakarta.xml.bind.annotation.XmlType;
import java.io.Serializable;
Expand Down Expand Up @@ -194,7 +194,7 @@ protected String getExtendedString(int depth) {
stringBuilder.append("\t".repeat(Math.max(0, depth)));
stringBuilder.append(field.getName());
stringBuilder.append(": ");
stringBuilder.append(ArrayConverter.bytesToHexString(temp));
stringBuilder.append(DataConverter.bytesToHexString(temp));
stringBuilder.append("\n");
}
if (tempObject instanceof ModifiableVariableHolder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import static de.rub.nds.modifiablevariable.util.StringUtil.backslashEscapeString;

import com.fasterxml.jackson.annotation.JsonTypeInfo;
import de.rub.nds.modifiablevariable.util.ArrayConverter;
import de.rub.nds.modifiablevariable.util.DataConverter;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlTransient;
Expand Down Expand Up @@ -137,7 +137,7 @@ protected void debug(E value) {
} else {
String valueString =
switch (value) {
case byte[] bytes -> ArrayConverter.bytesToHexString(bytes);
case byte[] bytes -> DataConverter.bytesToHexString(bytes);
case String s -> backslashEscapeString(s);
default -> value.toString();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package de.rub.nds.modifiablevariable.biginteger;

import de.rub.nds.modifiablevariable.ModifiableVariable;
import de.rub.nds.modifiablevariable.util.ArrayConverter;
import de.rub.nds.modifiablevariable.util.DataConverter;
import jakarta.xml.bind.annotation.XmlRootElement;
import java.math.BigInteger;

Expand Down Expand Up @@ -108,7 +108,7 @@ public boolean isOriginalValueModified() {
* @return The byte array representation of the BigInteger
*/
public byte[] getByteArray() {
return ArrayConverter.bigIntegerToByteArray(getValue());
return DataConverter.bigIntegerToByteArray(getValue());
}

/**
Expand All @@ -118,7 +118,7 @@ public byte[] getByteArray() {
* @return The byte array representation of the BigInteger
*/
public byte[] getByteArray(int size) {
return ArrayConverter.bigIntegerToByteArray(getValue(), size, true);
return DataConverter.bigIntegerToByteArray(getValue(), size, true);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package de.rub.nds.modifiablevariable.bool;

import de.rub.nds.modifiablevariable.VariableModification;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import jakarta.xml.bind.annotation.XmlRootElement;

/**
Expand Down Expand Up @@ -76,6 +77,10 @@ public BooleanExplicitValueModification createCopy() {
* @return The explicit value, or null if input was null
*/
@Override
@SuppressFBWarnings(
value = "NP_BOOLEAN_RETURN_NULL",
justification =
"Returning null for null input is intentional design for null-safety in modification chain")
protected Boolean modifyImplementationHook(Boolean input) {
if (input == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package de.rub.nds.modifiablevariable.bool;

import de.rub.nds.modifiablevariable.VariableModification;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import jakarta.xml.bind.annotation.XmlRootElement;

/**
Expand All @@ -27,23 +28,14 @@ public BooleanToggleModification() {
super();
}

/**
* Copy constructor.
*
* @param other The modification to copy
*/
public BooleanToggleModification(BooleanToggleModification other) {
super();
}

/**
* Creates a deep copy of this modification.
*
* @return A new instance of BooleanToggleModification
*/
@Override
public BooleanToggleModification createCopy() {
return new BooleanToggleModification(this);
return new BooleanToggleModification();
}

/**
Expand All @@ -59,6 +51,10 @@ public BooleanToggleModification createCopy() {
* @return The inverted Boolean value, or null if the input is null
*/
@Override
@SuppressFBWarnings(
value = "NP_BOOLEAN_RETURN_NULL",
justification =
"Returning null for null input is intentional design for null-safety in modification chain")
protected Boolean modifyImplementationHook(Boolean input) {
if (input == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package de.rub.nds.modifiablevariable.bytearray;

import de.rub.nds.modifiablevariable.VariableModification;
import de.rub.nds.modifiablevariable.util.ArrayConverter;
import de.rub.nds.modifiablevariable.util.DataConverter;
import de.rub.nds.modifiablevariable.util.UnformattedByteArrayAdapter;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
Expand Down Expand Up @@ -96,7 +96,7 @@ protected byte[] modifyImplementationHook(byte[] input) {
if (input == null) {
return null;
}
return ArrayConverter.concatenate(input, bytesToAppend);
return DataConverter.concatenate(input, bytesToAppend);
}

/**
Expand Down Expand Up @@ -167,7 +167,7 @@ public boolean equals(Object obj) {
@Override
public String toString() {
return "ByteArrayAppendValueModification{bytesToAppend="
+ ArrayConverter.bytesToHexString(bytesToAppend)
+ DataConverter.bytesToHexString(bytesToAppend)
+ "}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package de.rub.nds.modifiablevariable.bytearray;

import de.rub.nds.modifiablevariable.VariableModification;
import de.rub.nds.modifiablevariable.util.ArrayConverter;
import de.rub.nds.modifiablevariable.util.DataConverter;
import jakarta.xml.bind.annotation.XmlRootElement;
import java.util.Arrays;

Expand Down Expand Up @@ -114,7 +114,7 @@ protected byte[] modifyImplementationHook(byte[] input) {
byte[] ret1 = Arrays.copyOf(input, deleteStartPosition);
if (deleteEndPosition < input.length) {
byte[] ret2 = Arrays.copyOfRange(input, deleteEndPosition, input.length);
return ArrayConverter.concatenate(ret1, ret2);
return DataConverter.concatenate(ret1, ret2);
}
return ret1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package de.rub.nds.modifiablevariable.bytearray;

import de.rub.nds.modifiablevariable.VariableModification;
import de.rub.nds.modifiablevariable.util.ArrayConverter;
import de.rub.nds.modifiablevariable.util.DataConverter;
import jakarta.xml.bind.annotation.XmlRootElement;

/**
Expand All @@ -31,15 +31,6 @@ public ByteArrayDuplicateModification() {
super();
}

/**
* Copy constructor for creating a deep copy of an existing modification.
*
* @param other The modification to copy
*/
public ByteArrayDuplicateModification(ByteArrayDuplicateModification other) {
super();
}

/**
* Creates a deep copy of this modification.
*
Expand All @@ -49,7 +40,7 @@ public ByteArrayDuplicateModification(ByteArrayDuplicateModification other) {
*/
@Override
public ByteArrayDuplicateModification createCopy() {
return new ByteArrayDuplicateModification(this);
return new ByteArrayDuplicateModification();
}

/**
Expand All @@ -72,7 +63,7 @@ protected byte[] modifyImplementationHook(byte[] input) {
if (input == null) {
return null;
}
return ArrayConverter.concatenate(input, input);
return DataConverter.concatenate(input, input);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package de.rub.nds.modifiablevariable.bytearray;

import de.rub.nds.modifiablevariable.VariableModification;
import de.rub.nds.modifiablevariable.util.ArrayConverter;
import de.rub.nds.modifiablevariable.util.DataConverter;
import de.rub.nds.modifiablevariable.util.UnformattedByteArrayAdapter;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
Expand Down Expand Up @@ -148,7 +148,7 @@ public boolean equals(Object obj) {
public String toString() {
return "ByteArrayExplicitValueModification{"
+ "explicitValue="
+ ArrayConverter.bytesToHexString(explicitValue)
+ DataConverter.bytesToHexString(explicitValue)
+ '}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package de.rub.nds.modifiablevariable.bytearray;

import de.rub.nds.modifiablevariable.VariableModification;
import de.rub.nds.modifiablevariable.util.ArrayConverter;
import de.rub.nds.modifiablevariable.util.DataConverter;
import de.rub.nds.modifiablevariable.util.UnformattedByteArrayAdapter;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
Expand Down Expand Up @@ -118,9 +118,9 @@ protected byte[] modifyImplementationHook(byte[] input) {
byte[] ret1 = Arrays.copyOf(input, insertPosition);
if (insertPosition < input.length) {
byte[] ret2 = Arrays.copyOfRange(input, insertPosition, input.length);
return ArrayConverter.concatenate(ret1, bytesToInsert, ret2);
return DataConverter.concatenate(ret1, bytesToInsert, ret2);
}
return ArrayConverter.concatenate(ret1, bytesToInsert);
return DataConverter.concatenate(ret1, bytesToInsert);
}

/**
Expand Down Expand Up @@ -215,7 +215,7 @@ public boolean equals(Object obj) {
public String toString() {
return "ByteArrayInsertModification{"
+ "bytesToInsert="
+ ArrayConverter.bytesToHexString(bytesToInsert)
+ DataConverter.bytesToHexString(bytesToInsert)
+ ", startPosition="
+ startPosition
+ '}';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package de.rub.nds.modifiablevariable.bytearray;

import de.rub.nds.modifiablevariable.VariableModification;
import de.rub.nds.modifiablevariable.util.ArrayConverter;
import de.rub.nds.modifiablevariable.util.DataConverter;
import de.rub.nds.modifiablevariable.util.UnformattedByteArrayAdapter;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
Expand Down Expand Up @@ -98,7 +98,7 @@ protected byte[] modifyImplementationHook(byte[] input) {
if (input == null) {
return null;
}
return ArrayConverter.concatenate(bytesToPrepend, input);
return DataConverter.concatenate(bytesToPrepend, input);
}

/**
Expand Down Expand Up @@ -169,7 +169,7 @@ public boolean equals(Object obj) {
@Override
public String toString() {
return "ByteArrayPrependValueModification{bytesToPrepend="
+ ArrayConverter.bytesToHexString(bytesToPrepend)
+ DataConverter.bytesToHexString(bytesToPrepend)
+ "}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package de.rub.nds.modifiablevariable.bytearray;

import de.rub.nds.modifiablevariable.VariableModification;
import de.rub.nds.modifiablevariable.util.ArrayConverter;
import de.rub.nds.modifiablevariable.util.DataConverter;
import de.rub.nds.modifiablevariable.util.UnformattedByteArrayAdapter;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
Expand Down Expand Up @@ -126,10 +126,10 @@ protected byte[] modifyImplementationHook(byte[] input) {
/**
* Gets the byte array used for the XOR operation.
*
* @return The XOR byte array
* @return A copy of the XOR byte array
*/
public byte[] getXor() {
return xor;
return xor == null ? null : xor.clone();
}

/**
Expand All @@ -138,7 +138,7 @@ public byte[] getXor() {
* @param xor The new XOR byte array
*/
public void setXor(byte[] xor) {
this.xor = xor;
this.xor = xor == null ? null : xor.clone();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes need to be reverted - we dont want them


/**
Expand Down Expand Up @@ -208,7 +208,7 @@ public boolean equals(Object obj) {
public String toString() {
return "ByteArrayXorModification{"
+ "xor="
+ ArrayConverter.bytesToHexString(xor)
+ DataConverter.bytesToHexString(xor)
+ ", startPosition="
+ startPosition
+ '}';
Expand Down
Loading