Commit Graph
2440 Commits
Author SHA1 Message Date
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
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
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
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
Jacques Le Roux 9963c46c82 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: we prepend the IV in order to decrypt the plaintexts. I'll do
something similar in ValueLinkApi class ASAP

Thanks: Artem Smotrakov
2021-07-21 10:55:49 +02:00
Jacques Le Roux 2c421cedfb Fixed: Add http to https redirect rule for ofbiz.apache.org (OFBIZ-10590)
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
2021-07-20 07:47:32 +02:00
Jacques Le Roux e4919d16ca Fixed: IndexOutOfBoundsException on Entity Import (OFBIZ-12273)
Removes the localhost (and 127.0.0.1) OOTB.
Allows to use it through a "multi-property" (list) in security.properties.
2021-07-06 14:30:39 +02:00
Jacques Le Roux b00aed6d20 Fixed: IndexOutOfBoundsException on Entity Import (OFBIZ-12273)
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
2021-07-05 19:36:42 +02:00
Jacques Le Roux 0effce0c7b Fixed: IndexOutOfBoundsException on Entity Import (OFBIZ-12273)
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
2021-07-03 19:24:08 +02:00
Jacques Le Roux cc4de50f6f Improved: fixes an indentation issue 2021-06-22 15:56:04 +02:00
Wiebke Pätzold d0924362af Fixed: Adding tel protocol in CustomPermissivePolicy is not working
(OFBIZ-12258)

With these changes, the default sanitizers rules are only loaded if
there is no CustomPermissivePolicy
2021-06-21 07:44:08 +02:00
Jacques Le Roux b9f785d2fa Fixed: Unexpected decoding of url encoded textarea data after submission (OFBIZ-12249)
Oops, forgot to commit this checkstyle issue fix
2021-06-10 09:21:05 +02:00
Jacques Le Roux 4bab66e501 Fixed: Unexpected decoding of url encoded textarea data after submission (OFBIZ-12249)
When trying to add a note to WorkEffort entity, I found that URL encoded
characters are unescaped, which is not expected.

e.g.:
1. Go to page: https://demo-trunk.ofbiz.apache.org/workeffort/control/EditWorkEffortNotes?workEffortId=TASK01
2. Add a note with content: https://example.com/a%20link
3. After submission, it will turned to be: https://example.com/a link

Thanks: Xin Wang for report and exchanges until solution I provided
2021-06-09 10:57:51 +02:00
Jacques Le Roux fb0701b7bd Fixed: Plugin not showing in menu due to permission (OFBIZ-12233)
When creating a plugin via gradle :
./gradlew createPlugin -PpluginId=plugin-test -PpluginResourceName=PluginTest
-PwebappName=plugin-test -PbasePermission=PLUGIN_TEST

and loading all the required data and permissions, the plugin doesn't appear
in the menu.

It comes from the ComponentConfig.java file, L1229, when the permissions gets
trimmed and modified. I tried removing it locally and it fixed the problem.

Thanks: Gaetan Chaboussie
2021-05-17 11:59:36 +02:00
Jacques Le Roux 7fd9d05f7e Improved: Improve ObjectInputStream denyList (OFBIZ-12221)
Forgot to change ListOfSafeObjectsForInputStream to allowList in UtilObjectTests
2021-04-07 10:12:33 +02:00
Jacques Le Roux 3f975780cf Improved: Improve ObjectInputStream denyList (OFBIZ-12221)
In SafeObjectInputStream.properties
  Renames listOfSafeObjectsForInputStream to allowList and fixes it
  Introduces a denyList

Adapts SafeObjectInputStream class to new denyList
2021-04-07 08:51:36 +02:00
Jacques Le Roux fcc0078b60 Improved: Improve ObjectInputStream denyList (OFBIZ-12221)
Prevents generics markup in string type names.
2021-04-05 17:03:12 +02:00
Jacques Le Roux 1bc8a20634 Improved: Improve UtilObject class (OFBIZ-12216)
Removes "DiskFileItem, FileItemHeadersImpl are not serializable" case. It does
not appear in trunk.

Handling with exception Rather than returning null cleans UtilObject class.

Restrict unauthorized deserialisations to java.rmi instead of java.rmi.server
2021-03-30 12:29:54 +02:00
Jacques Le Roux 4944ef8017 Fixed: Error while uploading file in Ecommerce Profile's File Manager (OFBIZ-10746)
On uploading File in Ecommerce Profile's File Manager,

"The following required parameter is missing:
[IN] [uploadPartyContentFile.partyContentTypeId]" error is displaying.

Steps to regenerate the issue:
    Open Ecommerce on Ofbiz.
    Login with any user.
    Go to Profile.
    Navigate down to File Manager.
    Select Purpose.
    Seletct Mime Type
    Click upload.

Thanks: Aishwary Shrivastava for report, Priya Sharma fir the fix
2021-02-21 19:20:00 +01:00
Jacques Le Roux b1c611bebd Fixed: Bypass Java GString to String conversion in ObjectType::simpleTypeOrObjectConvert (OFBIZ-12182)
Follows https://markmail.org/message/azn7e4g2rbpo7tvj
2021-02-19 09:28:53 +01:00
Jacques Le Roux 4be71d74c2 Improved: Update Freemarker to 2.3.31 (OFBIZ-12180)
Adds the Jira ref
2021-02-18 13:43:09 +01:00
Jacques Le Roux 44922f0fba Improved: Update Freemarker to 2.3.31 2021-02-18 13:35:53 +01:00
Michael Brohl 29bf0a040a Merge branch 'trunk' into OFBIZ-12169_Handle_remaining_checkstyle_errors 2021-02-13 11:26:01 +01:00
Wiebke Pätzold 82a15c70e3 Improved: Removed inner assignments (OFBIZ-12169) 2021-02-10 11:38:04 +01:00
Jacques Le Roux e7b3169d03 Improved: Rename some connoted words like blacklist and whitelist (OFBIZ-12168)
Renames respectively blacklist and whitelist to denylist and allowlist in
several places.

There are still a lot of master word which can be replaced by main, but not in
contexts where slave is also used. I'll discuss that on dev ML again...

Provides the migrateOldOrderBlacklistAndOldOrderBlacklistType service to migrate
records from OrderBlacklist and OrderBlacklistType entities to new OrderDenylist
and OrderDenylistType entities
2021-02-09 09:55:39 +01:00
Wiebke Pätzold 95d37d2189 Removes and adds whitespaces as suggested by checkstyle (OFBIZ-12169) 2021-02-09 08:46:20 +01:00
Michael Brohl bae3628501 Declare classes final as suggested by checkstyle (OFBIZ-12169)
Helper and Worker classes which are likely to be extended by custom
projects where left as is.
2021-02-08 17:09:56 +01:00
Wiebke Pätzold 2fe5e15a83 Improved: Adds newline at the end of file (OFBIZ-12169) 2021-02-08 16:31:13 +01:00
Jacques Le Roux af9ed4e68e Fixed: Adds a blacklist (to be renamed soon to denylist) in Java serialisation (OFBIZ-12167)
Adds an example based on RMI which is known to be a problem
2021-02-05 11:02:28 +01:00
Benjamin Jugl 5a0b0a0c0d Fixed: Checkstyle Issues in WebToolsDbEvents and UtilXml (OFBIZ-6510) 2021-02-04 12:29:28 +01:00
Benjamin Jugl 8fac07ad0a Improved: Replaces ModelInduceFromDb with widgets (OFBIZ-6510) 2021-02-03 12:39:15 +01:00
James Yong b679d36b49 Improved: Updated tasks.checkstyleMain.maxErrors to 278 2021-01-21 21:21:54 +08:00
Nicolas Malin 7165768251 Implemented: Add a framework method to get main webapp menu with the webapp name
(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
2021-01-15 08:56:23 +01:00
Daniel Watford c4d8f904b7 Improved: Don't log warning when ObjectType converts from String to
String

(OFBIZ-10710)

Thanks: Benjamin Jugl for report and patch.
2021-01-14 17:58:05 +00:00
Daniel Watford d40081dc86 Improved: Minor changes to reduce checkstyle warnings count 2021-01-13 14:28:19 +00:00
Nicolas Malin e0a840a0c4 Implemented: Access to the current screen from any widget element
(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.
2021-01-12 17:48:00 +01:00
Daniel Watford c9ee842163 Fixed: Issue starting ofbiz from tar distribution (OFBIZ-12118)
Avoid using caches when opening a URL connection to read an XML resource
in a JAR file.

If caches were used when running from the ofbiz.jar file then attempts
to read resources from the jar would fail due to the cached file's
InputStream already being in a closed state.

Thanks: Eugen Stan for the bug report and fix.
2021-01-11 17:35:07 +00:00
Jacques Le Roux c52f29e0ae Fixed: Post-auth XSS vulnerability at catalog/control/EditProductPromo (OFBIZ-12096)
We missed to unescape EcmaScript encoded strings in
UtilCoded::checkStringForHtmlSafe, ie in all form fields using allow-html="safe"

Thanks: 牛治 <niu.zhi@zte.com.cn> for report
2020-12-19 20:54:08 +01:00
Jacques Le Roux c7fef0c409 Fixed: Post-auth XSS vulnerability at catalog/control/EditProductPromo (OFBIZ-12096)
We missed to unescape EcmaScript encoded strings in
UtilCoded::checkStringForHtmlSafe, ie in all form fields using allow-html="safe"

Thanks: 牛治 <niu.zhi@zte.com.cn> for report
2020-12-19 18:24:29 +01:00
Jacques Le Roux e73616caf1 Fixed: Secure the uploads (OFBIZ-12080)
2020/08/10 the OFBiz security team received a security report by Harshit Shukla
<harshit.shukz@gmail.com>, roughly it was (quoting part of it to simplify):

<<I have identified a Remote Code Execution (RCE) Vulnerability. The reason
behind this RCE is lack of file extension check at
catalog/control/UploadCategoryImage?productCategoryId=CATALOG1_BEST_SELL&pload_file_type=category>>

Using this post-auth RCE in OFBiz demos, Harshit was able to get some AWS
credentials by uploading a webshell (based on [0]).
By security, it was then decided by the Infra and OFBiz security teams to shut
down the demos.

After discussing the elements reported with Mark J Cox (VP of ASF security team)
we in common decided that no CVE was necessary.
2020-12-01 10:16:04 +01:00
Jacques Le Roux e136cb1d98 Fixed: Prevent Zip Slip vulnerability (OFBIZ-12056)
While working with FileUtil::unzipFileToFolder I noticed that it's vulnerable to
Zip slip vulnerability: https://snyk.io/research/zip-slip-vulnerability.

Fortunately OOTB code does not use FileUtil::unzipFileToFolder so I did not
create a CVE, nor reported to
https://github.com/snyk/zip-slip-vulnerability#user-content-projects-affected-and-fixed.
If you think we should please shime in...
2020-11-14 11:39:10 +01:00
Jacques Le Roux 2fe76bead8 Improved: Misc trivial changes done while working on others issues 2020-11-11 20:43:59 +01:00
Jacques Le Roux 9a6ed0279b Fixed: NotSerializableException using uploadPartyContentFile service (OFBIZ-12050)
Removes a warning:

UtilMisc.java:202: warning: [rawtypes] found raw type: Iterator
Iterator itr = arrayList.iterator();
^
missing type arguments for generic class Iterator<E>
where E is a type-variable:
E extends Object declared in interface Iterator
2020-11-06 11:27:16 +01:00
Jacques Le Roux ae5d3b4045 Fixed: NotSerializableException using uploadPartyContentFile service (OFBIZ-12050)
This error appears after trying to upload a file to party content:

2020-11-06 07:48:22,488 |jsse-nio-8443-exec-7 |RequestHandler                |I|
Sending redirect to:
[https://localhost:8443/partymgr/control/viewprofile?partyId=admin].
2020-11-06 07:48:29,288 |jsse-nio-8443-exec-7 |UtilObject                    |E|
null
java.io.NotSerializableException: org.apache.commons.fileupload.disk.DiskFileItem
2020-11-06 10:59:58 +01:00
Jacques Le Roux f2632b90c5 Fixed: Sorting of lists generates undesired results (OFBIZ-8302)
Fixes an issue reported by UtilHttpTest::emptyParameterMap

More to come for MacroFormRendererTest::renderSortFieldUsesQueryString

Both put in with "MacroFormRenderer refactoring" (OFBIZ-11456)
2020-11-01 10:47:31 +01:00
Jacques Le Roux cd242ea34c Fixed: Sorting of lists generates undesired results (OFBIZ-8302)
For this issue (OFBIZ-8302) I reverted the point 1 of
http://svn.apache.org/viewvc?view=revision&revision=1759555

As reported by Alvaro Munoz from GH security team it's not sufficient:
<<the second part of the fix was not effective, since the attacker can close the
raw string context with a double quote and write a new attribute or even close
the macro tag and write arbitrary FreeMarker code.>>

So this removes the 2nd part and add better solution to fix the OFBIZ-8302 issue
The solution is to encode only the QueryString and to handle it correctly in
UtilHttp::getParameterMap. I must say it was not a sinecure!
2020-10-31 20:21:32 +01:00
Suraj Khurana acdddaf85c Improved: Corrected some spacing issues in code, where there are extra white spaces, this will fix some checkstyle issues in framework component.
(OFBIZ-12022)
2020-09-26 14:01:43 +05:30
James Yong d7a5d601bd Fixed: Open FTL File from browser (OFBIZ-12018)
StringIndexOutOfBoundsException error in Windows

Thanks Jacques for reporting.
2020-09-25 13:00:34 +08:00
James Yong ad2e8de7c2 Improved: Open FTL File from browser (OFBIZ-12018)
Add function to open the corresponding FTL file with IDE
when the named border is clicked from browser.

Thanks Rishi and Jacques for review
2020-09-24 21:36:24 +08:00