tensorflow / tensorflow/tensorboard

CSP directive error in tensorboard plugin

Open
#5,828 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

core:backend core:plugin-api type:feature type:support
Dominant language
TypeScript
Stars
7.2k
Forks
1.7k
Avg merge
4d 22h
Merged PRs (30d)
1

Description

Hi,

I am using tensorboard to create a plugin so that I can render custom charts. I wish to use Chart.JS to add this feature and need to add a script to be able to use it. I do so by calling the loadScript function here in the example plugin.

However, I get Refused to load the script 'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.js' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval' 'sha256-PVZp/wXI2V6hq7T2aNiDNM+vJWIOWwNwyhE53i+6lSQ='". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

function loadScript() {
  const script = document.createElement('script');
  script.src = "https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.js";
  document.body.appendChild(script);
  console.log("I am here...Trying to load ", url);
}

Is there a better way to plot custom charts?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with tensorboard/examples/plugins/example_basic/tensorboard_plugin_example/static/index.js and its loadScript function, then review the reported Content Security Policy error. Determine the supported approach for using Chart.js in a TensorBoard plugin; the issue is done when custom charts can load without violating the policy or the supported limitation is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
chart.js, javascript
Domain
frontend, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.