Improve the groovy dsl with a success method that return directly all fields
Previously we used:
Map result = success()
result.myId = myId
return result
Now we can write:
return success(myId: myId)
Or
Previously we used:
Map result = success('Wonderful !')
result.myId = myId
return result
Now we can write:
return success('Wonderful !', myId: myId)
Improve the groovy dsl with a simple method 'label' to resolve an uiLabel instead of use 'UtilProperty.getMessage()' on groovy script.
Previously we used:
UtilProperties.getMessage("AccountingUiLabels", "AccountingUpdatePaymentPermissionError", 'locale'))
Now we can write:
label("AccountingUiLabels", "AccountingUpdatePaymentPermissionError")
On the service calcShipmentCostEstimate, each estimated shipment cost is analysed to resolve which ones should be applied on the order.
During the breakQtys block analysis, OFBiz checks if the estimate match the quantity with their breaks and validates if one is good.
If a rule contains multiple break type (ex: weight and price) this will be ignored or use as partial, only one break would be analysed.
To solve it we extend the analyse on the break type combinaison.
After a global code review, we reformat the function to down less code quantity for help the reader on:
* use an Util function to resolve BigDecimal values
* dedicate function to resolve the shipping address
* dedicate function to validate a break type
* move multiple loop to stream
Thanks to Gil Portenseigne and Jacques Leroux for their look
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.
Currently, when you would be rendering a widget screen from a ftl template, you can use a element screen present on context to call the renderer :
${screens.render("component://common/widget/CommonScreens.xml#countries")}
This rendering is realized with the context present when the object screen has been initialized.
To simplify the screen call from freemarker template, I implemented a new macro ofbizScreen
You can call a Ofbiz screen with the ftl context with simple macro
<@ofbizScreen>component://mycomponent/widget/MyComponentScreens.xml#MyScreen</@ofbizScreen>
You can also write
<@ofbizScreen location="component://mycomponent/widget/MyComponentScreens.xml" name="MyScreen"/>
Or set a default location on your context
action :
context.defaultTemplateLocation = "component://mycomponent/widget/MyComponentScreens.xml"
widget :
<@ofbizScreen>MyScreen</@ofbizScreen>
When the screen would be call, the context to rendering the screen would be use the current context:
<#list contactMechs as contactMech>
<#assign contactMechId = contactMech.contachMechId/>
<@ofbizScreen>component://mycomponent/widget/MyComponentScreens.xml#DisplayContactMech</@ofbizScreen>
</#list>
Safer completing solution as recommended by weinull orz <weinull@outlook.com>
Previous commit was OK, but better be safe than sorry ;)
Also forgot to commit the DENIEDFILEEXTENSIONS checkstyle change last time
Thanks: weinull orz for the the right suggestion (done 2021-08-13)
The fix I did is two folds:
filters extensions (thanks to Zhujie's suggestion of a list of extensions to ban)
deletes bad files at the right place (thanks to thiscodecc's report)
Thanks: thiscodecc for the security report
SonarQBE did not detect bug put in in ModelInduceFromDb.jsp by 13d6bc2,
found it by chance
"moz-linear-gradient(bottom" should be better than "moz-linear-gradient(to bottom"
When you have a user with long password (greater than 256 characters) present in OFBiz and you try to log with, OFBiz return a long error message with sensitive information due to exceeding value size to store on the field UserLoginHistory.passwordUsed.
To solve this we don't return any information on the genericValue that failed and analyze the field passwordUsed to escape the case where the password set to login is create than the database field capacity.
Thanks to Daniel Elkabes <daniel.elkabes@whitesourcesoftware.com> and Hagai Wechsler <hagai.wechsler@whitesourcesoftware.com> from white source software to raise the problem.
(after discussing this on security@ofbiz.apache.org, it was decided to open a
Jira issue for that)
I've noticed that OFBiz Framework sometimes uses static initialization vectors
(IV) while creating a cipher:
https://s.apache.org/vhlbjhttps://s.apache.org/nyndk
IVs should be unique and ideally unpredictable to avoid producing the same
ciphertexts for the same plaintexts.
The issues can be fixed with something like the following:
byte[] rawIV = new byte[8];
SecureRandom random = new SecureRandom();
random.nextBytes(rawIV).
IvParameterSpec iv = new IvParameterSpec(rawIV);
jleroux: this prepends the IV in order to decrypt the plaintexts. It's similar
to what has been done for the DesCrypt class. But contrary to the DesCrypt class
I did not test.
Thanks: Artem Smotrakov
When you use a platform-specific element on CompoundWidget like this :
<ws:platform-specific>
<ws:html><ws:html-template location="component ..."/></ws:html>
</ws:platform-specific>
the ModelScreenWidget failed to resolve the attended type due to the
namespace presence (ws:html != html) and finally failed to rendering the screen
Complete the previous commit where I forgot this part
(after discussing this on security@ofbiz.apache.org, it was decided to open a
Jira issue for that)
I've noticed that OFBiz Framework sometimes uses static initialization vectors
(IV) while creating a cipher:
https://s.apache.org/vhlbjhttps://s.apache.org/nyndk
IVs should be unique and ideally unpredictable to avoid producing the same
ciphertexts for the same plaintexts.
The issues can be fixed with something like the following:
byte[] rawIV = new byte[8];
SecureRandom random = new SecureRandom();
random.nextBytes(rawIV).
IvParameterSpec iv = new IvParameterSpec(rawIV);
jleroux: we prepend the IV in order to decrypt the plaintexts. I'll do
something similar in ValueLinkApi class ASAP
Thanks: Artem Smotrakov
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
When you use a platform-specific element on CompoundWidget like this :
<ws:platform-specific>
<ws:html><ws:html-template location="component ..."/></ws:html>
</ws:platform-specific>
the ModelScreenWidget failed to resolve the attended type due to the
namespace presence (ws:html != html) and finally failed to rendering the screen
Menus link defaut parameters for height and width are not considered when the
link is generated. When parameter with empty value is passed to the macro, macro
default values are not retrieved.
To reproduce
you can create a "layered-modal" type link in a menu and click on the link
(without height nor width):
this will generate the link with parameters "data-dialog-height" and
"data-dialog-width" empty
Patch provided
When applied, the MacroMenuRenderer.renderLink will not send empty values to
the macro so that default value will be retrieved (what is actually done on
MacroFormRenderer.renderLookup)
Thanks: Leila
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
There is an error when the callback element resolve the list parameters, it check the parameters element as field and not as final variable.
This generate an empty callback link.
My changes in OFBIZ-12249 were only to handle textareas.
The case Nicolas reported is not related to a textarea but to the special case
of KeywordSearchBox handled by KeywordSearchBox.ftl.
So this simply bypasses this special case using the "DUMMYPAGE" key then present
The default padding scheme of ECB mode for
org.apache.shiro.crypto.AesCipherService is different between v1.4.1 and
v1.7.1, i.e.:
v1.4.1 getPaddingSchemeName() result is "PKCS5Padding"
v1.7.1 getPaddingSchemeName() result is "NoPadding"
This patch specify padding scheme explicitly, after that exception
mentioned in build.gradle does not raise anymore, and initial data can
load successfully.
I get an IndexOutOfBoundsException when using the EntityImport.
The problem occurs while having a resemblance of an url in the data.
For example
screenPath="component://... is interpreted as url because of '://'
but doesn't match a valid url pattern.
jleroux: I decided to keep it simple and to take the "component://" and the
"https://localhost" cases apart. I see no reasons to fear "https://localhost"
there. It should be only used in a safe dev env.
Thanks: Sebastian Berg and Nicolas Malin for report
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.
Refreshment information are controlled by the calling object,
instead of the called form.
This avoid dependency between called form and parent screens.
The set-callback tag generate a jwt encoded UpdateArea widget, that
is transmitted through submits and links until a submit with no
update-area information is met. This specific submit ends the
process launched by the link, and trigger the refresh action
contained into the JWT token.