Title: Couldn't import some standard Python libs because of the permission issue · Issue #1 · healeycodes/untrusted-python · GitHub
Open Graph Title: Couldn't import some standard Python libs because of the permission issue · Issue #1 · healeycodes/untrusted-python
X Title: Couldn't import some standard Python libs because of the permission issue · Issue #1 · healeycodes/untrusted-python
Description: Hi @healeycodes , firstly I'd like to say thanks for the great idea and making it work. But it there seems to be an issue what we can't import several standard libraries. For example: └─> curl -X POST https://untrusted-python.fly.dev/api...
Open Graph Description: Hi @healeycodes , firstly I'd like to say thanks for the great idea and making it work. But it there seems to be an issue what we can't import several standard libraries. For example: └─> curl -X P...
X Description: Hi @healeycodes , firstly I'd like to say thanks for the great idea and making it work. But it there seems to be an issue what we can't import several standard libraries. For example: └─>...
Opengraph URL: https://github.com/healeycodes/untrusted-python/issues/1
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Couldn't import some standard Python libs because of the permission issue ","articleBody":"Hi @healeycodes , firstly I'd like to say thanks for the great idea and making it work. But it there seems to be an issue what we can't import several standard libraries. For example:\r\n\r\n```\r\n└─\u003e curl -X POST https://untrusted-python.fly.dev/api/exec \\\r\n-H \"Content-Type: application/json\" \\\r\n-d '{\"code\":\"import datetime\"}'\r\n\r\nTraceback (most recent call last):\r\n File \"/app/./sandbox.py\", line 41, in \u003cmodule\u003e\r\n File \"\u003cstring\u003e\", line 1, in \u003cmodule\u003e\r\nModuleNotFoundError: No module named 'datetime'\r\n```\r\n\r\nAfter checking around I can see the issue is because some permissions are missing. After disabled the [drop_perms()](https://github.com/healeycodes/untrusted-python/blob/main/sandbox/sandbox.py#L40) function, it works well. Like this:\r\n\r\n```\r\nif __name__ == \"__main__\":\r\n code = sys.argv[1]\r\n set_mem_limit()\r\n # drop_perms()\r\n exec(code)\r\n```\r\nThen it works:\r\n```\r\n└─\u003e curl -X POST http://localhost:3000/api/exec \\\r\n-H \"Content-Type: application/json\" \\\r\n-d '{\"code\":\"import datetime\\nprint(1)\"}'\r\n1\r\n\r\n```\r\n\r\nSo ideally we should improve this function to let all default Python's functionality work well.\r\n","author":{"url":"https://github.com/mozedz","@type":"Person","name":"mozedz"},"datePublished":"2023-12-28T06:59:30.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/1/untrusted-python/issues/1"}
| 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:3e8337c1-06a9-c3ef-1e2f-8596770bef03 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C684:106C72:1727AD3:1F166AB:69706ACD |
| html-safe-nonce | 65030f6a67a62e0cf59a4cdead74c65acbd6fd68a32a31df4e203377ed4a9365 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNjg0OjEwNkM3MjoxNzI3QUQzOjFGMTY2QUI6Njk3MDZBQ0QiLCJ2aXNpdG9yX2lkIjoiMzAxMjk3MzA4ODA5MDM4NTEwMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | bfcfe3ba1f5b0fa2379f8253aadd74b4a167e115a6996fc693f87116832d30d1 |
| hovercard-subject-tag | issue:2058069514 |
| 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/healeycodes/untrusted-python/1/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a704401337b4d64c5f553ac1a753a65c4d1453aee8c55d67ef58ebc9cc17a34c/healeycodes/untrusted-python/issues/1 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a704401337b4d64c5f553ac1a753a65c4d1453aee8c55d67ef58ebc9cc17a34c/healeycodes/untrusted-python/issues/1 |
| og:image:alt | Hi @healeycodes , firstly I'd like to say thanks for the great idea and making it work. But it there seems to be an issue what we can't import several standard libraries. For example: └─> curl -X P... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mozedz |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9920a62ba22d06470388e2904804fb7e5ec51c9e35f81784e9191394c74b2bd2 |
| turbo-cache-control | no-preview |
| go-import | github.com/healeycodes/untrusted-python git https://github.com/healeycodes/untrusted-python.git |
| octolytics-dimension-user_id | 34559231 |
| octolytics-dimension-user_login | healeycodes |
| octolytics-dimension-repository_id | 668573392 |
| octolytics-dimension-repository_nwo | healeycodes/untrusted-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 668573392 |
| octolytics-dimension-repository_network_root_nwo | healeycodes/untrusted-python |
| 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 | 7d6181066430cc06553c8396ca201e194ae33cb9 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width