Repository navigation
Socket.connect and Files.readAllBytes produce errors in Concrete execution #1314
Copy link
Copy link
Open
Labels
ctg-bugIssue is a bugIssue is a bugpriority-top-focusTop priority chosen by dev teamTop priority chosen by dev team
Description
Description
Socket.connect and Files.readAllBytes produce errors in Concrete execution
To Reproduce
- Install Build from the unit-test-bot/rc112022 branch into IDEA 2022.2.3
- Open UTBotJava project
- Check File -> Settings are default: 95% Symbolic execution
- Generate tests for the following class:
public class SecurityCheck {
public int read(File path) throws IOException {
byte[] bytes = Files.readAllBytes(path.toPath());
return bytes.length;
}
public int connect(Socket socket) throws IOException {
socket.connect(new InetSocketAddress("0.0.0.0", 22));
return 0;
}
}Expected behavior
Tests are supposed to be generated without error reports.
Actual behavior
An error test is generated with information about errors in the concrete executor.
Visual proofs (screenshots, logs, images)
public final class SecurityCheckTest {
///region Test suites for executable org.utbot.examples.securitycheck.SecurityCheck.connect
///region
@Test
@Disabled(value = "Disabled due to sandbox")
public void testConnect1() throws IOException {
SecurityCheck securityCheck = new SecurityCheck();
Socket socket = new Socket("jkmqh", 568849899, true);
/* This test fails because method [org.utbot.examples.securitycheck.SecurityCheck.connect] produces [java.security.AccessControlException: access denied ("java.net.SocketPermission" "jkmqh" "resolve")] */
}
@Test
@Disabled(value = "Disabled due to sandbox")
public void testConnect2() throws IOException {
SecurityCheck securityCheck = new SecurityCheck();
Socket socket = new Socket("hlcoj", 1525745488);
/* This test fails because method [org.utbot.examples.securitycheck.SecurityCheck.connect] produces [java.security.AccessControlException: access denied ("java.net.SocketPermission" "hlcoj" "resolve")] */
}
@Test
@Disabled(value = "Disabled due to sandbox")
public void testConnect3() throws IOException {
SecurityCheck securityCheck = new SecurityCheck();
Socket socket = new Socket("", 22, true);
/* This test fails because method [org.utbot.examples.securitycheck.SecurityCheck.connect] produces [java.security.AccessControlException: access denied ("java.net.SocketPermission" "127.0.0.1:22" "connect,resolve")] */
}
@Test
@Disabled(value = "Disabled due to sandbox")
public void testConnect4() throws IOException {
SecurityCheck securityCheck = new SecurityCheck();
Socket socket = new Socket("jkmqh", 22, false);
/* This test fails because method [org.utbot.examples.securitycheck.SecurityCheck.connect] produces [java.security.AccessControlException: access denied ("java.net.SocketPermission" "jkmqh" "resolve")] */
}
@Test
@Disabled(value = "Disabled due to sandbox")
public void testConnect5() throws IOException {
SecurityCheck securityCheck = new SecurityCheck();
Socket socket = new Socket("", 0, true);
/* This test fails because method [org.utbot.examples.securitycheck.SecurityCheck.connect] produces [java.security.AccessControlException: access denied ("java.net.SocketPermission" "127.0.0.1:0" "connect,resolve")] */
}
@Test
@Disabled(value = "Disabled due to sandbox")
public void testConnect6() throws IOException {
SecurityCheck securityCheck = new SecurityCheck();
Socket socket = new Socket("0.0.0.0", 22);
/* This test fails because method [org.utbot.examples.securitycheck.SecurityCheck.connect] produces [java.security.AccessControlException: access denied ("java.net.SocketPermission" "0.0.0.0:22" "connect,resolve")] */
}
@Test
@Disabled(value = "Disabled due to sandbox")
public void testConnect7() throws IOException {
SecurityCheck securityCheck = new SecurityCheck();
Socket socket = new Socket("noimn", 427785292);
/* This test fails because method [org.utbot.examples.securitycheck.SecurityCheck.connect] produces [java.security.AccessControlException: access denied ("java.net.SocketPermission" "noimn" "resolve")] */
}
@Test
@Disabled(value = "Disabled due to sandbox")
public void testConnect8() throws IOException {
SecurityCheck securityCheck = new SecurityCheck();
Socket socket = new Socket("", 0);
/* This test fails because method [org.utbot.examples.securitycheck.SecurityCheck.connect] produces [java.security.AccessControlException: access denied ("java.net.SocketPermission" "127.0.0.1:0" "connect,resolve")] */
}
///endregion
///region Errors report for connect
public void testConnect_errors() {
// Couldn't generate some tests. List of errors:
//
// 70 occurrences of:
// Default concrete execution failed
}
///endregion
///endregion
///region Test suites for executable org.utbot.examples.securitycheck.SecurityCheck.read
///region
@Test
@Disabled(value = "Disabled due to sandbox")
public void testRead1() {
SecurityCheck securityCheck = new SecurityCheck();
File path = new File("jkmqh", "uhauh");
/* This test fails because method [org.utbot.examples.securitycheck.SecurityCheck.read] produces [java.security.AccessControlException: access denied ("java.io.FilePermission" "jkmqh\\uhauh" "read")]
java.base/java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
java.base/java.security.AccessController.checkPermission(AccessController.java:897)
java.base/java.lang.SecurityManager.checkPermission(SecurityManager.java:322)
java.base/java.lang.SecurityManager.checkRead(SecurityManager.java:661)
java.base/sun.nio.fs.WindowsChannelFactory.open(WindowsChannelFactory.java:299)
java.base/sun.nio.fs.WindowsChannelFactory.newFileChannel(WindowsChannelFactory.java:168)
java.base/sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:230)
java.base/java.nio.file.Files.newByteChannel(Files.java:371)
java.base/java.nio.file.Files.newByteChannel(Files.java:422)
java.base/java.nio.file.Files.readAllBytes(Files.java:3206)
org.utbot.examples.securitycheck.SecurityCheck.read(SecurityCheck.java:19) */
}
@Test
public void testRead2() throws IOException {
SecurityCheck securityCheck = new SecurityCheck();
/* This test fails because method [org.utbot.examples.securitycheck.SecurityCheck.read] produces [java.lang.NullPointerException]
org.utbot.examples.securitycheck.SecurityCheck.read(SecurityCheck.java:19) */
securityCheck.read(null);
}
///endregion
///region Errors report for read
public void testRead_errors() {
// Couldn't generate some tests. List of errors:
//
// 6 occurrences of:
// Default concrete execution failed
}
///endregion
///endregion
}Environment
Windows 10 Pro
IntelliJ IDEA 2022.2.3 (JBR 17)
Gradle
JDK 11
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
ctg-bugIssue is a bugIssue is a bugpriority-top-focusTop priority chosen by dev teamTop priority chosen by dev team
Type
Projects
- StatusShow more project fieldsTodo
Activity
alisevych commentedon Nov 16, 2022
@SBOne-Kenobi
Also there is an unused import in the generated test:
import java.net.UnknownHostException;Could you please check if it requires a separate issue?
alisevych commentedon Mar 21, 2023
Reproducing on latest unit-test-bot/rc3102023 branch