plotly / plotly/plotly.py

Output of renderer 'notebook' violates Content Security Policy

Aperta
#3,739 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

feature P3 security
Lingua principale
Python
Stelle
18.8k
Fork
2.8k
Merge medio
16h 26m
PR unite (30g)
21

Descrizione

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?

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia dal renderer del notebook configurato tramite pio.renderers.default = "notebook" e traccia il modo in cui produce l'HTML esportato. Confronta le dipendenze plotly.js incorporate con il bundle strict di plotly.js menzionato nell'issue. Il lavoro è completato quando l'esportazione del notebook funziona con la policy script-src indicata senza richiedere unsafe-eval.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, node.js, python
Ambito
data-visualization, frontend, security
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
32/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.