-
Notifications
You must be signed in to change notification settings - Fork 45
Closed
Labels
comp-fuzzingIssue is related to the fuzzingIssue is related to the fuzzingctg-bugIssue is a bugIssue is a bug
Description
Description
Fuzzer creates values of private class. This leads to reflection-using by codegen, but fuzzer shouldn't create any tests using reflection.
To Reproduce
Try to generate code for test method:
public class AccessibleObjects {
public boolean test(Inn.Node n) {
return n.value * n.value == 36;
}
private static class Inn {
static class Node {
public int value;
public Node() {
}
}
}
}Expected behavior
In this case fuzzer should not create any test, because Node object cannot be created by fuzzer (the Inn class is private).
Actual behavior
Fuzzer generates test with reflection that leads to another problem: #1629
public void testTestReturnsFalse() throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchFieldException {
AccessibleObjects accessibleObjects = new AccessibleObjects();
Class nodeClazz = Class.forName("sanity.AccessibleObjects$Inn$Node");
Constructor nodeConstructor = nodeClazz.getDeclaredConstructor();
nodeConstructor.setAccessible(true);
Object[] nodeConstructorArguments = new Object[0];
Object node = nodeConstructor.newInstance(nodeConstructorArguments);
Field valueField = nodeClazz.getDeclaredField("value");
valueField.setAccessible(true);
valueField.get(node) = 37;
Class accessibleObjectsClazz = Class.forName("sanity.AccessibleObjects");
Method testMethod = accessibleObjectsClazz.getDeclaredMethod("test", nodeClazz);
testMethod.setAccessible(true);
Object[] testMethodArguments = new Object[1];
testMethodArguments[0] = node;
boolean actual = ((Boolean) testMethod.invoke(accessibleObjects, testMethodArguments));
assertFalse(actual);
}Environment
Fuzzing is set to 100%
Additional context
Looks like the problem is caused by different implementations of isAccessbile logic. We need to resolve #1507 to reduce errors like this.
Metadata
Metadata
Assignees
Labels
comp-fuzzingIssue is related to the fuzzingIssue is related to the fuzzingctg-bugIssue is a bugIssue is a bug
Type
Projects
Status
Done