-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add mutators for lowercase/uppercase expanding strings
- Loading branch information
Showing
4 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...ain/java/com/endava/cats/fuzzer/special/mutators/impl/LowercaseExpandingBytesMutator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.endava.cats.fuzzer.special.mutators.impl; | ||
|
||
import com.endava.cats.fuzzer.special.mutators.api.BodyMutator; | ||
import com.endava.cats.generator.simple.UnicodeGenerator; | ||
import com.endava.cats.util.CatsUtil; | ||
import com.endava.cats.util.JsonUtils; | ||
import jakarta.inject.Singleton; | ||
|
||
@Singleton | ||
public class LowercaseExpandingBytesMutator implements BodyMutator { | ||
@Override | ||
public String mutate(String inputJson, String selectedField) { | ||
int length = String.valueOf(JsonUtils.getVariableFromJson(inputJson, selectedField)).length(); | ||
String generated = CatsUtil.selectRandom(UnicodeGenerator.getLowercaseExpandingBytes(), length); | ||
return CatsUtil.justReplaceField(inputJson, selectedField, generated).json(); | ||
} | ||
|
||
@Override | ||
public String description() { | ||
return "replace field with strings that expand bytes when lowercased"; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...in/java/com/endava/cats/fuzzer/special/mutators/impl/LowercaseExpandingLengthMutator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.endava.cats.fuzzer.special.mutators.impl; | ||
|
||
import com.endava.cats.fuzzer.special.mutators.api.BodyMutator; | ||
import com.endava.cats.generator.simple.UnicodeGenerator; | ||
import com.endava.cats.util.CatsUtil; | ||
import com.endava.cats.util.JsonUtils; | ||
import jakarta.inject.Singleton; | ||
|
||
@Singleton | ||
public class LowercaseExpandingLengthMutator implements BodyMutator { | ||
@Override | ||
public String mutate(String inputJson, String selectedField) { | ||
int length = String.valueOf(JsonUtils.getVariableFromJson(inputJson, selectedField)).length(); | ||
String generated = CatsUtil.selectRandom(UnicodeGenerator.getLowercaseExpandingLength(), length); | ||
return CatsUtil.justReplaceField(inputJson, selectedField, generated).json(); | ||
} | ||
|
||
@Override | ||
public String description() { | ||
return "replace field with strings that expand length when lowercased"; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...ain/java/com/endava/cats/fuzzer/special/mutators/impl/UppercaseExpandingBytesMutator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.endava.cats.fuzzer.special.mutators.impl; | ||
|
||
import com.endava.cats.fuzzer.special.mutators.api.BodyMutator; | ||
import com.endava.cats.generator.simple.UnicodeGenerator; | ||
import com.endava.cats.util.CatsUtil; | ||
import com.endava.cats.util.JsonUtils; | ||
import jakarta.inject.Singleton; | ||
|
||
@Singleton | ||
public class UppercaseExpandingBytesMutator implements BodyMutator { | ||
@Override | ||
public String mutate(String inputJson, String selectedField) { | ||
int length = String.valueOf(JsonUtils.getVariableFromJson(inputJson, selectedField)).length(); | ||
String generated = CatsUtil.selectRandom(UnicodeGenerator.getUppercaseExpandingBytes(), length); | ||
return CatsUtil.justReplaceField(inputJson, selectedField, generated).json(); | ||
} | ||
|
||
@Override | ||
public String description() { | ||
return "replace field with strings that expand bytes when uppercased"; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...in/java/com/endava/cats/fuzzer/special/mutators/impl/UppercaseExpandingLengthMutator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.endava.cats.fuzzer.special.mutators.impl; | ||
|
||
import com.endava.cats.fuzzer.special.mutators.api.BodyMutator; | ||
import com.endava.cats.generator.simple.UnicodeGenerator; | ||
import com.endava.cats.util.CatsUtil; | ||
import com.endava.cats.util.JsonUtils; | ||
import jakarta.inject.Singleton; | ||
|
||
@Singleton | ||
public class UppercaseExpandingLengthMutator implements BodyMutator { | ||
@Override | ||
public String mutate(String inputJson, String selectedField) { | ||
int length = String.valueOf(JsonUtils.getVariableFromJson(inputJson, selectedField)).length(); | ||
String generated = CatsUtil.selectRandom(UnicodeGenerator.getUppercaseExpandingLength(), length); | ||
return CatsUtil.justReplaceField(inputJson, selectedField, generated).json(); | ||
} | ||
|
||
@Override | ||
public String description() { | ||
return "replace field with strings that expand length when uppercased"; | ||
} | ||
} |