I created an plot with python bokeh. The output is an html file. Now I want to render that plot in the Label Studio Labelling interface, however, it does not show up.
My setup:
I have a local Label Studio instance running via Docker
I use a local storage setup for fetching the html files. Generally that works, a simple dummy html file with just a bit of text is found and displayed correctly.
This is the Labelling interface I use:
<View>
<HyperText name="website" valueType="url" value="$website" inline="false"/>
<Header value="Above should be the html plot rendered, obviously it is not"/>
<Rating name="rating" toName="website" maxRating="10" icon="star" size="medium" />
</View>
This HTML probably contains JavaScript. All JavaScript scripts are removed for security purposes from labeling tasks.
Label Studio Enterprise supports custom JavaScripts as a separate configuration for your labeling interface. If you rely heavily on it, consider switching to Label Studio Enterprise.
Makes sense to me, just a (probably stupid) follow-up question: If I would not use the html file directly, but instead host and serve the html in another web app (for example an Azure web app, where I would have control on the CORS settings), would hat help? So in my labeling configuration I would refer to the website where the bokeh plot lives via <iframe src=https:// … >
We want to show a 3d HTML plot generated with K3D. So the plot is contained in a single HTML file. Both HTML, CSS, and Javascript.
The user should then be able to see and interact with the plot. While as an example label it as being Over-segmentation, Under-segmentation, or Exact match.
Is this possible?
When reading the Custom scripts in LS enterprise, I can only see a way to use plotly not to show an HTML file with Javascript code directly?
to follow up on s204159 question: is there a way in the community version (even in the code itself and building a custom container for hosting) to disable the security feature that removes all JavaScript for the labelling task?
You can technically re-enable JavaScript in HyperText by modifying the Label Studio source code that sanitizes HTML, but there is no built-in switch or setting in the Community Edition to disable the sanitization checks. If you build Label Studio yourself, you could remove or alter the portion that disallows script tags, for example in web/libs/editor/src/utils/html.js where disallowedTags includes script: true. However, be aware this is strongly discouraged from a security standpoint, because the sanitization step prevents malicious scripts from running in Label Studio.
If you still want to proceed, you would:
Fork/clone the Label Studio repository.
Locate the sanitizeHtml function in web/libs/editor/src/utils/html.js and remove or comment out script from disallowedTags.
Build your custom Docker image (or run the project locally) with these changes.
Keep in mind that this disables an important security measure and poses potential risks if your data or environment is exposed to untrusted HTML or tasks.