I just tried g npm_outdated undocumented Gradle task and got this result*:
> Task :npm_outdated
Package Current Wanted Latest Location
dompurify 2.3.3 2.3.4 2.3.4 ofbiz-framework
jquery 3.5.1 3.6.0 3.6.0 ofbiz-framework
jquery-migrate 3.3.1 3.3.2 3.3.2 ofbiz-framework
jquery-ui-dist 1.12.1 1.13.0 1.13.0 ofbiz-framework
This updates accordingly. I keep this task open as an umbrella tasks for similar
subtasks in future like we have OFBIZ-10213
Thanks: Jacques for inspiration and guidance, Aditya Sharma for sharing
thoughts and visions and Ingo Richter for finding this gem.
- changed grid 'EditProductPriceRulesCondition' list-name to reflect
correct list
After checking that we don't have any possible vulnerability using
jquery-ui-dist (ie 1.12.1) vs jquery-ui (1.13.0) based on* and checking in code
I decided to use jquery-ui-dist from npm. I just had to modify OfbizUtil.js to
get back to element.form() (for 1.12.1) vs element._form() for 1.13.0
I hope the npm jquery-ui-dist package will be updated soon. The release of
1.13.0 is quite fresh (<1 month).
We also need a mechanism to check the update or our npm packages.
As Aditya explained:
<<Minor updates can be handled implicitly by node when specified with tilde
range or caret range for version. For major updates, we just have to change
the version and use npm install.>>
So for now it will be manual. Later something like** could be used (I wonder
about https://snyk.io/, but that needs Infra agreement)
* https://blog.jqueryui.com/2021/10/jquery-ui-1-13-0-released/
** https://dev.to/dennismphil/automate-your-node-dependency-updates-4aga
Previously in commit dfc7ee4 I blindly followed GH CodeQL's advice about js CSS.
I had a doubt, indeed it was irrelevant. I misinterpreted the advice.
Then I tried to follow OWASP's advice about using node-esapi but was unable to
make it work in a reasonable time. Neither with "node require" nor requireJS;
ie using either CommonJS or AMD format, I guess I missed something there.
Anyway, I finally I set my sights on DOMPurify which is doing the job.
There is only one "foot-gun potential":
https://github.com/cure53/DOMPurify#user-content-is-there-any-foot-gun-potential
"If you first sanitize HTML and then modify it afterwards, you might easily void
the effects of sanitization. If you feed the sanitized markup to another library
after sanitization, please be certain that the library doesn't mess around with
the HTML on its own."
Fortunately, that's not a concern in our simple case.
This commit
* fixes the 3 remaining js vulnerabilty reported by
* prevents checking all under node_modules since it's done by npm in console
(a bit weak though, ie not clearly on purpose)
* gives more information about 'ci' vs 'install' in npmInstallCommand
Fixes "A DOM text reinterpreted as HTML" issue in fieldlookup.js
GH CodeQL reports:
"A webpage with this vulnerability reads text from the DOM, and afterwards adds
the text as HTML to the DOM. Using text from the DOM as HTML effectively
unescapes the text, and thereby invalidates any escaping done on the text. If an
attacker is able to control the safe sanitized text, then this vulnerability can
be exploited to perform a cross-site scripting attack.
Recommendation
To guard against cross-site scripting, consider using contextual output
encoding/escaping before writing text to the page, or one of the other solutions
that are mentioned in the References section below.
Example
"Extracting text from a DOM node and interpreting it as HTML can lead to a
cross-site scripting vulnerability."
GH CodeQL suggest:
The above vulnerability can be fixed by using $.find instead of $. The $.find
function will only interpret target as a CSS selector and never as HTML,
thereby preventing an XSS attack.
GH CodeQL reports 556 "Incomplete string escaping or encoding branch" issues
(there are 588 issues at all).
Most of them are in jQuery-UI but not only. So this only an attempt to clarify
among the 23 pages reported by upgrading jQuery-UI to 1.13.0.
As reported at https://markmail.org/message/uof5ldk4o3x2ya33 I did not spot that
I also needed to commit the checksum change.
There is maybe more to do related to using "npm ci" instead of "npm install",
I'll check it out.
Removed javascript for jQuery, jQuery Migrate, jQuery Browser and jQuery Validation from OFBiz sources. Instead these are now retrieved during the build as NPM packages using gradle-node-plugin.
Thanks: Aditya Sharma for implementation.
Transform workEffort creation using modal and callback system to
illustrate this improvement.
A new Attribute `from-event-result` is created for `set-callback`
parameters, to indicate that the callback should be called with a
parameter which value comes from the event result initiated by the link.
In this example, is retrieved from the workeffort creation event the id
needed to display the WorkEffortSummary screen of the new data.
A new pattern is created to encode in CALLBACK JWT token the data that
should be parsed from the event. The parsing occurs in javascript.
Thanks to Xin Wang comments in https://s.apache.org/trrkk we discover
that label retrieval through javascript are not working.
One example exists, but is not functionnal and do not use jgrowl.
This commit allow jgrowl use directly from javascript (showjGrowlMessage(...))
while making label retrieval synchronous for Jgrowl and fromDate/thruDate existing
feature.
Clean up showErrorAlertLoadUiLabel that became orphan.
After the refactoring realized on issue OFBIZ-12268, a typo has been introduce when we scanned the presence of error during an ajax call.
The typo raised that ignore the case of an error is present as list.
The same typo is also present for event message list.
Thanks to Xin Wang to alert on this problem through issue OFBIZ-12272
At this time the function ajaxSubmitFormUpdateAreas present on themes/common-theme/webapp/common/js/util/OfbizUtil.js take a form, submit it thought ajax and wait a success to analyse a json result for update an area with the cvsAreaString given on parameter.
I realized different improvements :
* refactoring some js code to centralize the analyze of json result for check if the call is a success or error
* Analyze the content-type of the response if is a json continue as before, else take the return and update first area (useful for submit search or filtering form)
* Manage the case who the ajax call failed and we inform the user
* Add a trigger to force the modal close on submit success
Thanks to Leila Mekika, Marie-Aline Pantais and Gil Portenseigne for looking on that.
(OFBIZ-12260)
When you generate a link with the type hidden-form and the link present an update area, on the click jquery failed to resolve the form.
Example of a current link generate :
<a href="javascript:ajaxSubmitFormUpdateAreas('ListProductMeterActionMenus_delete_LF_1__0', 'embedded13009956-a841-47d3-86b1-b1931e6b430e,https://localhost:8443/catalog/control/ListProductMeters,productId=GZ-1000')">javascript:ajaxSubmitFormUpdateAreas('ListProductMeterActionMenus_delete_LF_1__0', 'embedded13009956-a841-47d3-86b1-b1931e6b430e,https://localhost:8443/catalog/control/ListProductMeters,productId=GZ-1000')</a>
The problem come from OfbizUtil.js:748
var $form = jQuery("#" + form)
To solve it, we change the form resolution in the function ajaxSubmitFormUpdateAreas with use the form name instead the form id.
Thanks to Xin Wang for this suggest to fix it.
asm select library is already replaced with select2 library, but the library files still exist in code base unused.
asm_asmListItemPercentOfForm varaible was used to set the width of the selected items which were displaced distictly from select fields. With select2, the selected items display inside the input field so it is no more needed
Thanks Jacques Le Roux for reporting it
Use importLibrary js function to load locale-specific datepicker js.
Corrected locale naming in macro to use '.locale'.
Tested page at /ordermgr/control/findreturn and /ordermgr/control/orderentry.
Use importLibrary js function to load time-related js and css for date time picker.
Tested page at /ordermgr/control/findreturn and /ordermgr/control/orderentry