从html文件生成nginx内容安全策略头

nginxcsp的Python项目详细描述


nginx内容安全策略头生成器

Build StatusCoverage Status

此工具将从html文件中的导入域为nginx配置文件生成Content-Security-Policy头。

用法

要从路径中的html文件生成Content-Security-Policy头,可以使用以下命令:

nginxcsp /path/to/html/files --out /path/to/nginx.conf --override

该命令将为您的nginx.conf文件的所有server块生成Content-Security-PolicyX-Content-Security-PolicyX-WebKit-CSP头,并删除以前的头。标题将从HTML文件中的标记生成,例如,如果您有一个带有标记<script src="https://cdnjs.cloudflare.com/some-script.js"></script>的HTML文件,您将得到标题Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdnjs.cloudfare.com; img-src 'self'; style-src 'self' 'unsafe-inline'; font-src 'self'; object-src 'self'"

如果您只想创建Content-Security-Policy头,则可以使用标志--csp,这同样适用于--xcspX-Content-Security-Policy--xwebkitX-WebKit-CSP

您可以使用nginxcsp -h

usage: nginxcsp html_path

Search content loading sources in HTML files and Content-Security-Policy
headers automatically.

positional arguments:
  html_path             the path of the HTML files

optional arguments:
  -h, --help            show this help message and exit
  --out OUT             NGINX configuration file to output the generated
                        headers
  --server_name SERVER_NAME
                        the server_name in the NGINX server block to add CSP
                        headers
  --port PORT           the port from "listen {port}" line in a NGINX server
                        block to add CSP headers
  --override            flag to override the headers in the out file
  --csp                 flag to generate only the Content-Security-Policy
                        header
  --xcsp                flag to generate only the X-Content-Security-Policy
                        header
  --xwebkit             flag to generate only the X-WebKit-CSP header

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
手机上的html调试Java web应用程序   Java当前日期和过去日期之间的差值,以年、月、日、小时、分、秒为单位   如果方法名称相同,java如何使扩展类不从上面的类触发方法?   即使在提供了准确的firebase引用之后,java仍出现“无法跳转到类型”异常。请看详情   jar文件中的java图像   java如何避免从缓存读取时修改相同的对象实例?   Android中java完全控制的线程队列   JTextArea中的java计算   java如何独立运行。jar作为64位mashine上的32位   java在尝试实例化自引用泛型类的实例时,如何处理自引用类型参数   java如何安装着色jar而不是原来的jar   java在resultSet之后使用If-Else   多线程是java。朗,反思一下。方法调用线程安全   java 7语言向后兼容性   Objective C中的Category和Java 8中的Default方法是否等效?