根据Apple 的文档,应用程序要访问其容器外部以及此处列出的目录之外的文件系统,需要指定文件访问临时异常权利。
\n\n我的应用程序需要读取和写入 中的一些文件~/Library/Application Support/,因此我将com.apple.security.temporary-exception.files.home-relative-path.read-write值设置/Library/Application Support/为应用程序的.entitlementplist 中。
~/Library/Application Support/现在,如果路径是硬编码的,我的应用程序可以读取文件,如下所示:
let filePath = URL(fileURLWithPath: "/Users/myUsername/Library/Application Support/path/to/somefile.txt")\nlet fileContent = try! String(contentsOf: filePath, encoding: .ascii)\nRun Code Online (Sandbox Code Playgroud)\n\n但是,如果我像下面这样做,它将不起作用:
\n\nlet filePathString = "~/Library/Application Support/path/to/somefile.txt"\nlet expandedFilePathString = NSString(string: filePathString).expandingTildeInPath\nlet filePath = URL(fileURLWithPath: expandedFilePathString)\nlet fileContent = try! String(contentsOf: filePath, encoding: .ascii) // Error\n\n// alternatively\nlet applicationSupportPath = try! FileManager.default.url(\n for: .applicationSupportDirectory,\n in: .userDomainMask,\n appropriateFor: nil,\n create: false\n)\nlet filePath = applicationSupportPath.appendingPathComponent("path/to/somefile.txt")\nlet fileContent …Run Code Online (Sandbox Code Playgroud) 你好,谢谢!
我正在尝试从Silverlight应用程序访问USB端口.由于Silverlight在沙箱中运行,因此无法执行此操作.
是否可以从Silverlight应用程序内部运行ActiveX控件?(最好不要叠加)
如果是这样:存在哪些例子?这方面的最佳做法是什么?
我在谷歌搜索和搜索SO的插件架构,我对如何实现它的一般知识感到满意.现在我进一步寻找沙盒架构.基本上我的意思是带插件的应用程序,插件崩溃不会导致整个应用程序崩溃,插件可以重新加载.我找不到好的文档.我知道Firefox实现它(崩溃的Flash插件不会影响整个FF的东西,可以重新加载)谢谢!
我正在使用本教程向我的应用程序添加登录项.大部分都按预期工作,我已设法创建一个沙盒帮助应用程序并将其注册到启动服务,因此它应该在登录时启动.
现在的问题是,该教程并不是非常具体地说明了如何从这个帮助应用程序中启动主应用程序包.它仅包括:
[[NSWorkspace sharedWorkspace] launchApplication:
@"/Path/To/Main/App/Bundle"];
Run Code Online (Sandbox Code Playgroud)
但是,如果我尝试使用任何NSWorkspace方法以完整路径启动应用程序,它将失败,因为Sandbox不允许这样做.
如果我尝试将上述方法的参数设置为我的应用程序名称,它可以正常工作,但奇怪地启动我的应用程序的旧版本(我将这些存储在我的硬盘上,但它们不在/ Applications文件夹中,仅我的应用程序的正确版本位于/ Applications文件夹中)
现在有人为什么会这样,或者我怎么能解决这个问题?
我正在制作一个Mac OS X应用程序(沙盒),它从/ etc / myfolder中已安装的配置文件中读取。当我尝试使用NSFileHandle读取文件时,在控制台中收到以下错误:
sandboxd: ([3251]) MyApp(3251) deny file-read-data /private/etc/myfolder/myconfig.conf
我已在我的Entitilements文件中设置了以下权利,但仍然受到沙盒拒绝。
编辑:似乎我滥用了
com.apple.security.temporary-exception.files.absolute-path.read-only。
我将其设置为布尔值。我的印象是将其设置为YES将启用使用绝对路径的所有文件读取。上述权利的值必须是允许的绝对路径。
我正在尝试使用PyPy创建一个服务器端沙箱,对我的文件系统的访问权限有限.我正在使用Ubuntu 12.04 64位机器,并且一直在尝试从这里安装PyPy的完整源代码:http://pypy.org/download.html#sandboxed-version(向下滚动到"从源代码构建"部分).
我的问题是,每当我尝试运行pypy_interact.py(位于pypy/pypy/sandbox)时,我都会收到以下错误:
ImportError:没有名为rpython.translator.sandbox.sandlib的模块
无法导入的模块具有以下路径:pypy/rpython/translator/sandbox/sandlib.py.pypy_interact.py的内容如下:
import sys, os
sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), '..\
', '..', '..')))
from rpython.translator.sandbox.sandlib import SimpleIOSandboxedProc
from rpython.translator.sandbox.sandlib import VirtualizedSandboxedProc
from rpython.translator.sandbox.vfs import Dir, RealDir, RealFile
import pypy
LIB_ROOT = os.path.dirname(os.path.dirname(pypy.__file__))
Run Code Online (Sandbox Code Playgroud)
我觉得这是一个非常简单的修复 - 我几天前刚开始学习Python,所以我不确定如何解决问题/不太了解进口.有什么建议?非常感谢.
我有一个用户提交的不受信任的代码,我需要在浏览器的沙盒环境中执行它。
有人告诉我,Web-Workers不能为此提供足够的安全性,因此最好使用Sandbxed iframe。这一页:
https://www.owasp.org/index.php/HTML5_Security_Cheat_Sheet#Web_Workers
还说工人不适合不受信任的代码。
但是,如果我从Blob创建一个worker,则其url甚至具有不同的协议(blob://)。在这种情况下,是否将单独的来源策略应用于工作者代码?
如果还有其他原因,为什么(默认情况下)为什么与沙盒iframe(访问IndexedDB等)相比,对工作人员的限制较少(是否有机会以某种方式设置工作人员,以便对其进行足够的限制,或者应该我还是要使用沙盒iframe吗?
我正在使用srcdoc属性将HTML内容加载到iframe中.iframe是一个没有权限的沙盒iframe,因此iframe中的所有Javascript都被阻止.但是,仍会在iframe内触发远程请求(例如CSS,图像等).
是否有任何可能的方法告诉iframe只加载我在srcdoc属性中提供的内容而不进行任何其他请求?
提前致谢
我正在测试Braintree沙箱(PHP),即使我使用的是伪随机数据,交易仍然显示有效
我有一个dropin前端和一个PHP后端
我的后端测试代码如下所示:
$amount = '12.00';
$nonce = 'fake-processor-declined-visa-nonce';
$result = Braintree_Transaction::sale(['amount' => $amount,
'paymentMethodNonce' => $nonce,
'options' => ['submitForSettlement' => true]
]);
$debug = get_object_vars($result);
print_r($debug);
Run Code Online (Sandbox Code Playgroud)
结果
Array
(
[success] => 1
[transaction] => Braintree\Transaction Object
(
[_attributes:protected] => Array
(
[id] => 9bnyb32r
[status] => submitted_for_settlement
[type] => sale
[currencyIsoCode] => EUR
[amount] => 12.00
[merchantAccountId] => somenamehere
[subMerchantAccountId] =>
[masterMerchantAccountId] =>
[orderId] =>
[createdAt] => DateTime Object
Run Code Online (Sandbox Code Playgroud)
我保证这些假的小菜在沙箱中测试错误结果...还是我错过了一些东西
https://developers.braintreepayments.com/reference/general/testing/php#test-amounts
我正在使用Xcode 8.0,Swift 3.0并在我的iPad上测试应用程序.我想使用沙盒用户测试应用内购买.
设备的设置中没有添加帐户
问题是我没有得到产品列表以响应产品请求代码.请看一下我的代码:
let PRODUCT_ID_MY_PRODUCT = "com.company.ProjectName.MyProduct"
// The ProducID in this code and ProducID on iTunes are the SAME. ??
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if productID == nil {
productID = PRODUCT_ID_MY_PRODUCT
}
SKPaymentQueue.default().add(self)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
startPurchases()
}
func startPurchases() {
if (SKPaymentQueue.canMakePayments())
{
let productIDs = NSSet(object: self.productID!)
let productsRequest:SKProductsRequest = SKProductsRequest(productIdentifiers: productIDs as! Set<String>)
productsRequest.delegate = self
productsRequest.start()
}
}
// Delegate Methods …Run Code Online (Sandbox Code Playgroud)