LoginSignup
20
15

More than 5 years have passed since last update.

JenkinsのHTML Publisher pluginで `Blocked script execution in <URL>. because the document's frame is sandboxed and the 'allow-scripts' permission is not set`となって、画面の一部が表示されない場合の対応方法

Last updated at Posted at 2016-05-18

Jenkinsをアップデートしたら、HTML Publisher plugin で表示した doxygen の生成ページのクラス図等の SVG が以下のエラーで表示されなくなった。

Blocked script execution in <URL>. because the document's frame is sandboxed and the 'allow-scripts' permission is not set

原因としては、Jenkins 1.625 以降からセキュリティポリシーが変更になったとのこと (当然 2.x 以降も同様)

Configuring Content Security Policy - Jenkins - Jenkins Wiki

HTML5のsandbox属性については以下などを参照

sandbox 属性 | HTML5 タグリファレンス | W3 Watch Reference

とりあえずの回避策

Jenkinsの管理 => スクリプトコンソール から以下を実行する。

System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")

これで、上記のsandbox由来のエラーは消えるはず。(おそらくJenkinsを再起動したりするとこの設定は無効化されるので注意)

正式な回避策

Jenkinsの起動オプションから上記の設定を追加しても、同様の効果は得られるはずだが、わざわざ追加されたセキュリティの無効化をしても大丈夫なのかの検討は必要かと思われる。

Jenkinsの起動オプションによる対応

以下のように、 -Dhudson.model.DirectoryBrowserSupport.CSP="" オプションを付けて起動する。

java -Dhudson.model.DirectoryBrowserSupport.CSP="" -jar jenkins.war

TODO: プラグインまたはHTML側の設定でなんとかできないかの検討

参考

javascript - Blocked script execution in . because the document's frame is sandboxed and the 'allow-scripts' permission is not set - Stack Overflow

20
15
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
15