tensorflow / tensorflow/tensorboard
CSP directive error in tensorboard plugin
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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