2015-11-20 54 views
3

我已經上演在Heroku Django的博客應用程序,一切工作像我應該現在,但我有一個小問題有關Missing Subresource Integrity Protection失蹤子資源完整性保護

我在使用Heroku的插件相當新的,但我有安全設置tinfoil,最初的掃描後,我曾經遇到過3個漏洞。掃描結果顯示,我Missing Subresource Integrity Protection,他們已經提出了我:

> All externally loaded resources must have their content pinned using 
    > the subresource integrity mechanisms provided by modern browsers. This 
    > involves computing a hash of the contents of the resource, and 
    > specifying this hash when loading that resource. In the case of a 
    > script, this might look like the following: 

     <script src="https://example.com/include.js" 
        integrity="sha256-Rj/9XDU7F6pNSX8yBddiCIIS+XKDTtdq0//No0MH0AE=" 
        crossorigin="anonymous"></script> 

SRI Hash is an option for computing the necessary hashes. 

有人能解釋我這一切都說明,所以我可以學到一些東西了這一點,並在未來做什麼,所以我能避免這種情況?

回答

1

Subresource integrity是一個規範,「定義哪個用戶代理可以驗證所取的資源已被無意外操縱輸送的機構。」它基本上是您的資產的校驗和,如果符合指定的完整性值,兼容的瀏覽器將不會加載資源。

這是很容易的添加,在Rails的,只要你的鏈輪版本3.x或更高。您可以通過以下從sprockets documentation的例子中添加了檢查:

javascript_include_tag :application, integrity: true 
# => "<script src="/assets/application.js" integrity="sha256-TvVUHzSfftWg1rcfL6TIJ0XKEGrgLyEq6lEpcmrG9qs="></script>" 

GitHub的工程有一個interesting blog post,在那裏他們詳細討論該功能。

+0

我想,我可以把它添加到Django的呢? – PetarP

+1

[目前還沒有內置該功能的支持,在Django(https://github.com/cyberdelia/django-pipeline/issues/501)。您需要自行計算並添加它。 –

+0

你能否告訴我如何爲我的應用程序計算這個值,或者只是一個提示,將不勝感激。 – PetarP