GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Sandboxed test is not compiling because of illegal unicode escape · Issue #1134 · UnitTestBot/UTBotJava

Sandboxed test is not compiling because of illegal unicode escape #1134

New issue
Copy link
New issue
Copy link
Closed
#1182
Closed
Sandboxed test is not compiling because of illegal unicode escape#1134
#1182
Copy link
Assignees
Vassiliy-Kudryashov
Labels
ctg-bugIssue is a bugIssue is a bug
Milestone
2022.11 Release

Description

@alisevych
alisevych
opened on Oct 11, 2022
Issue body actions

Description

Sandboxed test is not compiling because commented stack trace contains "illegal unicode escape".

To Reproduce

  1. Run a project in IntelliJ Idea 2022.1.3 - 2022.2.2
  2. Install RC plugin build
  3. Set Fuzzing to 100% (in File -> Settings -> Tools -> UnitTestBot)
  4. Add the following class (originally posted in Add SecurityManager support to block suspicious code #622 #625 ):
public class SecurityCheck {

    public int normalTest(int value) {
        if (value < 0) {
            return -value;
        }
        return value;
    }

    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;
    }

    public String property(String key) {
        return System.getProperty(key);
    }

    public String systemExit() {
        System.exit(0);
        return "bad";
    }

}
  1. Generate tests with UnitTestBot
  2. Open generated tests

Expected behavior

Project can be successfully build after test generation.

Actual behavior

SecurityCheckTest is not compiled.
The following error is displayed:

C:\Users\<user_name>\UTBotJava\utbot-sample\src\test\java\org\utbot\examples\securitycheck\SecurityCheckTest.java:2823: error: illegal unicode escape
        /* This test fails because method [org.utbot.examples.securitycheck.SecurityCheck.read] produces [java.security.AccessControlException: access denied ("java.io.FilePermission" "jkmqh\uhauh" "read")]

Visual proofs (screenshots, logs, images)

image

There is the following test generated by Fuzzer

    ///region FUZZER: EXPLICITLY_THROWN_UNCHECKED_EXCEPTIONS for method read(java.io.File)

    @Test
    @DisplayName("read: path = File(String, String)")
    @Disabled(value = "Disabled due to sandbox")
    public void testRead() {
        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) */
    }
    ///endregion

Environment

Windows 10 Pro
IntelliJ IDEA 2022.2.2

Additional context

Originally posted by @alisevych in #1125 (comment)

Activity

  1. korifey
    added this to UTBot Javaon Oct 11, 2022
  2. korifey
    moved this to Todo in UTBot Javaon Oct 11, 2022
  3. alisevych
    assigned
    Markoutte
    on Oct 11, 2022
  4. alisevych
    added
    ctg-bugIssue is a bugIssue is a bug
    on Oct 11, 2022
  5. alisevych
    added this to the 2022.11 Release milestone on Oct 11, 2022
  6. Markoutte commented on Oct 11, 2022

    @Markoutte
    Markoutte
    on Oct 11, 2022
    Collaborator
    More actions

    Looks like that it is relative to #609

    Reproducable for a simple example without sandboxing (fuzzer is on, test should fail):

    public int error() {
        Integer.parseInt("my" + "\\" + "union");
        return -1;
    }

    @Vassiliy-Kudryashov could you please take a look?

  7. Markoutte
    assigned
    Vassiliy-Kudryashov
    and unassigned
    Markoutte
    on Oct 11, 2022
  8. Vassiliy-Kudryashov
    moved this from Todo to In Progress in UTBot Javaon Oct 19, 2022
  9. Vassiliy-Kudryashov
    added a commit that references this issue on Oct 19, 2022

    Sandboxed test is not compiling because of illegal unicode escape #1134

    7f952fd
  10. Vassiliy-Kudryashov
    linked a pull request that will close this issueSandboxed test is not compiling because of illegal unicode escape #1134 #1182on Oct 19, 2022
  11. Vassiliy-Kudryashov
    added a commit that references this issue on Oct 19, 2022

    Sandboxed test is not compiling because of illegal unicode escape #1134…

    5bd3235
  12. Vassiliy-Kudryashov
    closed this as completedin #1182on Oct 19, 2022
  13. Repository owner moved this from In Progress to Done in UTBot Javaon Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @Vassiliy-Kudryashov
    Vassiliy-Kudryashov

Labels

ctg-bugIssue is a bugIssue is a bug

Type

No type

Projects

  • UTBot Java
    Status
    Done
    Show more project fields

Milestone

  • 2022.11 Release

Relationships

None yet

Development

No branches or pull requests

Issue actions

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.