plotly / plotly/plotly.py

Output of renderer 'notebook' violates Content Security Policy

オープン
#3,739 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

feature P3 security
主要言語
Python
スター
18.8k
フォーク
2.8k
平均マージ
16時間 26分
マージ済み PR(30日)
21

説明

Setup description

We have plotly.py setup with pio.renderers.default = "notebook" and we use nbconvert 6.5 to convert executed notebooks to HTML reports with input cells stripped out. These HTMLs are served by a simple node.js front end that has Content Security Policies for script-src setup due to security requirements.

Issue description

The exported HTML contains inline script tags one of which has plotly.js and its dependencies. One of the dependencies seems to violate our script-src Content Security Policy as it is using eval(), new Function(), setTimeout([string], ...) and setInterval([string], ...) for evaluating strings Reference

CSP Error from Chrome:

  1. Content Security Policy of your site blocks the use of 'eval' in JavaScript`
    1. The Content Security Policy (CSP) prevents the evaluation of arbitrary strings as JavaScript to make it more difficult for an attacker to inject unathorized code on your site.

      To solve this issue, avoid using eval()new Function()setTimeout([string], ...) and setInterval([string], ...) for evaluating strings.

      If you absolutely must: you can enable string evaluation by adding unsafe-eval as an allowed source in a script-src directive.

      ⚠️ Allowing string evaluation comes at the risk of inline script injection.

    2. AFFECTED RESOURCES
      1. 1 directive
        1. Source Location Directive Status
          report:14743 script-src blocked
Screen Shot 2022-05-19 at 8 10 12 AM

Ask

Is there a way to provide plotly.py the ability to use the plotly.js strict bundle and hence avoid having to use dependencies that violate CSP?

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

pio.renderers.default = "notebook" で設定された notebook renderer から始め、それがエクスポートされた HTML をどのように生成するかを追跡します。埋め込まれた plotly.js の依存関係を、issue で参照されている plotly.js strict bundle と比較します。指定された script-src ポリシーの下で、unsafe-eval を必要とせずに notebook のエクスポートが機能すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, node.js, python
領域
data-visualization, frontend, security
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
32/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。