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
This complete the previous Improvement, Rendering different HTML container types with ScreenRenderer (OFBIZ-10495), where the xml macro are forgotten.
In same time resynchronise also missing macro renderColumn*
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.
This prevented to run the stable demo, hence the next, weirdly the trunk had
not this problem. Anyway better safe than sorry... Maybe related to Gradle
version or rather libs loaded?
The reason why the stable (and old) demos were not running is because the
EntitySaxReaderTests did not pass
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
Menus link with request-confirmation and confirmation message do not generate the script that open confirmation
When you activate the following menu item :
<menu-item name="statusToCancelled" title="${uiLabelMap.AccountingPaymentTabStatusToCancelled}">
<link target="setPaymentStatus" request-confirmation="true" confirmation-message="You want to cancel this payment number ${payment.paymentId}?">
....
</link>
</menu-item>
OFBiz to not generate the js code link to the request-confirmation attribute because this functionality has been never implemented on java code for MenuRenderer
Thanks to Leila Mekika for raised this issue and solved it
If you use a ComomnDynamicSingle form for realize a search, the FindScreenDecorator would be refresh all the container searchOptions + searchResult.
To keep the coherence, we move the screenStack resolution on the beginning of the decorator, and leave the searchResult to resolve it itself by usage of EmbeddedDecorator.
In practice to keep all dynamism on a search element :
* Main screen with global decorator include the find screen wrap by main-decorator
* The find screen include the search form and include the screen list result wrap by FindScreenDecorator
* The screen result include the list result form wrap by EmbeddedDecorator
When you display a list with search criteria, pagination information and/or sort parameters, if you update an element of this list with a update area, you loose all of them.
Example:
<form name="ListProductMeters" type="list" list-name="productMeters" target="updateProductMeter" paginate-target="ListProductMeters">
<actions>
<entity-condition entity-name="ProductMeter">...
</actions>
<auto-fields-service service-name="updateProductMeter"/>
<field name="meterName"><text size="20"/></field>
<field name="updateButton"><submit/></field>
<on-event-update-area event-type="paginate"/>
<on-event-update-area event-type="sort-column"/>
<on-event-update-area event-type="submit"/>
</form>
Or this works well if you move an next page sort the list.
I realize the same principle for each event which do a modification of element in the list and after refresh it.
I also introduce the possibility to submit a form on modal (for edition) when you press 'enter' that will refresh the origin list.
Last point, the queryString element use to propage pagination state is also forwarded on callback element to keep this on update the list.
Thanks to Gil Portenseigne is help.
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-11813)
To homogenize and help each theme to implement correctly the screen engine concept,
we add two sub-decorators like existing 'FindScreenDecorator'.
DetailScreenDecorator can be used to display a sum up of an object and
its related data.
Embedded Decorator can be used to inject a specific screen in an
structured page area.
Those are composed of several sections that can be handled by the
theme for specific display.
Thanks Nicolas
(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.
If `sanitizer.enable` is turned off, `ListWorkEfforts` form will be vulnerable
to XSS attack, because of incomplete escaping.
Steps to reproduce:
1. Turn off `sanitizer.enable` in owasp.properties
2. Create a WorkEffort entity with name as `<script>alert(1)</script>`
3. Go to page: http://localhost:8080/workeffort/control/FindWorkEffort
4. Search for "Work Effort Name" which contains "script"
Thanks: Xin Wang
This is related to this question from Daniel at
https://github.com/apache/ofbiz-framework/pull/220
I couldn't figure out how to configure OFBiz with my Google API key so ended up
temporarily patching
themes/common-theme/template/includes/GeoLocation.ftl line 44 with my key.
Line 44 looked similar to:
<script src="https://maps.googleapis.com/maps/api/js?key=secret_google_api_key" type="application/javascript"></script>
Is there a way to configure ofbiz with the API key?
Disclaimer: w/o a not free "Google API key" I was not able to test, will ask
Daniel...
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
I tried to use the form-widgets checkbox on a custom find screen.
But after searching values with option/s checked, no checkbox remains selected.
I found similar kind of ticket OFBIZ-11933.
The checkbox was replaced by usage of the asmselect jQuery plugin
This fixes the bug at the framework level.
jleroux: fixes checkstyle issues: missing spaces after (3) if
Thanks: Nameet Jain
I tried to use the form-widgets checkbox on a custom find screen.
But after searching values with option/s checked, no checkbox remains selected.
I found similar kind of ticket OFBIZ-11933.
The checkbox was replaced by usage of the asmselect jQuery plugin
This fixes the bug at the framework level.
jleroux: fixes checkstyle issues: missing spaces after (3) if
Thanks: Nameet Jain
Empty popup occurs when showjGrowl is run later than the javascript from unsafe message. Delay running of showjGrowl function from 10 to 100 milliseconds.
Thanks Jacques for reporting.
(OFBIZ-11810)
Currently when you want to display an information easily on sub-screen
dynamically (example as related element) is currently not possible without
write specific js code.
To simplify it, we introduce a new link type: update-area, to indicate
to the theme that we want to refresh a local area with the call result.
Example :
<link target="ListCategoryProductMembers" link-type="update-area" target-window="detail">
<parameter param-name="productCategoryId"/>
</link>
For this example we indicate that the display result of target 'ListCategoryProductMembers' is going
on the area identify by 'detail'. Pleasure to the theme to manage it.
(OFBIZ-10601)
To improve theme management and provide better tools for new themes, we implement a method to obtain the main menu of a webapp.
Instead of just managing a menu, we extend the functionality by offering a method to expose a summary of the webapp, to simplify the navigation.
For this we add a new attribute on webapp definition app-shortcut-screen :
<webapp name="mywebapp"
...
app-shortcut-screen="component://mycomponent/widget/CommonScreens.xml#ShortcutApp"
...
/>
The idea is to define a new purpose screen *Shortcut* that contains what defines a webapp when an action or navigation has been requested. With this screen you can load a menu, a search, a complex description and use all screen powerfulness to resolve what displaying and support by theming
<screen name="ShortcutApp">
<section>
<actions>
<property-map resource="CommonUiLabels" map-name="uiLabelMap" global="true"/>
</actions>
<widgets>
<decorator-screen name="ShortcutDecorator" location="component://common/widget/CommonScreens.xml">
<decorator-section name="body">
<include-menu name="MyShortcutAppBar" location="component://mycomponent/widget/CommonMenus.xml"/>
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
Each component are self-sufficient to define what shortcuts to display without framework change or knowledge about other component.
Each theme can implement and customize the display rendering at will.
To illustrate an example of implementation we set sub menu for each webapp defined on applications and exploit it on bluelight theme.
Thanks for Dennis Balkir, Jacques Leroux, Leila Mekika and Julien Nicolas for their involvement
(OFBIZ-11809)
During the rendering process, an element have no information about the screen which is dependent from. This not really help to automate some refresh treatment and force the developer to know the screen structure where is the element.
To solve this situation we implement a new class, ScreenStack that allow anytime for any element to identify its direct dependency. This help to resolve the unique Id that the screen take and can be used by the theme.
At any time a developer can retrieve the screen reference with uel function screen:id(screenStack)
example:
<container id="${screen:id(screenStack)}">
The object screenStack is always present during a rendering process.