sandboxed | Python script to jail execution
kandi X-RAY | sandboxed Summary
kandi X-RAY | sandboxed Summary
Python module with utilities to jail execution with limited privileges, filesystem, network and resources. Inspired by Da_Blitz's work on Asylum. I made this to learn ctypes and how namespaces/cgroups and parts of Linux kernel work by trying to use it directly instead of just reading about it. It is unfinished, has no setup.(py|ini) yet. To use it, you need new Linux kernel with namespaces compiled in (CONFIG_NAMESPACES, CONFIG_*_NS) and be able to run as root (CAP_SYS_ADMIN privilege).
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Create new namespaces
- Explorer the player
- Setup pylib
- Mount a python library
- Start the machine
- Terminate a patient
- Start worker threads
- Process a connection
- Create a libc call
- Decorator to create a syscall function
sandboxed Key Features
sandboxed Examples and Code Snippets
Community Discussions
Trending Discussions on sandboxed
QUESTION
ANSWER
Answered 2021-Jun-07 at 12:48When BP
or SP
is used in addressing, the default segment register is SS
, otherwise it's DS
.
Rewrite the first column of memory dump table with linear address, i.e. instead of seg:offs calculate 16*seg+offs. This gives addresses
QUESTION
I haven’t entirely given up on the idea of validators moonlighting as oracles for off-chain computation…based on this extensive discussion: https://gov.near.org/t/off-chain-computation-framework/1400/6
So far from studying Sputnik’s code, I have figured out the mechanics of how to upload a blob to a smart contract. Let's say that a blob represents a storage-less contract, having only stateless functions that act only on input to the function, and return those inputs modified.
Now I’m missing the piece of how Validators can download and execute the blob. As mentioned by Ilya in the link above, the NearSDK would be able to interpret the blob (if the blob is essentially a compiled contract), but it needs to be a modified version of the SDK...
Think of this like sandbox mode…blob cannot modify state of any other contract, but can read state (forget about the internet access part for now). Results of the blob execution are then fed back to a smart contract, where they have to match the results of every other validator who executed the blob. This can be done by hash comparison (rather than looping through the results individually), so it’s not an expensive comparison, especially because it’s all or nothing.
Question: how can a Validator download the blob and execute it via a sandboxed SDK, and post the result via the regular SDK to the blockchain? I am missing a lot of architectural context…and this is bringing me to the edge of giving on the idea. Please help prevent that from happening!
...ANSWER
Answered 2021-May-30 at 18:48If you are implementing this as a separate binary, your binary will be doing next things:
- Use RPC to load the WASM file from the blockchain. See RPC reference
- Use runtime-standalone to run this WASM with specific inputs. An example of using runtime standalone is here, but you will need to customize this with few things.
- The result should be sent as a transaction signed by this binary again via RPC.
If you want these WASM files to have access to state, you will need to load state inside this binary. There are two options:
- Modify a nearcore node to also do the above items
- Run nearcore in parallel, and open the database on read when you are initializing
Trie
(e.g. here load from disk instead).
If you want to add more host functions (like accessing internet), you will need to fork runtime-standalone to expose those functions.
QUESTION
I am trying to recreate this https://www.paypal.com/donate/?hosted_button_id=JA4LPSED5LVCG which is the standard hosted PayPal donation button. It has preset amounts, let the user add their intent(which program to support), and recurring monthly donations. I started out with jQuery to target elements and pass the preset amounts and that worked but since I've gone with a vanilla js approach. My question is this, am I even setting this up properly using the PP SDK? Or do I need to do a different kind of integration with the API in order to support the recurring donations.
At this point my code is more broken than when I started out with jQuery(At least I was able to pass the preset amounts, but not the donation intent). I have set up a Codepen here and would love any and all feedback. https://codepen.io/tripdog/pen/dyvNeEV
...ANSWER
Answered 2021-May-28 at 03:00That code will not work for recurring payments. Subscriptions are a separate integration, see the Subscriptions overview: https://developer.paypal.com/docs/subscriptions/ , and in addition to API calls you can manually create and manage billing Products and Plans in the receiving account at:
If you want a choice on a PayPal page to make a donation recurring or not, the only option is to create a non-JS Donate button at https://www.paypal.com/buttons . In Step 2 you can uncheck the option to save the button at PayPal, and when you generate the code you can remove the code protection. A custom value can be passed using the custom
parameter, https://developer.paypal.com/docs/paypal-payments-standard/integration-guide/Appx-websitestandard-htmlvariables/#payment-transaction-variables , this will be visible in the receiver account's transaction details.
QUESTION
In this article on Xcode Source Editor extensions, it mentions that XPC is a way to circumvent the app sandbox:
The extension must be sandboxed just to be loaded by Xcode, whereas calls to SourceKit needs to be un-sandboxed, which of course won’t fly in the App Store. We could distribute independently and use an un-sandboxed XPC service embedded in the extension.
However, I'm not sure how to tie everything together to use an XPC service.
How do I tie my Xcode Source Editor extension to an XPC service?
...ANSWER
Answered 2021-May-17 at 19:16I was able to figure this out thanks to the LinuxSupportForXcode extension.
I'm going to make the assumption that you followed the tutorial on creating an Xcode Extension Editor, and made the main project a macOS App. You should have a target structure similar to:
- MyApp (macOS App target)
- MyAppExtension (Xcode Source Editor Extension target)
To use XPC with a Source Editor Extension:
File > New > Target... > XPC Service.
For example purposes, we'll assume it's called
MyAppXPCService
and its bundle identifier iscom.example.MyAppXPCService
.Move the XPC service dependency from the App to the Extension:
If you don't do this step, you may run into issues where your XPCService isn't being executed by the extension. E.g. you invoke a command that should launch the XPCService, but in the Xcode Debug Navigator, your XPCService never comes up.
- Go to your app's target.
- Remove MyAppXPCService.xpc from the Frameworks and Libraries.
- Go to your extension's target.
- Add MyAppXPCService.xpc to Frameworks and Libraries by dragging it in from the products folder in the Project Navigator. Leave it on the default "Embed Without Signing".
In the XPC Service, convert it to Swift, mainly following the instructions here:
Note: If you'd prefer to not convert to Swift, and use a mixed target instead, simply create a Swift file and when prompted, choose to create the bridging header, then include
#import "MyAppXPCServiceProtocol.h"
in the bridging header.Create
main.swift
,MyService.swift
,MyServiceDelegate.swift
,MyServiceProtocol.swift
normally.Set the following build settings:
- Install Objective-C Compatibility Header:
NO
- Objective-C Generated Interface Header Name: `` (blank)
- Install Objective-C Compatibility Header:
Choose your desired Swift Language Version in Build Settings.
In Build Settings, add (don't replace):
@loader_path/../../../../Frameworks
to Runtime Search Paths.If you accidentally replace, and use an embedded framework, XPC will crash on launch.
In your extension target:
import MyAppXPCService
so that it can see the protocol.Create the connection, using your XPC target's bundle identifier for
serviceName
:
QUESTION
I'm trying to figure out a way to determine whether a Mac has a MagSafe charging port programmatically. If that's not possible, alternatively, I suppose detecting whether any USB-C ports exist (and thus MagSafe is not present).
I've searched around the web for APIs for this as well as shell commands but haven't found any good solutions. I need this to work in a sandboxed environment distributed through the Mac App Store. Ideally, any solution would be in pure Cocoa/Objective-C, but I am also fine with achieving this via NSTask or similar.
Thank you so much in advance for any suggestions!
...ANSWER
Answered 2021-Apr-14 at 16:41I ended up compiling a list from EveryMac.com of all the models with MagSafe:
QUESTION
I'm working on a mobile app that can execute Python code easily, and unlike other execution apps I am going to have it run with actual Python.
I'm using a Flask Webserver and requests to accomplish this.
This is my code:
...ANSWER
Answered 2021-Apr-13 at 06:19There are a few ways to go about this: if you're doing exec
from the same process as Flask, the simplest thing to do is call it with a dictionary of "globals" and pass your own print
function. You can also replace sys.out
to reroute it to your own sink.
Alternatively, you can write a separate script which reads the input code from stdin, then exec
s it, and call that script as a subprocess to read from its output directly. That way also allows you to impose stricter limits on the user's code than the Flask code.
Whichever way you choose, be sure to also handle the case when the user's code raises an exception or falls into an infinite loop (or just takes way too long to run). The handling of those cases will depend on which approach you take.
QUESTION
I'm using ad hoc (outside App Store) distribution for my document-based app. The app is NOT sandboxed, and entitlements are set correctly:
...ANSWER
Answered 2021-Apr-11 at 20:42The problem was some remnants of old a bundle identifier. I had migrated to a sandboxed distribution of the app, and at some point in the process, I had built the sandboxed version with the same bundle identifier. macOS had registered the bundle identifier to belong to a sandboxed app and, probably due to security reasons, no longer wanted to allow it to run non-sandboxed.
I created a fresh Info.plist
, and changed the bundle identifier and the errors were gone.
QUESTION
I am testing file access on macOS Big Sur Xcode Obj-C with a sandboxed app. Because the app is sandboxed, I had to give read/write access to the folder my app writes files to - in this case the user's Music Directory.
This is located at Targets / Signing & Capabilities in the Info Tab under App Sandbox and File Access Type.
My app is writing files using:
...ANSWER
Answered 2021-Mar-24 at 20:48OK so I believe Music is a folder that can't be removed even if a music library is moved via the Music app. I guess if a music library is moved or changed, the default Music folder will still remain and usable by the app.
Therefore,
QUESTION
Tensorflow is build with spawn_strategy=standalone
. What is the reason behind that? Would sandboxed
be a better option?
ANSWER
Answered 2021-Apr-04 at 09:47It is hard to say, the commit which introduce that change do not tell why it was done.
The default option, which enable the best available sandboxing is probably the safest approach during development. However the Tensorflow case is different: most of the users do not change anything in a code base, they just want to build already tested codebase for their PC. In that case sandboxing can be disadvantageous, because it affects build performance, and there are some historical issues on some uncommon system configurations
QUESTION
I am using wix and in order to customize any html you need to use an embed object which creates a sandboxed iframe on the site. I have a decent grasp of how this works and posting messages to it but what I am having difficulties with is generating a pdf into this iframe.
I have done some reading and I think I get the overall concept. While traditionally you would just set the source to some document on a server somewhere I am generating the content dynamically based on user action. So it looks like something like pdfkit and creating a blob is the way to go.
I think I am able to generate the pdf without issues as well as a blob url no problem
[![console image][1]][1]
I can manually open the console and get that URL and paste it in the browser and the document opens exactly how I expect it. However I can't get it to display normally in the browser.
I have tried setting the src of various elements = to the blob url without luck.
...ANSWER
Answered 2021-Mar-15 at 04:26I have partially solved my question and it is good enough for what I need. Here is what I did.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install sandboxed
You can use sandboxed like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page