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

Open
wants to merge 44 commits into
base: main
Choose a base branch
from

Conversation

C0D3D3V
Copy link

@C0D3D3V C0D3D3V commented Nov 4, 2024

⚠️ Warning: Downward compatibility is no longer given with this pull request. Old serialized modifiable variables with modifications can no longer be deserialized without changes to the XML.

  • Adds the possibility to add multiple modifications to a Modifiable Variable.

Includes some refactoring:

  • To make the switch cases more readable
  • To simplify some statements / conditions
  • To make linter happy

Adds some more modifications, including StingInsertValueModification

Modification classes. Also simplify some conditions in validateAssertions() and modify() methods.
…logging methods with parameterized log messages
…ually return modified copies and not only the same modification.
…modification types instead of constant integers. This also unifies the method in all factories.

Also remove unnecessary semicolons from previous commit.
…rayInsertModification class. To make the String modifiable variable more complete. Naming it InsertValue to keep it consistent with append and prepend, though the other Modification classes put "value" only behind Explicit Modifications.
* origin/main:
  build(deps): bump de.rub.nds:protocol-toolkit-bom from 4.2.1 to 4.2.4
  ci: Use Maven 3.9.9
  ci: Switch to recordCoverage plugin
  build(deps): bump de.rub.nds:protocol-toolkit-bom from 4.2.0 to 4.2.1
  build(deps): bump de.rub.nds:protocol-toolkit-bom from 4.1.17 to 4.2.0
  build(deps): bump de.rub.nds:protocol-toolkit-bom from 4.1.16 to 4.1.17
  build(deps): bump de.rub.nds:protocol-toolkit-bom from 4.1.10 to 4.1.16
  build(deps): bump de.rub.nds:protocol-toolkit-bom from 4.1.9 to 4.1.10
  release: Prepare for next development iteration
  release: v4.2.2
  Added suppressing adapters to leave default values out of XML
  build(deps): bump de.rub.nds:protocol-toolkit-bom from 4.1.7 to 4.1.9
  build(deps): bump de.rub.nds:protocol-toolkit-bom from 4.1.6 to 4.1.7
  fixed and supressed warning
  added generics
  added supression of warning as its a test with reflections
  closes scanner after use
Copy link
Contributor

@ic0ns ic0ns left a comment

Choose a reason for hiding this comment

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

Rest looks pretty good

ic0ns
ic0ns previously approved these changes Nov 5, 2024
@ic0ns ic0ns enabled auto-merge November 5, 2024 18:34
ic0ns and others added 4 commits November 6, 2024 14:32
…it more semantic. There is no real reason for this change. Now the magic numbers, are a little bit less magic (just counting up the different modifications)
SSH-Fuzzer hat defined some modificiations using the
explicitValueModificationGenerator() method. It makes not much sense for
me to define them not well structured in the SSH-Fuzzer (and abusing explicit
modifications for this).

The Mutations that got moved over are:
- Append
- Insert
- Prepend
for Integer, BigInteger, ByteArray and Long
These Modifications do currently produce no usefull values for negative
parameters, but if someone needs this, he should revise this. For our
work, we mostly need only positiv values.

I also added the missing modifications for long, since SFTP uses longs.
And also added multiply modifiaction to integer.
auto-merge was automatically disabled November 21, 2024 08:36

Head branch was pushed to by a user without write access

@C0D3D3V
Copy link
Author

C0D3D3V commented Nov 21, 2024

I have also changed the behavior of the insert modification of byteArray to adopt the behavioir of the new insert modifications, namely if the insert position is outside the possible, it behaves like an append or prepend instead of outputting the original value. Except that it still wraps around like before, as long as the negative position is greater than -2*input.length. Maybe I will add the wrap around to the other insert modifications too.

That got me thinking, I think I'll change the behavior completely, so that the insert works for arbitrary positions, which would be better for random positions that don't necessarily take the length of the original value into account.

…eger and Long, so that they actually make sense. Before the calculations where copied form SSH-Fuzzer, but they do not really produce values that makes any sense. Because the values were shifted and then a new value were added, but adding a value to a binary integer, does not produce the expected insertion. Now we insert the values bitwise, I see a use-case for this. e.g. in mask fields.

Also let the insert position wrap around in all insert modifications.  For int and long it wraps around the bit size.
@C0D3D3V C0D3D3V changed the title Refactoring + Insert Modification for Strings Refactoring + Insert Modification for Strings, Integer, BigInteger, Long + Some more Modifications for Long Nov 21, 2024
PathExplicitValueFromFileModification
…make it a little bit faster, since we do not need the synchronisation of StringBuffer.

fix test, since I changed toString of ModifiableByteArray
…inputs, that still results in modifications.

Add Delete modification for Path and Strings.
…mented using innerToString() but good enough for now.
…sition, that wraps around. And always apply xor, even if xor is to long for original value -> cut of to long part. This probably does not match the expected behavior of all users, so further improvements can be made in the future.
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