Skip to content

Commit

Permalink
jackson-dataformats-binary: Add loops to parser method calling
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Chan <[email protected]>
  • Loading branch information
arthurscchan committed Dec 14, 2023
1 parent 974091f commit b102aa9
Show file tree
Hide file tree
Showing 5 changed files with 305 additions and 290 deletions.
119 changes: 61 additions & 58 deletions projects/jackson-dataformats-binary/AvroParserFuzzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class AvroParserFuzzer {
public static void fuzzerTestOneInput(FuzzedDataProvider data) {
try {
Integer choice = data.consumeInt(1, 19);
Integer iteration = data.consumeInt(1, 100);

// Retrieve set of AvroMapper.Feature
EnumSet<AvroParser.Feature> featureSet = EnumSet.allOf(AvroParser.Feature.class);
Expand Down Expand Up @@ -54,64 +55,66 @@ public static void fuzzerTestOneInput(FuzzedDataProvider data) {
((AvroMapper) mapper).getFactory().createParser(data.consumeRemainingAsBytes());

// Fuzz methods of AvroParser
switch (choice) {
case 1:
parser.currentName();
break;
case 2:
parser.currentTokenLocation();
break;
case 3:
parser.currentLocation();
break;
case 4:
parser.isExpectedStartArrayToken();
break;
case 5:
parser.isExpectedNumberIntToken();
break;
case 6:
parser.nextToken();
break;
case 7:
parser.nextTextValue();
break;
case 8:
parser.getText();
break;
case 9:
parser.getTextCharacters();
break;
case 10:
parser.getTextLength();
break;
case 11:
parser.getTextOffset();
break;
case 12:
parser.getNumberType();
break;
case 13:
parser.getNumberValue();
break;
case 14:
parser.getIntValue();
break;
case 15:
parser.getLongValue();
break;
case 16:
parser.getBigIntegerValue();
break;
case 17:
parser.getFloatValue();
break;
case 18:
parser.getDoubleValue();
break;
case 19:
parser.getDecimalValue();
break;
while (iteration-- > 0) {
switch (choice) {
case 1:
parser.currentName();
break;
case 2:
parser.currentTokenLocation();
break;
case 3:
parser.currentLocation();
break;
case 4:
parser.isExpectedStartArrayToken();
break;
case 5:
parser.isExpectedNumberIntToken();
break;
case 6:
parser.nextToken();
break;
case 7:
parser.nextTextValue();
break;
case 8:
parser.getText();
break;
case 9:
parser.getTextCharacters();
break;
case 10:
parser.getTextLength();
break;
case 11:
parser.getTextOffset();
break;
case 12:
parser.getNumberType();
break;
case 13:
parser.getNumberValue();
break;
case 14:
parser.getIntValue();
break;
case 15:
parser.getLongValue();
break;
case 16:
parser.getBigIntegerValue();
break;
case 17:
parser.getFloatValue();
break;
case 18:
parser.getDoubleValue();
break;
case 19:
parser.getDecimalValue();
break;
}
}

parser.close();
Expand Down
119 changes: 61 additions & 58 deletions projects/jackson-dataformats-binary/CborParserFuzzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class CborParserFuzzer {
public static void fuzzerTestOneInput(FuzzedDataProvider data) {
try {
Integer choice = data.consumeInt(1, 19);
Integer iteration = data.consumeInt(1, 100);

// Retrieve set of CBORParser.Feature
EnumSet<CBORParser.Feature> featureSet = EnumSet.allOf(CBORParser.Feature.class);
Expand All @@ -47,64 +48,66 @@ public static void fuzzerTestOneInput(FuzzedDataProvider data) {
((CBORMapper) mapper).getFactory().createParser(data.consumeRemainingAsBytes());

// Fuzz methods of CBORParser
switch (choice) {
case 1:
parser.currentName();
break;
case 2:
parser.currentTokenLocation();
break;
case 3:
parser.currentLocation();
break;
case 4:
parser.isExpectedStartArrayToken();
break;
case 5:
parser.isExpectedNumberIntToken();
break;
case 6:
parser.nextToken();
break;
case 7:
parser.nextTextValue();
break;
case 8:
parser.getText();
break;
case 9:
parser.getTextCharacters();
break;
case 10:
parser.getTextLength();
break;
case 11:
parser.getTextOffset();
break;
case 12:
parser.getNumberType();
break;
case 13:
parser.getNumberValue();
break;
case 14:
parser.getIntValue();
break;
case 15:
parser.getLongValue();
break;
case 16:
parser.getBigIntegerValue();
break;
case 17:
parser.getFloatValue();
break;
case 18:
parser.getDoubleValue();
break;
case 19:
parser.getDecimalValue();
break;
while (iteration-- > 0) {
switch (choice) {
case 1:
parser.currentName();
break;
case 2:
parser.currentTokenLocation();
break;
case 3:
parser.currentLocation();
break;
case 4:
parser.isExpectedStartArrayToken();
break;
case 5:
parser.isExpectedNumberIntToken();
break;
case 6:
parser.nextToken();
break;
case 7:
parser.nextTextValue();
break;
case 8:
parser.getText();
break;
case 9:
parser.getTextCharacters();
break;
case 10:
parser.getTextLength();
break;
case 11:
parser.getTextOffset();
break;
case 12:
parser.getNumberType();
break;
case 13:
parser.getNumberValue();
break;
case 14:
parser.getIntValue();
break;
case 15:
parser.getLongValue();
break;
case 16:
parser.getBigIntegerValue();
break;
case 17:
parser.getFloatValue();
break;
case 18:
parser.getDoubleValue();
break;
case 19:
parser.getDecimalValue();
break;
}
}

parser.close();
Expand Down
119 changes: 61 additions & 58 deletions projects/jackson-dataformats-binary/IonParserFuzzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class IonParserFuzzer {
public static void fuzzerTestOneInput(FuzzedDataProvider data) {
try {
Integer choice = data.consumeInt(1, 19);
Integer iteration = data.consumeInt(1, 100);

// Retrieve set of IonParser.Feature
EnumSet<IonParser.Feature> featureSet = EnumSet.allOf(IonParser.Feature.class);
Expand Down Expand Up @@ -58,64 +59,66 @@ public static void fuzzerTestOneInput(FuzzedDataProvider data) {
JsonParser parser = ((IonObjectMapper) mapper).getFactory().createParser(byteArray);

// Fuzz methods of IonParser
switch (choice) {
case 1:
parser.currentName();
break;
case 2:
parser.currentTokenLocation();
break;
case 3:
parser.currentLocation();
break;
case 4:
parser.isExpectedStartArrayToken();
break;
case 5:
parser.isExpectedNumberIntToken();
break;
case 6:
parser.nextToken();
break;
case 7:
parser.nextTextValue();
break;
case 8:
parser.getText();
break;
case 9:
parser.getTextCharacters();
break;
case 10:
parser.getTextLength();
break;
case 11:
parser.getTextOffset();
break;
case 12:
parser.getNumberType();
break;
case 13:
parser.getNumberValue();
break;
case 14:
parser.getIntValue();
break;
case 15:
parser.getLongValue();
break;
case 16:
parser.getBigIntegerValue();
break;
case 17:
parser.getFloatValue();
break;
case 18:
parser.getDoubleValue();
break;
case 19:
parser.getDecimalValue();
break;
while (iteration-- > 0) {
switch (choice) {
case 1:
parser.currentName();
break;
case 2:
parser.currentTokenLocation();
break;
case 3:
parser.currentLocation();
break;
case 4:
parser.isExpectedStartArrayToken();
break;
case 5:
parser.isExpectedNumberIntToken();
break;
case 6:
parser.nextToken();
break;
case 7:
parser.nextTextValue();
break;
case 8:
parser.getText();
break;
case 9:
parser.getTextCharacters();
break;
case 10:
parser.getTextLength();
break;
case 11:
parser.getTextOffset();
break;
case 12:
parser.getNumberType();
break;
case 13:
parser.getNumberValue();
break;
case 14:
parser.getIntValue();
break;
case 15:
parser.getLongValue();
break;
case 16:
parser.getBigIntegerValue();
break;
case 17:
parser.getFloatValue();
break;
case 18:
parser.getDoubleValue();
break;
case 19:
parser.getDecimalValue();
break;
}
}

parser.close();
Expand Down
Loading

0 comments on commit b102aa9

Please sign in to comment.