1 /* 2 * Copyright 2021 Code Intelligence GmbH 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <string> 20 21 constexpr const char *kBaseReproducer = 22 R"java(import java.lang.reflect.InvocationTargetException; 23 import java.lang.reflect.Method; 24 25 public class Crash_$0 { 26 static final String base64Bytes = "$1"; 27 28 public static void main(String[] args) { 29 ClassLoader.getSystemClassLoader().setDefaultAssertionStatus(true); 30 try { 31 Method fuzzerInitialize = $2.class.getMethod("fuzzerInitialize"); 32 fuzzerInitialize.invoke(null); 33 } catch (NoSuchMethodException ignored) { 34 try { 35 Method fuzzerInitialize = $2.class.getMethod("fuzzerInitialize", String[].class); 36 fuzzerInitialize.invoke(null, (Object) args); 37 } catch (NoSuchMethodException ignored1) { 38 } catch (IllegalAccessException | InvocationTargetException e) { 39 e.printStackTrace(); 40 System.exit(1); 41 } 42 } catch (IllegalAccessException | InvocationTargetException e) { 43 e.printStackTrace(); 44 System.exit(1); 45 } 46 $3 47 $2.fuzzerTestOneInput(input); 48 } 49 } 50 )java"; 51 52 constexpr const char *kTestOneInputWithBytes = 53 "byte[] input = java.util.Base64.getDecoder().decode(base64Bytes);"; 54 55 constexpr const char *kTestOneInputWithData = 56 "com.code_intelligence.jazzer.api.CannedFuzzedDataProvider input = new " 57 "com.code_intelligence.jazzer.api.CannedFuzzedDataProvider(base64Bytes)" 58 ";"; 59