Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-25020

Relax import constraints for Automation Scripting

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 10.2
    • Component/s: Automation
    • Impact type:
      Configuration Change
    • Upgrade notes:
      Hide

      It's now possible to allow specific Java classes to be used via Automation Scripting, by default we add:

      • java.util.ArrayList
      • java.util.Arrays
      • java.util.Collections
      • java.util.UUID
      • org.nuxeo.runtime.transaction.TransactionHelper
      • org.nuxeo.ecm.core.api.Blobs
      • org.nuxeo.ecm.core.api.impl.blob.StringBlob
      • org.nuxeo.ecm.core.api.impl.blob.JSONBlob

      Other classes can be added, and previously-allowed ones denied, through:

        <require>org.nuxeo.automation.scripting.classfilter</require>
        <extension target="org.nuxeo.automation.scripting.internals.AutomationScriptingComponent" point="classFilter">
          <classFilter>
            <allow>com.example.MyClass</allow>
            <allow>com.example.MyOtherClass</allow>
            <deny>org.nuxeo.runtime.transaction.TransactionHelper</deny>
          </classFilter>
        </extension>
      

      One can use <deny>*</deny> to disallow all previously-allowed classes.

      The default contribution now allows scripting code like:

      function run(input, params) {
          var uuid = java.util.UUID.randomUUID().toString();
          return org.nuxeo.ecm.core.api.Blobs.createJSONBlob("{\"uuid\": \"" + uuid + "\"}");
      }
      
      Show
      It's now possible to allow specific Java classes to be used via Automation Scripting, by default we add: java.util.ArrayList java.util.Arrays java.util.Collections java.util.UUID org.nuxeo.runtime.transaction.TransactionHelper org.nuxeo.ecm.core.api.Blobs org.nuxeo.ecm.core.api.impl.blob.StringBlob org.nuxeo.ecm.core.api.impl.blob.JSONBlob Other classes can be added, and previously-allowed ones denied, through: <require> org.nuxeo.automation.scripting.classfilter </require> <extension target= "org.nuxeo.automation.scripting.internals.AutomationScriptingComponent" point= "classFilter" > <classFilter> <allow> com.example.MyClass </allow> <allow> com.example.MyOtherClass </allow> <deny> org.nuxeo.runtime.transaction.TransactionHelper </deny> </classFilter> </extension> One can use <deny>*</deny> to disallow all previously-allowed classes. The default contribution now allows scripting code like: function run(input, params) { var uuid = java.util.UUID.randomUUID().toString(); return org.nuxeo.ecm.core.api.Blobs.createJSONBlob( "{\" uuid\ ": \" " + uuid + " \ "}" ); }
    • Sprint:
      nxFG 10.2.6
    • Story Points:
      3

      Description

      Automation Scripting currently forbids all JavaScript imports. This is too strict and we should whitelist commonly-used classes and allow this list to be extended.

      Example classes to allow:

      • java.util.ArrayList
      • java.util.UUID
      • org.nuxeo.runtime.transaction.TransactionHelper
      • org.nuxeo.ecm.core.api.impl.blob.StringBlob
      • org.nuxeo.ecm.core.api.impl.blob.JSONBlob

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 3 hours
                  3h