Commit Graph
10634 Commits
Author SHA1 Message Date
Jacques Le Roux d83603f064 Improved: Migrate Ofbiz bb 0.8 config to 3.2 (INFRA-22279)
At Gavin's request a non functional change to test Buildbot migration
2021-11-06 12:48:40 +01:00
Jacques Le Roux ce564ebc2a Improved: Try to reduce "Incomplete string escaping or encoding branch" issues reported by CodeQL (OFBIZ-12356)
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.
2021-10-31 15:29:30 +01:00
Jacques Le Roux 9f822ab337 Improved: removes Java compilation unchecked] and deprecation warnings 2021-10-18 13:33:52 +02:00
Jacques Le Roux 2489381f7f Improved: Handle remaining checkstyle errors (OFBIZ-12169)
Adds unused hashCode method to *ArtifactInfo and PackingSession classes
Makes final CmsEvents, ContactMechWorker and PartyWorker classes

There are no longer any checkstyle issues
2021-10-17 15:59:35 +02:00
Jacques Le Roux 49cae3c73a Improved: Handle remaining checkstyle errors (OFBIZ-12169)
Adds getter and setter to ScreenRenderer class
Adds unused hashCode method to ControllerRequestArtifactInfo class
Makes final UomWorker and ContactHelper classes

Only 10 checkstyle issues now
2021-10-17 15:45:55 +02:00
Jacques Le Roux c85f60279b Improved: Remove Checkstyle warning related to double parenthesis at start of lines (OFBIZ-12340)
At https://markmail.org/message/3mhzlqew3igad3r2 I reported an issue that I was
not able to really qualify. After exchanging with a Checkstyle expert
(see markmail thread).

I was unable to find what in our checkstyle.xml file was wrongly throwing these
warnings. I decided that there was no reason to throw those warnings.

So I decided to put the SuppressionCommentFilter in our checkstyle.xml file and
use CHECKSTYLE_OFF: ALMOST_ALL/CHECKSTYLE_ON: ALMOST_ALL around
the concerned lines as documented here
https://checkstyle.sourceforge.io/config_filters.html#SuppressionCommentFilter_Examples
2021-10-17 15:38:30 +02:00
Jacques Le Roux 87f9981f71 Improved: Handle remaining checkstyle errors (OFBIZ-12169)
Fixes wrong methods names in EntityFunction class
2021-10-17 10:49:51 +02:00
Aditya Sharma 4bd30ce4d5 Implemented: Use NPM with gradle to get external JS dependencies (OFBIZ-11960)
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.
2021-10-12 20:50:41 +01:00
Jacques Le Roux 3cb4e791e0 Improved: post-auth Remote Code Execution Vulnerability (OFBIZ-12332)
Prevents an useless inevitable warning by commenting out
RequestWrapper::getParameterNames and with it all the unused methods in
RequestWrapper class

Also better comments CacheFilter::doFilter by giving its real and only goal:
<<to prevent a post-auth security issue described in OFBIZ-12332>>
2021-10-11 09:45:09 +02:00
Jacques Le Roux 351d752690 Improved: Refactor methods signature to reduce the number of params they use (OFBIZ-12335)
Fixes a typo about filterConfiguration in CacheFilter.java
2021-10-10 13:32:49 +02:00
Jacques Le Roux 19d2932591 Fixed: post-auth Remote Code Execution Vulnerability (OFBIZ-12332)
In previous commit, in CacheFilter::doFilter, I checked "xmlrpc"  when it was
actually "/control/xmlrpc"
2021-10-10 11:24:55 +02:00
Jacques Le Roux a5bdcc6f9e Fixed: post-auth Remote Code Execution Vulnerability (OFBIZ-12332)
This definitely solves all issues by introducing a CacheFilter and
RequestWrapper classes inspired by several works found on the Net.
Also moves the change introduced before in ContextFilter to CacheFilter.

The basic problem is that you only can use once
ServletRequest::getInputStream or the ServletRequest::getReader
Also not both, even once, ie they can be seen as same from this POV.

The integration tests all pass.

Also replace the checked String "</serializable>" by "</serializable" as, like
reported by Jie Zhu, the former could be bypassed by using "</serializable >"

Thanks: Jie Zhu for report
2021-10-10 08:00:51 +02:00
Jacques Le Roux cd03a6a98f Improved: post-auth Remote Code Execution Vulnerability (OFBIZ-12332)
Temporarily comments out XMLRPC tests.

I'll work on a definitive solution ASAP
2021-10-09 07:48:55 +02:00
Jacques Le Roux 9c1698917a Fixed: post-auth Remote Code Execution Vulnerability (OFBIZ-12332)
As reported by Jie Zhu:
<<The latest version of the OFBiz framework (17.12.08) is affected by an
XMLRPC Remote Code Execution Vulnerability.
This vulnerability is caused by incomplete patch repair of cve-2020-9496.>>

Actually this is not an OFBiz bug (so not related to CVE-2020-9496)
but an old XMLRPC bug (Archiva was(/is?)) also affected:
https://nvd.nist.gov/vuln/detail/CVE-2016-5003

Unfortunately XMLRPC is no longer maintained, so it's OFBiz responsibility to
fix this bug.

As the code that secures serialisation in OFBiz is not reached by this bug, the
solution is to secure it at the ContextFilter class level (ie before it reaches
secured serialisation in OFBiz source).

Thanks: Jie Zhu for report and help.
2021-10-08 19:13:20 +02:00
Daniel Watford dabafa77f9 Improved: Use FTL with_args on macro calls (OFBIZ-12274)
Previous approach to rendering FTL macros was to encode all macro
arguments as a single string and pass to the FTL processor.

New approach is to use FTL's default wrapper to handle passing Java
types to the FTL processor and referencing them from macro calls.

Thanks: Xin Wang for introducing FTL with_args approach and providing
POC.
2021-09-27 10:33:17 +01:00
Jacques Le Roux dfc05edbab Improved: Remove Docbook parts now useless since Ascidoc is used for online help (OFBIZ-12327)
At https://markmail.org/message/inoihmcon37wq5zz I suggested:

If I'm not wrong, we no longer use Docbook anywhere. So I suggest to remove it
from:

1. cmssite component, where it was used by the online help, now assured by
    Asciidoc. BTW, for whom it could concern, I noticed that anchors jumping
    in adoc files does not work in online help
2. docbook.dtd in content component only used by the cmssite component
3. docbook.css in themes, I'm not sure that still useful there
2021-09-25 10:31:03 +02:00
Gil Portenseigne 3cea95fc4c Create a deny list to reject webshell tokens (OFBIZ-12324)
Replace java 9 `List.of` that is not yet compatible with current CI java
configuration (java 8)
2021-09-23 15:30:42 +02:00
Gil Portenseigne c0f8783d8d Improved: Create a deny list to reject webshell tokens (OFBIZ-12324)
Improve readability using stream api, while adding unit test for
refactoring validation.
Fix deniedWebShellTokens property where some blank space where removed
and '// python' comment was inlined.
2021-09-23 14:59:00 +02:00
Jacques Le Roux 976b63bb5b Improved: Create a deny list to reject webshell tokens (OFBIZ-12324)
Extracts the list of words used in SecuredUpload::isValidText in a
deniedWebShellTokens property in security.properties
2021-09-20 18:15:42 +02:00
Jacques Le Roux 6a7f3cd83e Fixed: Groovy Program sandbox bypass (OFBIZ-12305)
This much increases the current security by creating SecuredUpload::isValidText
and call it from ProgramExport.groovy

This said I agree with thiscodecc that a better solution would be to use a
Groovy sandbox, and not only in ProgramExport.groovy.

I had a quick glance at a such solution. Unfortunately as Cédric Champeau reports
at https://melix.github.io/blog/2015/03/sandboxing.html and unlike thiscodecc
suggest there are no "mature solutions on the market".

Nevertheless I'll have a deeper look at an OFBiz specific Groovy sandbox
solution.

Somehow related: I'll also soon extract the list of words used in
SecuredUpload::isValidText in a deniedWebShellWords property in security.properties

Thanks: thiscodecc for report
2021-09-17 18:50:07 +02:00
Nicolas Malin 8548f3a8a1 Fixed: Remove unnecessary variable instanciation
No Functional change
2021-09-17 15:14:13 +02:00
Nicolas Malin 32cca8a81b Fixed: Groovy DSL failed to use 'run service' from an event call (OFBIZ-12322)
When you call a groovy script from an event controller, some information are present note on the same place on the binding context.

Example if you call a groovy script as service you found the userLogin with parameters.userLogin or when you call it as event, the userLogin is on the binding context root.

The problem appear with the DSL method 'run service' who search the missing value need by a service (userLogin, locale and timezone) on the map parameters on the binding context, so failed to populate correctly the information for an event.

Call from event
    Map serviceResult = run service: 'createInvoice', with: [partyId: partyId, invoiceDate: nowTimestamp]

Failed due to security issue : missing userLogin on the service context.
2021-09-17 15:03:23 +02:00
Jacques Le Roux 71dbb3c824 Fixed: CVE-2021-37608 vulnerability bypass (OFBIZ-12307)
Fixes a number of issues I spotted while working on OFBIZ-12305 in relation with
OFBIZ-12055

The last change I made for OFBIZ-12305 was incomplete, the files could not be
checked by SecuredUpload because they did not exist! This concerns
ImageManagementServices, DataServices, FrameImage and ProductServices classes.
I used Files::createTempFile to fix that.

Also fixes a bug in SecuredUpload where I reversed the check on
fileToCheck.length in Windows case. I also added a comment, Windows 10 now
allows more length (need an OS parameter change though)

Finally, creates public SecuredUpload::isValidText to be used in OFBIZ-12305
2021-09-17 11:44:21 +02:00
Gil Portenseigne f790b7a6ef Implemented: Reintroduce groovy-test-suite test case (OFBIZ-12320)
This test case engine allow writing test in groovy script that do not
need compilation.
2021-09-15 15:35:20 +02:00
Nicolas Malin 5bd3ccfa40 Improved: Groovy DSL add success(Map) method (OFBIZ-12317)
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)
2021-09-15 14:26:05 +02:00
Nicolas Malin f82f7631b1 Implemented: Groovy DSL add label method (OFBIZ-12319)
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")
2021-09-15 12:07:15 +02:00
Nicolas Malin fcd2c0cec8 Improved: Estimated shipping cost resolution with breaks on price and quantity (OFBIZ-6988)
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
2021-09-15 11:45:04 +02:00
Nicolas Malin c97d9e7010 Improved: Set Helveticus Theme as default (OFBIZ-12318)
As shared on dev mailing list thread [1], we set Helveticus as default theme

[1] https://s.apache.org/2cm25
2021-09-14 22:38:43 +02:00
Jacques Le Roux 7a22a2bfc9 Fixed: Found a new XXE (XML External Entity Injection) vulnerability in EntityImport (OFBIZ-12304)
The XXE vulnerability can read arbitrary files on the server.

Thanks: thiscodecc for reporting this security issue (post-auth)
2021-09-13 09:28:06 +02:00
Jacques Le Roux 67665d1a9e Fixed: Found a new XXE (XML External Entity Injection) vulnerability in ArtifactInfo (OFBIZ-12306)
The XXE vulnerability can read arbitrary files on the server.

Thanks: thiscodecc for reporting this security issue (post-auth)
2021-09-13 08:10:14 +02:00
Nicolas Malin fa3e3573dc Improved: Improve run test from artefact info (OFBIZ-12312)
From https://localhost:8443/webtools/control/ViewComponents we have te possibility to run each test case or test suite.

We improve it with call with rest schema (like https://localhost:8443/webtools/control/RunTest/product/producttagtests) and display the result below

By this way, we also improve the groovy syntax to slim the code and extend xml form to CommonBasicGrid

Thanks to Gil Portenseigne for is support
2021-09-10 10:17:23 +02:00
Nicolas Malin 4bb54a1d1c Improved: Improve login page for Helveticus Theme (OFBIZ-12313)
Update the login page for Helveticus theme to keep the same spirit.

Thanks to Marine Desmarchelier for her work
2021-09-09 18:33:50 +02:00
Gil Portenseigne ab9ca12221 Execute a callback with parameters from the request (OFBIZ-12262)
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.
2021-09-07 14:56:20 +02:00
Jacques Le Roux ad1e06b9bd Improved: Update build.gradle to the latest dependencies (OFBIZ-12311)
The tests fails locally but it makes no sense, trying w/ BUilbot...
2021-09-06 10:06:41 +02:00
Nicolas Malin a83faaf15a Fixed: Rendering widget screen from ftl with the current context : java doc generation error (OFBIZ-12310)
Correction previous commit with invalid character on the javadoc.
2021-09-03 20:59:52 +02:00
Nicolas Malin 26a9dc7336 Implemented: Rendering widget screen from ftl with the current context (OFBIZ-12310)
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>
2021-09-03 18:29:48 +02:00
Jacques Le Roux 9ea7c6d524 Fixed: CVE-2021-37608 vulnerability bypass (OFBIZ-12307)
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)
2021-09-03 16:49:11 +02:00
Jacques Le Roux 3bfb03eaad Fixed: CVE-2021-37608 vulnerability bypass (OFBIZ-12307)
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
2021-09-03 13:47:15 +02:00
Jacques Le Roux 2525377569 Improved: switch link from Nabble (no longer reachable) to Markmail
Only trunk is concerned (OFBIZ-11998)
2021-08-11 17:08:38 +02:00
Nicolas Malin 3dd89a5219 Fixed: Fix checkstyle issue
detected by the buildbot and not by ./gradlew check
2021-08-11 14:59:47 +02:00
Eugen Stan 25c75e2839 Implemented: Clojure Service engine (OFBIZ-12302) (#317)
* Added Clojure service and service test and example service
* Added clojure engine
2021-08-10 16:09:39 +02:00
Jacques Le Roux 54acc03858 Fixed: SecuredUpload::isValidTextFile wrong check with uppercase (OFBIZ-12301)
In SecuredUpload::isValidTextFile a wrong check is done

Thanks: Zhujie from Ping'an Technology
2021-08-10 13:02:52 +02:00
Jacques Le Roux 4d3039c5de Improved: Fix issues reported by SonarQube analysis on Github (OFBIZ-12284)
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"
2021-08-06 17:07:58 +02:00
Jacques Le Roux 13d6bc2913 Improved: Fix issues reported by SonarQube analysis on Github (OFBIZ-12284)
Those should be OK, for instance I see no reasons to do something like that:
window.location.href = window.location.href;
2021-08-06 11:45:30 +02:00
Nicolas Malin 2aa68dc4de Fixed: UserLoginHistory failed the store operation with large password (OFBIZ-12287)
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.
2021-07-28 11:59:03 +02:00
Nicolas Malin de4213f017 Improved: Add description for all color orientation on Helveticus theme (OFBIZ-12288) 2021-07-28 11:25:15 +02:00
Jacques Le Roux 4f14cb96cf Fixed: Use platform specific failed on CompoundWidget (OFBIZ-12283)
Fixes a checkstyle issue
2021-07-23 09:30:25 +02:00
Jacques Le Roux 4e0ed1e6df Fixed: Static initialization vectors for encryption (OFBIZ-12281)
(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/vhlbj
https://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
2021-07-23 09:30:25 +02:00
Nicolas Malin c5a1a91fbd Fixed: Correct checkstyle typo 2021-07-23 09:10:09 +02:00
Nicolas Malin 8b5bd93d3a Fixed: Use platform specific failed on CompoundWidget (OFBIZ-12283)
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
2021-07-22 21:37:09 +02:00