我有一个多层PSD,一个特定的图层是非光栅化的文本.我试图找出一种方法,从bash/perl/python/whatever-else程序:
我立刻想到了ImageMagick,但我认为我不能通过IM编辑文本层.如果我可以通过其他一些编程方式完成前两个步骤,我总是可以使用ImageMagick执行最后两个步骤.
经过几个小时的谷歌搜索和搜索CPAN和PyPI后,我仍然没有找到任何有希望的东西.有没有人对这个问题有任何建议或想法?
我有一些javascript内容,我想"沙盒"到iframe:
<script type="text/javascript">
doSomethingPotentiallyMalicious( // ideally, i want this to be able to run...
top.document.getElementById('sensitive_information') // ...but want this to fail due to cross-domain permissions
);
</script>
Run Code Online (Sandbox Code Playgroud)
问题是,由于我们的Web应用程序的性质,我需要在包含iframe的父页面上内联执行此操作,并且我需要以跨浏览器兼容的方式执行此操作.
通过数据网址在iframe中设置内容,我能够在Chrome中获得所需的效果:
<iframe id="sandbox" src="data:text/html;charset=utf-8,%3Cscript%20type%3D%22text%2Fjavascript%22%3E%0A%20%20%20%20doSomethingPotentiallyMalicious(%20%2F%2F%20ideally%2C%20i%20want%20this%20to%20be%20able%20to%20run...%0A%20%20%20%20%20%20%20%20top.document.getElementById('sensitive_information')%20%2F%2F%20...but%20want%20this%20to%20fail%20due%20to%20cross-domain%20permissions%0A%20%20%20%20)%3B%0A%3C%2Fscript%3E"></iframe>
Run Code Online (Sandbox Code Playgroud)
但是,数据网址支持很多,这需要跨浏览器工作.
我可以在javascript转义字符串中包含不安全的内容,然后将其写为iframe的内容:
<iframe id="sandbox" src="http://google.com/"></iframe>
<script>
var unsafeContent = '\x3Cscript\x20type\x3D\x22text\x2Fjavascript\x22\x3E\x0A\x20\x20\x20\x20doSomethingPotentiallyMalicious\x28\x20\x2F\x2F\x20ideally,\x20i\x20want\x20this\x20to\x20be\x20able\x20to\x20run...\x0A\x20\x20\x20\x20\x20\x20\x20\x20top.document.getElementById\x28\x27sensitive_information\x27\x29\x20\x2F\x2F\x20...but\x20want\x20this\x20to\x20fail\x20due\x20to\x20cross\x2Ddomain\x20permissions\x0A\x20\x20\x20\x20\x29\x3B\x0A\x3C\x2Fscript\x3E\x0A\x0A';
var sandbox = document.getElementById('sandbox');
sandbox = (sandbox.contentWindow) ? sandbox.contentWindow : (sandbox.contentDocument.document) ? sandbox.contentDocument.document : sandbox.contentDocument;
sandbox.document.open();
sandbox.document.write(unsafeContent);
sandbox.document.close();
</script>
Run Code Online (Sandbox Code Playgroud)
这个问题是,一旦我将内容写入iframe,跨域安全性显然不再存在(意味着doSomethingPotentiallyMalicious函数可以访问父窗口中的所有内容).
我甚至尝试更改document.domain(通过删除最左边的域名,因此"www.example.com"成为"example.com")按照之前的SO帖子,但这似乎并不强制执行跨域策略:
<iframe id="sandbox" src="http://google.com/"></iframe> …Run Code Online (Sandbox Code Playgroud) 对于现有项目,我将使用ansible替换bash配置脚本 - 首先通过Vagrant,然后在解决问题之后将其推送到staging/prod服务器.
根据关于变量优先级的ansible 文档,group_vars应该覆盖角色变量,但我看到相反的情况发生.
以下是我Vagrantfile(在项目根目录中)的摘录:
config.vm.provision "ansible" do |ansible|
ansible.playbook = "app/config/provision/provision.yml"
end
Run Code Online (Sandbox Code Playgroud)
我将它指向一个子目录下的一个子目录,因为我正在使用自己的实践在现有的代码库中工作,并且不能让ansible的东西混乱根.有问题的剧本:
# app/config/provision/provision.yml
---
- hosts: all
gather_facts: yes
sudo: true
roles:
- apache
- php
post_tasks:
- debug: var=vagrant_ansible_test_loading_vars
- debug: var=apache_listen_ports
Run Code Online (Sandbox Code Playgroud)
请注意两个变量的调试语句,这两个变量都在playbook旁边的group_vars文件中定义:
# app/config/provision/group_vars/all
---
vagrant_ansible_test_loading_vars: "lorem ipsum"
apache_listen_ports:
- 80
- 8080
Run Code Online (Sandbox Code Playgroud)
我正在使用的apache角色定义了默认值(应该具有LOWEST优先级):
# app/config/provision/roles/apache/defaults/main.yml
---
apache_listen_ports: [ 80, 8080 ]
Run Code Online (Sandbox Code Playgroud)
同一个角色也定义了vars(应该是SECOND最低优先级):
# app/config/provision/roles/apache/vars/main.yml
---
apache_listen_ports: [ 80 ]
Run Code Online (Sandbox Code Playgroud)
然而,在vagrant up,我得到了这个:
TASK: [debug var=vagrant_ansible_test_loading_vars] *************************** …Run Code Online (Sandbox Code Playgroud)