Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring + Insert Modification for Strings, Integer, BigInteger, Long + Some more Modifications for Long #182

Draft
wants to merge 52 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
a1cb9cc
Simplify all return statements in the equal() methods of the
C0D3D3V Oct 12, 2024
7f3fb2f
Replace constant string concatenations that are used as arguments to …
C0D3D3V Oct 12, 2024
4ee5dd0
Fix getModifiedCopy() of ByteArrayShuffleModification. Before the Mod…
C0D3D3V Oct 14, 2024
24750a5
Fix getModifiedCopy() of StringModifications, so that the methods act…
C0D3D3V Oct 14, 2024
31bfb2f
Make createRandomModification() more readable by using Enums for the …
C0D3D3V Oct 14, 2024
753cf1b
Create StingInsertValueModification class. Very similar to the ByteAr…
C0D3D3V Oct 14, 2024
457a67b
Fix Typo getinsertValue to getInsertValue
C0D3D3V Oct 14, 2024
0763c71
Merge remote-tracking branch 'origin/main' into daniel-main
C0D3D3V Nov 4, 2024
79c0218
Merge branch 'main' into daniel-main
ic0ns Nov 6, 2024
fc9d71b
fix bytesToLong
C0D3D3V Nov 12, 2024
8599859
Change the hashCode() function of all Modifications, so they have a b…
C0D3D3V Nov 20, 2024
9789ee7
Move the Moodifications from SSH-Fuzzer to ModifiableVaraible.
C0D3D3V Nov 21, 2024
413d6d4
fix tests
C0D3D3V Nov 21, 2024
ca69bbf
Change the Insert Prepend and Append Modifications of Integer, BigInt…
C0D3D3V Nov 21, 2024
3337cba
run formatter
C0D3D3V Nov 21, 2024
0e71c4c
Add simple insertion test for long and BigInteger
C0D3D3V Nov 21, 2024
8c67bff
Actually remove magic values from hashCode() method of all modificati…
C0D3D3V Nov 21, 2024
5f31e08
Add copy constructors to all modifiable variables
C0D3D3V Nov 29, 2024
9598313
Fix equals() of ModifiableLengthField (I broke it in last commit)
C0D3D3V Nov 29, 2024
580b528
Undo changes to use String.format() instead of string concatenation
C0D3D3V Nov 29, 2024
b153a9e
Change CopyConstructors. Throw NullPointerException instead of allowi…
C0D3D3V Dec 1, 2024
4b606ee
Add Project_Defaults.xml to repo. So everyone developing on this repo…
C0D3D3V Dec 1, 2024
509333d
Add FromFileModifications, so one can distinguish it from normal expl…
C0D3D3V Dec 2, 2024
da88f9b
Fix CreateCopy() of ByteExplicitValue
C0D3D3V Dec 2, 2024
be36e78
Add missing XmlElement for explicit from file modifications
C0D3D3V Dec 3, 2024
c073a2b
Add PathModification. Fix copy methods
C0D3D3V Dec 4, 2024
3bb9d9f
Add ModifiablePath utilities and missing XmlElement Annotations
C0D3D3V Dec 4, 2024
753aa9d
run formatter
C0D3D3V Dec 4, 2024
6566fb9
Add PathInsertDirectorySeparatorModification
C0D3D3V Dec 5, 2024
95bb1ec
Fix some comments
C0D3D3V Dec 5, 2024
4ded76c
Add PathExplicitValueModification and
C0D3D3V Dec 5, 2024
f9b1a01
Be kind to negative and null count in PathInsertDirectoryTraversalMod…
C0D3D3V Dec 5, 2024
7309434
Add some toString() methods. Change backslashEscapeString() to return…
C0D3D3V Dec 6, 2024
149ceb2
Replace StringBuffer with StringBuilder in backslashEscapeString. To …
C0D3D3V Dec 6, 2024
882c926
fix logger of ModifiableByteArrayTest
C0D3D3V Dec 6, 2024
09a055a
Make ByteArrayDeleteModification more useful by allowing more random …
C0D3D3V Dec 6, 2024
e688cae
Fix tests because I changed the behavior of ByteArrayDeleteModification
C0D3D3V Dec 6, 2024
0ba036f
Fix ByteArrayShuffleModification to also shuffle byte arrays with len…
C0D3D3V Dec 6, 2024
2adcc69
Also print modifications in toString() methods. Not very nicely imple…
C0D3D3V Dec 9, 2024
272f6b6
Just some renaming of parameters
C0D3D3V Dec 9, 2024
d613cdd
Change behavior of ByteArrayXorModification. Allow arbitrary start po…
C0D3D3V Dec 9, 2024
ad139d1
Change behaviour of reduceToOriginalValue()
C0D3D3V Dec 12, 2024
564be80
Add Swap Endian Modifications for long and integer
C0D3D3V Dec 13, 2024
6a0d506
Allow multiple modifications on one modifiable variable
C0D3D3V Dec 13, 2024
3a3a2ad
Fi some overflows
C0D3D3V Dec 16, 2024
dc19dd4
Add softlySetValue methods for all modifiable variables.
C0D3D3V Dec 18, 2024
e4237b5
Add softlySetValue with alwaysSet option
C0D3D3V Dec 18, 2024
8684f65
Rename createRandomModification to setRandomModification, and make it…
C0D3D3V Dec 20, 2024
ff01b27
Rename longToUint64Bytes to longToEightBytes since it can also be use…
C0D3D3V Dec 30, 2024
c0fb825
run linter
C0D3D3V Dec 30, 2024
2ca2f90
Fix fourBytesToInt
C0D3D3V Dec 30, 2024
01f2f20
Fix fourBytesToInt but for real -.-
C0D3D3V Dec 30, 2024
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
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ nbproject/
nbactions.xml.project
nbactions.xml

# IntelliJ
.idea/
### IntelliJ IDEA ###
.idea/*
!.idea/inspectionProfiles
!.idea/runConfigurations
*.iws
*.iml
*.ipr

# VS Code
.vscode/
Expand Down
323 changes: 323 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

public class FileConfigurationException extends RuntimeException {

public FileConfigurationException() {}
public FileConfigurationException() {
super();
}

public FileConfigurationException(Exception ex) {
super(ex);
Expand Down
409 changes: 266 additions & 143 deletions src/main/java/de/rub/nds/modifiablevariable/ModifiableVariable.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
import de.rub.nds.modifiablevariable.bytearray.ModifiableByteArray;
import de.rub.nds.modifiablevariable.integer.ModifiableInteger;
import de.rub.nds.modifiablevariable.longint.ModifiableLong;
import de.rub.nds.modifiablevariable.path.ModifiablePath;
import de.rub.nds.modifiablevariable.singlebyte.ModifiableByte;
import de.rub.nds.modifiablevariable.string.ModifiableString;
import java.math.BigInteger;

public class ModifiableVariableFactory {
public final class ModifiableVariableFactory {

public static ModifiableBigInteger createBigIntegerModifiableVariable() {
return new ModifiableBigInteger();
Expand All @@ -38,61 +39,297 @@ public static ModifiableLong createLongModifiableVariable() {
return new ModifiableLong();
}

public static ModifiableBoolean createBooleanModifiableVariable() {
return new ModifiableBoolean();
}

public static ModifiableString createStringModifiableVariable() {
return new ModifiableString();
}

public static ModifiablePath createPathModifiableVariable() {
return new ModifiablePath();
}

public static ModifiableBigInteger safelySetValue(ModifiableBigInteger mv, BigInteger value) {
if (mv == null) {
mv = new ModifiableBigInteger();
return new ModifiableBigInteger(value);
}
mv.setOriginalValue(value);
return mv;
}

/**
* Returns only a ModifiableBigInteger with the value, if the given mv is null or the original
* value of the mv is null
*/
public static ModifiableBigInteger softlySetValue(ModifiableBigInteger mv, BigInteger value) {
if (mv == null) {
return new ModifiableBigInteger(value);
} else if (mv.getOriginalValue() == null) {
mv.setOriginalValue(value);
}
return mv;
}

/**
* Returns only a ModifiableBigInteger with the value, if the given mv is null or the original
* value of the mv is null or alwaysSet is true
*/
public static ModifiableBigInteger softlySetValue(
ModifiableBigInteger mv, BigInteger value, boolean alwaysSet) {
if (mv == null) {
return new ModifiableBigInteger(value);
} else if (alwaysSet || mv.getOriginalValue() == null) {
mv.setOriginalValue(value);
}
return mv;
}

public static ModifiableString safelySetValue(ModifiableString mv, String value) {
if (mv == null) {
mv = new ModifiableString();
return new ModifiableString(value);
}
mv.setOriginalValue(value);
return mv;
}

/**
* Returns only a ModifiableString with the value, if the given mv is null or the original value
* of the mv is null
*/
public static ModifiableString softlySetValue(ModifiableString mv, String value) {
if (mv == null) {
return new ModifiableString(value);
} else if (mv.getOriginalValue() == null) {
mv.setOriginalValue(value);
}
return mv;
}

/**
* Returns only a ModifiableString with the value, if the given mv is null or the original value
* of the mv is null or alwaysSet is true
*/
public static ModifiableString softlySetValue(
ModifiableString mv, String value, boolean alwaysSet) {
if (mv == null) {
return new ModifiableString(value);
} else if (alwaysSet || mv.getOriginalValue() == null) {
mv.setOriginalValue(value);
}
return mv;
}

public static ModifiableInteger safelySetValue(ModifiableInteger mv, Integer value) {
if (mv == null) {
mv = new ModifiableInteger();
return new ModifiableInteger(value);
}
mv.setOriginalValue(value);
return mv;
}

/**
* Returns only a ModifiableInteger with the value, if the given mv is null or the original
* value of the mv is null
*/
public static ModifiableInteger softlySetValue(ModifiableInteger mv, Integer value) {
if (mv == null) {
return new ModifiableInteger(value);
} else if (mv.getOriginalValue() == null) {
mv.setOriginalValue(value);
}
return mv;
}

/**
* Returns only a ModifiableInteger with the value, if the given mv is null or the original
* value of the mv is null or alwaysSet is true
*/
public static ModifiableInteger softlySetValue(
ModifiableInteger mv, Integer value, boolean alwaysSet) {
if (mv == null) {
return new ModifiableInteger(value);
} else if (alwaysSet || mv.getOriginalValue() == null) {
mv.setOriginalValue(value);
}
return mv;
}

public static ModifiableByte safelySetValue(ModifiableByte mv, Byte value) {
if (mv == null) {
mv = new ModifiableByte();
return new ModifiableByte(value);
}
mv.setOriginalValue(value);
return mv;
}

/**
* Returns only a ModifiableByte with the value, if the given mv is null or the original value
* of the mv is null
*/
public static ModifiableByte softlySetValue(ModifiableByte mv, Byte value) {
if (mv == null) {
return new ModifiableByte(value);
} else if (mv.getOriginalValue() == null) {
mv.setOriginalValue(value);
}
return mv;
}

/**
* Returns only a ModifiableByte with the value, if the given mv is null or the original value
* of the mv is null or alwaysSet is true
*/
public static ModifiableByte softlySetValue(ModifiableByte mv, Byte value, boolean alwaysSet) {
if (mv == null) {
return new ModifiableByte(value);
} else if (alwaysSet || mv.getOriginalValue() == null) {
mv.setOriginalValue(value);
}
return mv;
}

public static ModifiableByteArray safelySetValue(ModifiableByteArray mv, byte[] value) {
if (mv == null) {
mv = new ModifiableByteArray();
return new ModifiableByteArray(value);
}
mv.setOriginalValue(value);
return mv;
}

/**
* Returns only a ModifiableByteArray with the value, if the given mv is null or the original
* value of the mv is null
*/
public static ModifiableByteArray softlySetValue(ModifiableByteArray mv, byte[] value) {
if (mv == null) {
return new ModifiableByteArray(value);
} else if (mv.getOriginalValue() == null) {
mv.setOriginalValue(value);
}
return mv;
}

/**
* Returns only a ModifiableByteArray with the value, if the given mv is null or the original
* value of the mv is null or alwaysSet is true
*/
public static ModifiableByteArray softlySetValue(
ModifiableByteArray mv, byte[] value, boolean alwaysSet) {
if (mv == null) {
return new ModifiableByteArray(value);
} else if (alwaysSet || mv.getOriginalValue() == null) {
mv.setOriginalValue(value);
}
return mv;
}

public static ModifiableLong safelySetValue(ModifiableLong mv, Long value) {
if (mv == null) {
mv = new ModifiableLong();
return new ModifiableLong(value);
}
mv.setOriginalValue(value);
return mv;
}

/**
* Returns only a ModifiableLong with the value, if the given mv is null or the original value
* of the mv is null
*/
public static ModifiableLong softlySetValue(ModifiableLong mv, Long value) {
if (mv == null) {
return new ModifiableLong(value);
} else if (mv.getOriginalValue() == null) {
mv.setOriginalValue(value);
}
return mv;
}

/**
* Returns only a ModifiableLong with the value, if the given mv is null or the original value
* of the mv is null or alwaysSet is true
*/
public static ModifiableLong softlySetValue(ModifiableLong mv, Long value, boolean alwaysSet) {
if (mv == null) {
return new ModifiableLong(value);
} else if (alwaysSet || mv.getOriginalValue() == null) {
mv.setOriginalValue(value);
}
return mv;
}

public static ModifiableBoolean safelySetValue(ModifiableBoolean mv, Boolean value) {
if (mv == null) {
mv = new ModifiableBoolean();
return new ModifiableBoolean(value);
}
mv.setOriginalValue(value);
return mv;
}

/**
* Returns only a ModifiableBoolean with the value, if the given mv is null or the original
* value of the mv is null
*/
public static ModifiableBoolean softlySetValue(ModifiableBoolean mv, Boolean value) {
if (mv == null) {
return new ModifiableBoolean(value);
} else if (mv.getOriginalValue() == null) {
mv.setOriginalValue(value);
}
return mv;
}

/**
* Returns only a ModifiableBoolean with the value, if the given mv is null or the original
* value of the mv is null or alwaysSet is true
*/
public static ModifiableBoolean softlySetValue(
ModifiableBoolean mv, Boolean value, boolean alwaysSet) {
if (mv == null) {
return new ModifiableBoolean(value);
} else if (alwaysSet || mv.getOriginalValue() == null) {
mv.setOriginalValue(value);
}
return mv;
}

public static ModifiablePath safelySetValue(ModifiablePath mv, String value) {
if (mv == null) {
return new ModifiablePath(value);
}
mv.setOriginalValue(value);
return mv;
}

private ModifiableVariableFactory() {}
/**
* Returns only a ModifiablePath with the value, if the given mv is null or the original value
* of the mv is null
*/
public static ModifiablePath softlySetValue(ModifiablePath mv, String value) {
if (mv == null) {
return new ModifiablePath(value);
} else if (mv.getOriginalValue() == null) {
mv.setOriginalValue(value);
}
return mv;
}

/**
* Returns only a ModifiablePath with the value, if the given mv is null or the original value
* of the mv is null or alwaysSet is true
*/
public static ModifiablePath softlySetValue(
ModifiablePath mv, String value, boolean alwaysSet) {
if (mv == null) {
return new ModifiablePath(value);
} else if (alwaysSet || mv.getOriginalValue() == null) {
mv.setOriginalValue(value);
}
return mv;
}

private ModifiableVariableFactory() {
super();
}
}
Loading