Scripting is one of the coolest functions within the Content Hub. It gives you as a developer a lot of power and with that, there is also a lot of responsibility. Writing poorly code will have an effect on the performance of the Content Hub. It's therefore important to write proper code. In one of my previous blog posts, I've written about using Unit Testing with scripts. This will definitely help a lot to prevent poorly written code.
Next to that, Sitecore has also made some adjustments to prevent "harmful" code from running on their platform. From Content Hub version 3.2.2 unrestricted scripts will no longer be able to run. This means that the scripts are restricted to a list of permitted libraries.
Permitted libraries
You can use the following libraries in a script:
- System.*
- Stylelabs.M.Sdk.**
- System.Net.HttpStatusCode
- Stylelabs.M.Scripting.Types.**
- Stylelabs.M.Framework.LoadConfigurations.**
- Stylelabs.M.Framework.LoadOptions.**
- Stylelabs.M.Base.Querying.Linq.**
- Stylelabs.M.Base.Querying.Filters.**
- Stylelabs.M.Base.Querying.Query
- Stylelabs.M.Base.Querying.ScrollRequest
- Stylelabs.M.Base.Querying.Sorting
- Newtonsoft.**
Note
- One wildcard (*) means you can use only the classes and objects of that namespace. You cannot use the classes and objects of the embedded namespaces. For example, System.* allows you to use System.ArgumentException, but not System.Web.Services.WebService (the first is directly within the System namespace, unlike the second).
- Two wildcards (**) means you can use any classes and objects of that namespace or any embedded namespaces.
Important
- All scripts in Sitecore Content Hub are restricted, with permitted libraries and blocked libraries.
- If you have legacy unrestricted scripts that are published, and you upgrade to a later version than 3.2.2, your scripts will still work. However, you will not be able to create or publish new unrestricted scripts.
- If you have legacy unrestricted scripts, we recommend converting them to restricted scripts.