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

Docker Example project #894

Open
rushey1 opened this issue Feb 6, 2024 · 1 comment
Open

Docker Example project #894

rushey1 opened this issue Feb 6, 2024 · 1 comment

Comments

@rushey1
Copy link

rushey1 commented Feb 6, 2024

In the docker example there is a standard java project which didn't help me follow the example.

Can you please provide a simple java class to follow?
For example, assume we have the following Triangle class in Triangle/src/main/java/org/triangleValidator folder.
How can I use docker to fuzz this class for 2 minutes and start with sample inputs in /corpus/corpusinput.txt and place produced results in /corpus folder?

package org.triangleValidator;
import java.util.Scanner;

public class Triangle
{
public static boolean isValidTriangle(int side1, int side2, int side3) {
// Check if the sum of any two sides is greater than the third side
return (side1 + side2 > side3) && (side1 + side3 > side2) && (side2 + side3 > side1);
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

    System.out.println("Enter the lengths of 3 sides:");
    int side1 = scanner.nextInt();
    int side2 = scanner.nextInt();
    int side3 = scanner.nextInt();

    if (isValidTriangle(side1, side2, side3)) {
        System.out.println("Valid triangle!");
    } else {
        System.out.println("Not a valid triangle!");
    }
}

}

Thank you

@bertschneider
Copy link
Contributor

The docker image is a helpful starting point if you don't want or can't install Jazzer locally.

If you're starting out with Jazzer and struggle with general Docker usage, I suggest to use a locally installed Jazzer version (see GitHub releases), as that reduces complexity considerably.

Regardless of how you invoke Jazzer, you need to write a fuzz target (fuzzerTestOneInput method, e.g. this example, or JUnit 5 test function, e.g. this example project), compile everything and put it on the Java classpath when starting Jazzer.

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

No branches or pull requests

2 participants