testing with JAZZER
This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								testing/AufgabeEmailMatcher/EmailMatcher.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								testing/AufgabeEmailMatcher/EmailMatcher.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										17
									
								
								testing/AufgabeEmailMatcher/EmailMatcher.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								testing/AufgabeEmailMatcher/EmailMatcher.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
			
		||||
 | 
			
		||||
import java.util.regex.Pattern;
 | 
			
		||||
import java.util.regex.Matcher;
 | 
			
		||||
 | 
			
		||||
public class EmailMatcher {
 | 
			
		||||
 | 
			
		||||
 // Regex für Emailadressen
 | 
			
		||||
 static String emailRegex = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$";                 
 | 
			
		||||
 | 
			
		||||
 static Pattern pattern = Pattern.compile(emailRegex);
 | 
			
		||||
 
 | 
			
		||||
 static boolean isValidEmail(String email) {
 | 
			
		||||
     Matcher matcher = pattern.matcher(email);
 | 
			
		||||
     return matcher.matches();
 | 
			
		||||
 }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								testing/AufgabeEmailMatcher/EmailMatcherFuzzTest.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								testing/AufgabeEmailMatcher/EmailMatcherFuzzTest.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										14
									
								
								testing/AufgabeEmailMatcher/EmailMatcherFuzzTest.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								testing/AufgabeEmailMatcher/EmailMatcherFuzzTest.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
			
		||||
import com.code_intelligence.jazzer.api.FuzzedDataProvider;
 | 
			
		||||
import com.code_intelligence.jazzer.junit.FuzzTest;
 | 
			
		||||
 | 
			
		||||
import java.security.InvalidParameterException;
 | 
			
		||||
 | 
			
		||||
public class EmailMatcherFuzzTest {
 | 
			
		||||
    @FuzzTest
 | 
			
		||||
    public static void fuzzerTestOneInput(FuzzedDataProvider data) {
 | 
			
		||||
        String email = data.consumeString(100);
 | 
			
		||||
        if(EmailMatcher.isValidEmail(email)) {
 | 
			
		||||
            throw new InvalidParameterException("Valid email found!");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								testing/AufgabeEmailMatcher/ExampleMatcher.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								testing/AufgabeEmailMatcher/ExampleMatcher.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										18
									
								
								testing/AufgabeEmailMatcher/ExampleMatcher.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								testing/AufgabeEmailMatcher/ExampleMatcher.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
 | 
			
		||||
import java.util.regex.Pattern;
 | 
			
		||||
import java.util.regex.Matcher;
 | 
			
		||||
 | 
			
		||||
public class ExampleMatcher {
 | 
			
		||||
 | 
			
		||||
    public static void main(String[] args) {
 | 
			
		||||
 | 
			
		||||
        if (args.length<1) {
 | 
			
		||||
          System.out.println("No data provided as command line argument!");
 | 
			
		||||
        } else {
 | 
			
		||||
           if (EmailMatcher.isValidEmail(args[0])) { 
 | 
			
		||||
             System.out.println("Valid email address"); 
 | 
			
		||||
           }
 | 
			
		||||
         }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										12
									
								
								testing/AufgabeEmailMatcher/fuzz.bat
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								testing/AufgabeEmailMatcher/fuzz.bat
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
			
		||||
set CLASSPATH=.\;%JAVA_HOME%\lib;..\jars\jazzer_standalone.jar;..\jars\jazzer-junit-0.22.1.jar;..\jars\junit5-4.6.14.jar
 | 
			
		||||
 | 
			
		||||
javac EmailMatcher.java
 | 
			
		||||
javac EmailMatcherFuzzTest.java
 | 
			
		||||
 | 
			
		||||
java com.code_intelligence.jazzer.Jazzer --target_class=EmailMatcherFuzzTest
 | 
			
		||||
 | 
			
		||||
@rem ALTERNATIV Klassenpfad im Befehl angeben:
 | 
			
		||||
@rem javac -cp .\;%JAVA_HOME%\lib;..\jars\jazzer_standalone.jar EmailMatcher.java
 | 
			
		||||
@rem javac -cp .\;%JAVA_HOME%\lib;..\jars\jazzer_standalone.jar;..\jars\jazzer-junit-0.22.1.jar;..\jars\junit5-4.6.14.jar EmailMatcherFuzzTest.java
 | 
			
		||||
 | 
			
		||||
@rem java -cp .\;%JAVA_HOME%\lib;..\jars\jazzer_standalone.jar;..\jars\jazzer-junit-0.22.1.jar;..\jars\junit5-4.6.14.jar com.code_intelligence.jazzer.Jazzer --target_class=EmailMatcherFuzzTest
 | 
			
		||||
		Reference in New Issue
	
	Block a user