Title: Add SecurityManager support to block suspicious code #622 by Markoutte · Pull Request #625 · UnitTestBot/UTBotJava · GitHub
Open Graph Title: Add SecurityManager support to block suspicious code #622 by Markoutte · Pull Request #625 · UnitTestBot/UTBotJava
X Title: Add SecurityManager support to block suspicious code #622 by Markoutte · Pull Request #625 · UnitTestBot/UTBotJava
Description: Description This commit introduces support of SecurityManager in instrumentation.jar to restrict all suspicious code from running (File IO, Socket IO, Property reading and etc.). Security is enabled by default and limits all permissions to a small set that needed for execution. Settings can be extended by editing .utbot/sandbox.policy (more about policy file and syntax). Fixes #622 Type of Change Breaking change (fix or feature that would cause existing functionality to not work as expected) How Has This Been Tested? Automated Testing All existing tests should pass Manual Scenario Disable symbolic execution test generation and leave only fuzzing (in the settings by choosing "Simpler" for "Code analysis"). Run test generations for these methods: 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"; } } For every method except normatTest() there are should be several methods that look like: public void testPropertyWithBlankString() { SecurityCheck securityCheck = new SecurityCheck(); /* This test fails because method [com.company.security.SecurityCheck.property] produces [java.security.AccessControlException: access denied ("java.util.PropertyPermission" " " "read")] java.security.AccessControlContext.checkPermission(AccessControlContext.java:472) java.security.AccessController.checkPermission(AccessController.java:886) java.lang.SecurityManager.checkPermission(SecurityManager.java:549) java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1294) java.lang.System.getProperty(System.java:719) com.company.security.SecurityCheck.property(SecurityCheck.java:32) */ } Try to edit {user.home}/.utbot/sandbox.policy: grant { permission java.util.PropertyPermission "*", "read"; }; and generate test for String property(String key). Tests should be generated without access exception. Checklist: The change followed the style guidelines of the UTBot project Self-review of the code is passed The change contains enough commentaries, particularly in hard-to-understand areas New documentation is provided or existed one is altered No new warnings New tests have been added All tests pass locally with my changes
Open Graph Description: Description This commit introduces support of SecurityManager in instrumentation.jar to restrict all suspicious code from running (File IO, Socket IO, Property reading and etc.). Security is enable...
X Description: Description This commit introduces support of SecurityManager in instrumentation.jar to restrict all suspicious code from running (File IO, Socket IO, Property reading and etc.). Security is enable...
Opengraph URL: https://github.com/UnitTestBot/UTBotJava/pull/625
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:3db49db0-0115-9210-0107-daa29e8bb0c6 |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | B33E:3F433:2DADC0:3E7A3E:698E19CB |
| html-safe-nonce | 8eac601d9e8db3e17f0116d157f89c633f4ba1afd746f0b595c6cc3ffd7b68aa |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMzNFOjNGNDMzOjJEQURDMDozRTdBM0U6Njk4RTE5Q0IiLCJ2aXNpdG9yX2lkIjoiMjg3MTQ1MzE0NTY0ODM5ODgzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e2e0c13558e86fd0ead5f99be36b89d93410338992d8f380c8a730956350e98b |
| hovercard-subject-tag | pull_request:1013608557 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,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/UnitTestBot/UTBotJava/pull/625/checks |
| twitter:image | https://avatars.githubusercontent.com/u/720952?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/720952?s=400&v=4 |
| og:image:alt | Description This commit introduces support of SecurityManager in instrumentation.jar to restrict all suspicious code from running (File IO, Socket IO, Property reading and etc.). Security is enable... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 52130a026bd9a3f98228b6aa6af91acdab5d18de411e2c1e67e6253493561296 |
| 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 full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 301a1d7743177dcb7528b1322117cdafeda8ff08 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width