Title: Implicit unpermitted operations should be sandboxed · Issue #791 · UnitTestBot/UTBotJava · GitHub
Open Graph Title: Implicit unpermitted operations should be sandboxed · Issue #791 · UnitTestBot/UTBotJava
X Title: Implicit unpermitted operations should be sandboxed · Issue #791 · UnitTestBot/UTBotJava
Description: Description Unpermitted operations can be called implicitly. Need to sandbox them too. in constructors of used classes in static blocks in private methods of other classes in separate threads ? probably, there are other cases to be added...
Open Graph Description: Description Unpermitted operations can be called implicitly. Need to sandbox them too. in constructors of used classes in static blocks in private methods of other classes in separate threads ? pro...
X Description: Description Unpermitted operations can be called implicitly. Need to sandbox them too. in constructors of used classes in static blocks in private methods of other classes in separate threads ? pro...
Opengraph URL: https://github.com/UnitTestBot/UTBotJava/issues/791
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Implicit unpermitted operations should be sandboxed","articleBody":"**Description**\r\n\r\nUnpermitted operations can be called implicitly. Need to sandbox them too.\r\n- in constructors of used classes\r\n- in static blocks\r\n- in private methods of other classes\r\n- in separate threads\r\n- ? probably, there are other cases to be added ?\r\n\r\n**To Reproduce**\r\n\r\nSteps to reproduce the behavior:\r\n\r\n1. Open IntelliJ IDEA with installed UTBot plugin (with Security Manager turned on)\r\n2. Open/create a project with JDK 8/11\r\n3. Add the following class:\r\n\r\n~~~java\r\nimport java.io.File;\r\nimport java.io.IOException;\r\n\r\nclass A {\r\n A () throws IOException {\r\n File a = new File(\"a.txt\");\r\n a.createNewFile();\r\n }\r\n}\r\n\r\npublic class SecurityCheck {\r\n\r\n public int read(A a) {\r\n return 10;\r\n }\r\n}\r\n~~~\r\n\r\n4. Generate tests for the SecurityCheck.read method - with Mocking on\r\n\r\n**Expected behavior**\r\n\r\nGenerated test is supposed to be disabled with sandbox-related comment.\r\nNo file must be created by user's code during test generation.\r\n\r\n**Actual behavior**\r\n\r\nSuccessful test is generated.\r\nFile \"a.txt\" is created during test generation.\r\n\r\n**Visual proofs (screenshots, logs, images)**\r\n\r\n~~~java\r\n @Test\r\n @DisplayName(\"read: a = A() -\u003e return 10\")\r\n public void testReadReturns10() throws IOException {\r\n SecurityCheck securityCheck = new SecurityCheck();\r\n A a = new A();\r\n\r\n int actual = securityCheck.read(a);\r\n\r\n assertEquals(10, actual);\r\n }\r\n~~~\r\n\r\n\r\n\r\n**Environment**\r\n\r\nIntelliJ IDEA 2022.1 - 2022.1.4\r\nJDK 8/11\r\n\r\n**Additional context**\r\n\r\nStatic blocks are being executed without sandbox either:\r\n\r\n~~~java\r\nimport java.io.File;\r\n\r\nclass A {\r\n static {\r\n new File(\"a.txt\").renameTo(new File(\"b.txt\"));\r\n }\r\n}\r\n\r\npublic class AnotherCheck {\r\n\r\n public int read(A a) {\r\n return 10;\r\n }\r\n\r\n}\r\n~~~","author":{"url":"https://github.com/alisevych","@type":"Person","name":"alisevych"},"datePublished":"2022-08-25T13:50:04.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/791/UTBotJava/issues/791"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:58d56e99-0185-7d81-de95-e0638ff2c727 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C984:69671:B57F16:FA17BA:698E13C7 |
| html-safe-nonce | 3156636f4385aa9282475257110ff900fa48f5c7fe88a5d1e90b9e1e5154ec7e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOTg0OjY5NjcxOkI1N0YxNjpGQTE3QkE6Njk4RTEzQzciLCJ2aXNpdG9yX2lkIjoiNzIzNzU1Njc0MDY3MzExNTA4MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 1660aafba6a000ae145f3fef20d57b40f63b23328887c89541b8d5e6a58932f8 |
| hovercard-subject-tag | issue:1350935889 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/UnitTestBot/UTBotJava/791/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f135f10eee2cab4232b67d9f96873baad00c5ebc87fed6813c5e92d822fef495/UnitTestBot/UTBotJava/issues/791 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f135f10eee2cab4232b67d9f96873baad00c5ebc87fed6813c5e92d822fef495/UnitTestBot/UTBotJava/issues/791 |
| og:image:alt | Description Unpermitted operations can be called implicitly. Need to sandbox them too. in constructors of used classes in static blocks in private methods of other classes in separate threads ? pro... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alisevych |
| hostname | github.com |
| expected-hostname | github.com |
| None | fdf74c91c9ac187cc5cd7b14d4af2d6ef3e18136d002f5d36253f8538e97ee4c |
| turbo-cache-control | no-preview |
| go-import | github.com/UnitTestBot/UTBotJava git https://github.com/UnitTestBot/UTBotJava.git |
| octolytics-dimension-user_id | 87413538 |
| octolytics-dimension-user_login | UnitTestBot |
| octolytics-dimension-repository_id | 480810501 |
| octolytics-dimension-repository_nwo | UnitTestBot/UTBotJava |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 480810501 |
| octolytics-dimension-repository_network_root_nwo | UnitTestBot/UTBotJava |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 1a5a3e7bbfb3486980e340c242368684156fba87 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width