IBM Verify

IBM Verify

Join this online user group to communicate across Security product users and IBM experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  javascript version isam 9.0.6.0

    Posted Mon March 11, 2019 10:22 AM
    ​Hi,

    What javascript version is included in isam 9.0.6.0
    It says in the lmi that it uses ES 6.
    I wish to use this.

    ['a', 'b', 'c'].includes('b')

    But gets:
    Caused by: org.mozilla.javascript.EcmaError: TypeError: Cannot find function includes in object a,b,c. (InfoMap#4)


    ------------------------------
    Regards Mikael
    ------------------------------


  • 2.  RE: javascript version isam 9.0.6.0

    Posted Tue March 12, 2019 03:23 AM
    Hi Mikael,

    java.util.ArrayList Java class is available to use in writing  JavaScript rules in ISAM, the above logics could be written in following with java.util.ArrayList class

    var array = new java.util.ArrayList();
    array.add("a");
    array.add("b");
    array.add("c");
    var isIncluded = array.contains("b");

    Best Regards

    Chen Yongming

    ------------------------------
    Yongming Chen
    ------------------------------



  • 3.  RE: javascript version isam 9.0.6.0

    Posted Tue March 12, 2019 04:44 AM
    Hi Mikael,

    The 9.0.6 appliance has Rhino 1.7.9 onboard, which claims to have all features of JavaScript 1.7. And JavaScript 1.7 claims to be conform with EcmaScript edition 6. Yes, it's complicated :-).
    It seems like Rhino does not have all the 'fancy' features, see this link for an overview of the compatibility: 
    http://mozilla.github.io/rhino/compat/engines.html
    And then look for ".includes" -> it seems Rhino can only use .includes() on string objects. While the EcmaScript standard says it should work on just any object...
    For reference only: here's the link to EcmaScript ed 6: http://www.ecma-international.org/ecma-262/6.0/index.html

    Kind regards, Peter.

    ------------------------------
    Peter Volckaert
    Sales Engineer
    IBM Security
    ------------------------------



  • 4.  RE: javascript version isam 9.0.6.0

    Posted Tue June 23, 2020 10:59 PM
    Hi Peter

    Would you know what Rhino version is bunlded with ISAM 9.0.7.0 and 9.0.7.1 ?

    We're looking to use the Map() object but it get's rejected at runtime as not supported.

    ------------------------------
    Sylvain Gilbert
    ------------------------------



  • 5.  RE: javascript version isam 9.0.6.0

    Posted Wed June 24, 2020 01:28 AM
    Hi Sylvain,

    I was wondering too, so I did some digging around, but it's not completely clear: it seems v9.0.7.1 ships with both Rhino v1.7.9 and v8.0.0:
    [isam@3b9bc0a04f73 usr]$ pwd; find . -name *rhino*.jar
    /opt/ibm/wlp/usr
    find: './servers/default/certs': Permission denied
    ./servers/runtime/workarea/org.eclipse.osgi/190/0/.cp/rhino-1.7.9.jar
    ./extension/lib/isam/rhino/com.ibm.security.access.thirdparty.rhino_8.0.0.jar
    [isam@3b9bc0a04f73 usr]$

    Judging on the paths, I assume v1.7.9 is the "standard" one, but there may be some way to activate v8.0.0 through an extension?
    Not sure if v8 would help you though, as the rhino project states:

    "Rhino 1.6 and greater implement ECMA-357 ECMAScript for XML (E4X). See the specification for more information on the standard, and Rhino version 1.6R1 release notes for details on the implementation in Rhino."

    Rhino does allow to use java objects, so if you really need the map, you could try to leverage the java map object (but you'll need to take care of the subtile differences between js strings and java strings): https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/Embedding_tutorial#Expose_Java_APIs

    Kind regards,
          Kristof Goossens

    ------------------------------
    Kristof Goossens
    ------------------------------



  • 6.  RE: javascript version isam 9.0.6.0

    Posted Wed June 24, 2020 03:04 AM
    Hi,

    I had a quick look on the ISAM 9.0.7.1 VM I have running on my laptop. The Rhino version is 1.7.9.
    I'm almost sure that the rhino_8.0.0.jar file that @Kristof Goossens mentioned has no meaning when it comes to the Rhino version that is used by ISAM. Also the latest Rhino is 1.7.12 as seen on this link
    To verify the Rhino version that's used by an ISAM appliance, I downloaded an ISAM support file​, unzipped that file, and looked at the ls.txt file in the iswga directory. I saw lots of packages with an 8.0.0 postfix, so I'm assuming it's more like an ISAM-internal way of packaging things. 

    Cheers, Peter

    ------------------------------
    Peter Volckaert
    Senior Sales Engineer
    Authentication and Access
    IBM Security
    ------------------------------



  • 7.  RE: javascript version isam 9.0.6.0

    Posted Tue March 12, 2019 05:15 AM
    Hi Mikael,

    Whenever you wish to use functions that are not supported, I recommend looking for them at MDN.
    Usually, there is a "polyfill" for it there. A Polyfill is a function definition that extends the prototype. All you need to do is paste it in your script and you'll be able to use it as if you where working in a JS engine that supports it.

    For the includes example, you can find the polyfill code here: https://developer.mozilla.org/nl/docs/Web/JavaScript/Reference/Global_Objects/Array/includes#Polyfill

    Cheers

    ------------------------------
    Kristof Goossens
    ------------------------------



  • 8.  RE: javascript version isam 9.0.6.0

    Posted Tue March 12, 2019 07:54 PM
    Hi,

    Thanks for the information and tips on on how to solve it.


    ------------------------------
    Regards Mikael
    ------------------------------



  • 9.  RE: javascript version isam 9.0.6.0

    Posted Mon March 18, 2019 07:52 AM
    On this topic , one way I generally use to verify which functions are available in javascript objects in ISAM mapping rule is to 

    get the Object.getOwnPropertyNames for that object and trace it :

    IDMappingExtUtils.traceString("print functions for Array.prototype : " + Object.getOwnPropertyNames(Array.prototype));


     in this case in 9060 It says :


    ... functions for Array.prototype : constructor,toString,toLocaleString,toSource,join,reverse,sort,push,pop,shift,unshift,splice,concat,slice,indexOf,lastIndexOf,every,filter,forEach,map,some,find,findIndex,reduce,reduceRight,,length

    ------------------------------
    Gianluca Gargaro
    IBM
    Roma
    ------------------------------