Commit Graph
1160 Commits
Author SHA1 Message Date
Jacques Le Roux 8c6d3272bd Improved: Fix some bugs Spotbugs reports (OFBIZ-12386)
Fixes random  object created and used only once in classes:
  SSLUtil
  OrderTestServices
  FinAccountHelper
  GiftCertificateServices

Also related minor formatting in HashCrypt and ContextFilter
2021-12-28 12:11:12 +01:00
Jacques Le Roux 06092ae0af Improved: Fix some bugs Spotbugs reports (OFBIZ-12386)
As advised by SpotBugs:

<<This code creates a java.util.Random object, uses it to generate one random
number, and then discards the Random object. This produces mediocre quality
random numbers and is inefficient. If possible, rewrite the code so that the
Random object is created once and saved, and each time a new random number is
required invoke a method on the existing Random object to obtain it.

If it is important that the generated Random numbers not be guessable, you must
not create a new Random for each random number; the values are too easily
guessable. You should strongly consider using a java.security.SecureRandom
instead (and avoid allocating a new SecureRandom for each random number needed).

Rank: Troubling (14), confidence: High
Pattern: DMI_RANDOM_USED_ONLY_ONCE
Type: DMI, Category: BAD_PRACTICE (Bad practice)>>

uses <<private static final SecureRandom SECURE_RANDOM = new SecureRandom();>>
in classes:
PaymentGatewayServices
ValueLinkApi
ContactMechServices
ProductStoreWorker
DesCrypt
HashCrypt
EntityCrypto
ContextFilter.java

Despite doing so SpotButs still reports the same error for those classes.
As it's obviously an error I prefer to not excludes those cases that will maybe
not be reported in a future version of SpotButs in Eclipse. For instance they
are not reported at all in previous version (4.5.1) but are in 4.5.2
2021-12-26 14:50:32 +01:00
Jacques Le Roux 4de3a37c54 Improved: Fix some bugs Spotbugs reports (OFBIZ-12386)
In ProposedOrder::calculateStartDate and TimeDuration::TimeDuration better use a
long directly (efficiency)

In ConfigXMLReader, removes unused getViewMap method

In ServiceArtifactInfo, some formatting and in writeServiceCallGraphEoModel
method add missing <<if (calledServiceSet != null) {>>

Adds and documents false positives in exclude.xml.
Remains 14 issues, I'll document them in the Jira and 'll later discuss them
on dev ML (committers attention needed). None of them are security issues :)
C:/projectsASF/Git/ofbiz-framework/plugins/rest-api/src/main/java/org/apache/ofbiz/ws/rs/listener/ApiContextListener.java:38 Ecriture d'un champ statique org.apache.ofbiz.ws.rs.listener.ApiContextListener.servletContext depuis la méthode d'une instance org.apache.ofbiz.ws.rs.listener.ApiContextListener.contextInitialized(ServletContextEvent) [Of Concern(15), High confidence]
C:/projectsASF/Git/ofbiz-framework/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/GenericMapValues.java:49 org.apache.ofbiz.base.util.collections.GenericMapValues.equals(Object) checks for operand being a java.util.List  [Troubling(14), High confidence]
C:/projectsASF/Git/ofbiz-framework/plugins/ldap/src/main/java/org/apache/ofbiz/ldap/cas/OFBizCasAuthenticationHandler.java:91 Déréférencement immédiat du résultat d'un readLine() dans org.apache.ofbiz.ldap.cas.OFBizCasAuthenticationHandler.login(HttpServletRequest, HttpServletResponse, Element) [Of Concern(15), Normal confidence]
C:/projectsASF/Git/ofbiz-framework/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/GenericMapValues.java:49 org.apache.ofbiz.base.util.collections.GenericMapValues.equals(Object) checks for operand being a java.util.Set  [Troubling(14), High confidence]
C:/projectsASF/Git/ofbiz-framework/framework/widget/src/test/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRendererTest.java:875 Un appel de méthode dans new org.apache.ofbiz.widget.renderer.macro.MacroFormRendererTest$36(MacroFormRendererTest, ModelForm) passe null à un paramètre déréférencé de façon inconditionnelle dans org.apache.ofbiz.webapp.control.RequestHandler.makeLink(HttpServletRequest, HttpServletResponse, String) [Scary(8), Normal confidence]
C:/projectsASF/Git/ofbiz-framework/framework/widget/src/test/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRendererTest.java:848 Un appel de méthode dans new org.apache.ofbiz.widget.renderer.macro.MacroFormRendererTest$35(MacroFormRendererTest, ModelForm) passe null à un paramètre déréférencé de façon inconditionnelle dans org.apache.ofbiz.webapp.control.RequestHandler.makeLink(HttpServletRequest, HttpServletResponse, String) [Scary(8), Normal confidence]
C:/projectsASF/Git/ofbiz-framework/plugins/ecommerce/src/main/java/org/apache/ofbiz/ecommerce/janrain/JanrainHelper.java:71 Ecriture d'un champ statique org.apache.ofbiz.ecommerce.janrain.JanrainHelper.apiKey depuis la méthode d'une instance new org.apache.ofbiz.ecommerce.janrain.JanrainHelper(String, String) [Of Concern(15), High confidence]
C:/projectsASF/Git/ofbiz-framework/plugins/pricat/src/main/java/org/apache/ofbiz/htmlreport/AbstractReportThread.java:160 Champ jamais écrit : org.apache.ofbiz.htmlreport.AbstractReportThread.report [Troubling(12), Normal confidence]
C:/projectsASF/Git/ofbiz-framework/plugins/ecommerce/src/main/java/org/apache/ofbiz/ecommerce/janrain/JanrainHelper.java:72 Ecriture d'un champ statique org.apache.ofbiz.ecommerce.janrain.JanrainHelper.baseUrl depuis la méthode d'une instance new org.apache.ofbiz.ecommerce.janrain.JanrainHelper(String, String) [Of Concern(15), High confidence]
C:/projectsASF/Git/ofbiz-framework/framework/base/src/main/java/org/apache/ofbiz/base/util/cache/CacheSoftReference.java:29 org.apache.ofbiz.base.util.cache.CacheSoftReference est Serializable mais sa super-classe ne possède pas de constructeur par défaut visible [Troubling(14), High confidence]
C:/projectsASF/Git/ofbiz-framework/plugins/ldap/src/main/java/org/apache/ofbiz/ldap/activedirectory/OFBizActiveDirectoryAuthenticationHandler.java:110 Alimentation à perte d'une variable locale dans la méthode org.apache.ofbiz.ldap.activedirectory.OFBizActiveDirectoryAuthenticationHandler.getLdapSearchResult(String, String, Element, boolean) [Of Concern(15), High confidence]
C:/projectsASF/Git/ofbiz-framework/plugins/ldap/src/main/java/org/apache/ofbiz/ldap/openldap/OFBizLdapAuthenticationHandler.java:95 Alimentation à perte d'une variable locale dans la méthode org.apache.ofbiz.ldap.openldap.OFBizLdapAuthenticationHandler.getLdapSearchResult(String, String, Element, boolean) [Of Concern(15), High confidence]
C:/projectsASF/Git/ofbiz-framework/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/FlexibleServletAccessor.java:193 org.apache.ofbiz.base.util.collections.FlexibleServletAccessor.equals(Object) checks for operand being a String  [Troubling(14), High confidence]
C:/projectsASF/Git/ofbiz-framework/framework/service/src/main/java/org/apache/ofbiz/service/test/XmlRpcTests.java:47 Ecriture d'un champ statique org.apache.ofbiz.service.test.XmlRpcTests.url depuis la méthode d'une instance new org.apache.ofbiz.service.test.XmlRpcTests(String) [Of Concern(15), High confidence]
2021-12-11 16:21:36 +01:00
Jacques Le Roux 7ac626b23d Improved: Fix some bugs Spotbugs reports (OFBIZ-12386)
Repeated conditional test
2021-11-19 17:46:25 +01:00
Jacques Le Roux 59dd946078 Fixed: Fix some bugs Spotbugs reports (OFBIZ-12386)
Fixes a Spotbugs worry and simplifies code
2021-11-18 17:09:08 +01:00
Jacques Le Roux f126bae89c Fixed: Fix some bugs Spotbugs reports (OFBIZ-12386)
Char arrays can't use toString()

Thanks: Spotbugs :)
2021-11-16 16:02:51 +01:00
wpaetzold 3d93c2709e Fixed: Builds fail due to unauthorized access to repo.spring.io/plugins-release (OFBIZ-12351) (#334)
Replaces repository syndication by rometools

Thanks Mart Naum for report
2021-11-09 14:34:44 +01: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 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
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 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
Eugen Stan 19b1b8407e Improved: Clean commented code from ofbiz webapp (#312)
(OFBIZ-8042)
2021-07-09 07:31:00 +02:00
Gil Portenseigne 69cea81b12 Fixed: SeoConfigUtil does not maintain char-replace order (OFBIZ-12259)
Thanks: Ingo Wolfmayr for your contribution
2021-06-22 16:51:17 +02:00
Jacques Le Roux 7c5b78919e Improved: fixes a checkstyle issue
In RequestHandler.java[1394] ':' is not preceded with whitespace.
2021-05-25 12:14:27 +02:00
Nicolas Malin b663660486 Implemented: on-event-update-area on form inherit information from parent form
(OFBIZ-11811) (OFBIZ-11808)

When you write a form, if you want the dynamic interaction and style, you need to implement everything on the form.
The developer must know the style used, different area and rules support by the technology besides the really information/action that the form will do.

   <form name="ListFacility" type="list" list-name="listIt" paginate-target="FindFacility"
         odd-row-style="alternate-row" header-row-style="header-row-2" default-table-style="basic-table hover-bar">
       <actions>...
       <field name="facilityId">....
       <on-event-update-area event-type="sort-column" area-id="search-results" area-target="FacilitySearchResults"/>
       <on-event-update-area event-type="paginate" area-id="search-results" area-target="FacilitySearchResults"/>
   </form>

We can put all information on the theme and all dynamic refresh (for area) are related to the parent form and parent screen. Finally we will obtain :

    <form name="ListFacility" extends="CommonDynamicList" extends-resource="component://common/widget/CommonForms.xml"
          paginate-target="FindFacility">
        <actions>...
        <field name="facilityId">....
    </form>

    <form name="CommonDynamicList" type="list"
         odd-row-style="alternate-row" header-row-style="header-row-2" default-table-style="basic-table hover-bar">
       <on-event-update-area event-type="sort-column"/>
       <on-event-update-area event-type="paginate"/>
   </form>

The target and area to update has been automatically resolved from the parent form and screen.

This commit improve the modelForm and the widget-form.xsd to do that.

Thanks to Gil Portenseigne his help
2021-05-21 17:58:27 +02:00
Jacques Le Roux 45f50c910d Improved: Handle remaining checkstyle errors (OFBIZ-12169)
This handles the "'(' should be on the previous line?" rule of MethodParamPad

Actually not completely, because there are still some cases that can't be
handled by changing code, notably when a casting is necessary. I believe there
is an error in checkstyle code. I'll discuss that in dev ML before sending
checkstyle team a report.
2021-05-04 10:34:52 +02:00
Jacques Le Roux 78dd625bbe Improved: Display last-visited-time popup after login (OFBIZ-12148)
Makes afterlogin.lastvisit.show to false by default and document that in the
security documentation, ie in
https://cwiki.apache.org/confluence/display/OFBIZ/How+to+secure+your+deployment

Else when working in dev mode you always have to remove or wait the message to
remove itself

Fixes wrong wiki links in sy-password-and-JWT.adoc
2021-02-22 11:15:28 +01:00
Michael Brohl 69c62f5f00 Merge changes for PR #267 due to conflicting changes in trunk (OFBIZ-12169) 2021-02-15 17:15:18 +01:00
Jacques Le Roux 0ebb819247 Fixed: webapp position does not really work (OFBIZ-12176)
Fixes the tests:
Checks that when the same position is provided by the `WebappInfo` instance
only one is retrieved

Checks that when the same title with no position is provided by the `WebappInfo`
instance 2 instances are retrieved. though they use the same title only position
allows "collision"
2021-02-15 10:21:59 +01:00
Jacques Le Roux 568ac8927b Fixed: webapp position does not really work (OFBIZ-12176)
The current implementation of webapp position uses String as key.
You can't really order on String, you need numbers.

This is needed by OFBIZ-12166
2021-02-14 19:27:33 +01:00
Jacques Le Roux d60bf1574b Fixed: Remove _PREVIOUS_REQUEST_ Session Attribute on non-authentication pages (OFBIZ-12047)
After some small study, it seem there is a problem because login request not
require authentication

I have tried to add a test to check if current request is login and only if it's
not to remove PREVIOUS_REQUEST Session Attribute, it seem better with this
modification.

Thanks: Olivier for the patch and Michael for suggesting to parameterize using
a property. I simply used EntityUtilProperties.getPropertyValue instead of
UtilProperties.getPropertyValue
2021-02-13 12:29:02 +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 74f224f88c Improved: Removed trailing spaces (OFBIZ-12169) 2021-02-09 14:16:08 +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
James Yong ad0211ab2d Improved: Display last-visited-time popup after login (OFBIZ-12148) (#266)
Improved: Display last-visited-time popup after login (OFBIZ-12148)

To allow users to know of any unauthorised access to their accounts.

Thanks: Michael for review
2021-02-08 00:04:29 +08:00
Michael Brohl 0dc7e562c9 Improved: Remove unused imports (OFBIZ-12169) 2021-02-05 18:14:51 +01:00
Ingo Könemann ffcd8f34fc Fixed: Remove _PREVIOUS_REQUEST_ Session Attribute on non-authentication
pages (OFBIZ-12047)

Added removal of the _PREVIOUS_REQUEST_ attribute when requesting
non-authenticated sites and moved targetRequestUri handling to a
accommodate this change
2021-02-03 11:47:15 +01:00
Jacques Le Roux 2718ee011c Improved: fixes a typo 2021-01-30 11:01:37 +01:00
Daniel Watford edd7960e4b Fixed: Use data url scheme for logo in CompanyHeader
(OFBIZ-7327)

Use a data URL rather than a regular URL for company logos when a
logo has been specified as a Party Content item. This works around the
problem of Apache FOP failing to retrieve content from HTTPS URLs.

Thanks: Deepak Dixit for the review and suggestions
2021-01-24 16:26:34 +00:00
James Yong b679d36b49 Improved: Updated tasks.checkstyleMain.maxErrors to 278 2021-01-21 21:21:54 +08:00
James Yong 1bfd3c5fb0 Improved: Allow Unsafe Event Message (OFBIZ-12147)
Allow application to define event messages that contain javascripts, via request attribute "_UNSAFE_EVENT_MESSAGE_"

Thanks Jacques for review
2021-01-21 20:46:06 +08:00
James Yong 9c7dc7b877 Improved: Rename MultiBlockHtmlTemplateUtil to ScriptLinkHelper (OFBIZ-12134)
Rename + Refactor
2021-01-13 09:26:42 +08:00
Jacques Le Roux 333b896eef Fixed: Error wIth Flat Grey theme related to rest component (OFBIZ-12093)
When you use the Flat Grey theme (useful for RTL languages) you see an error in
the main menu (component choise). It's related to the rest component not using a
controller.

Fixes is simple and has not side effect: instead of throwing an exception simply
log a warning and return an empty string
2020-12-18 10:38:26 +01:00
James Yong bc5b0d595c Improved: Load language js for date.js only when required (OFBIZ-12064)
Tested on
1) date time field at /ordermgr/control/orderentry and
2) date find field at /ordermgr/control/findreturn
2020-11-27 21:51:35 +08: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
James Yong aa8ae4b01e Improved: Move SeoConfigUtil.java from Product to Widget component (OFBIZ-12031)
Help to remove dependency of product component from widget component
An afterthought: webapp component seems better for SeoConfigUtil.java than widget component.

Thanks Jacques for review
2020-10-02 22:57:15 +08: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
Jacques Le Roux f1b88bd84b Improved: Checkstyle: Variable name must match pattern (OFBIZ-11926)
Better use Debug.logVerbose in place where I replaced missing expression with
another varation of Debug.log. We mainly don't need these information, it's only
for Checkstyle.

I thought did not replace cases where using another variation makes sense
2020-09-21 10:45:03 +02:00
Jacques Le Roux 346c63bfdf Improved: Checkstyle: Variable name must match pattern (OFBIZ-11926)
We have a lot of "do nothing" in Java code. In case of catch we should at least
have Debug.logError(e, MODULE); and maybe an explanation in the comment.
2020-09-15 15:24:45 +02:00
Suraj Khurana a5619831eb Improved: Added missing Javadocs for remaining methods in framework component, this is required for all classes which looks like designed for extension (can be subclassed).
(OFBIZ-11947)
Thanks Jacques for review.
2020-09-13 11:28:00 +05:30
Suraj Khurana 97b1688b0d Improved: Make data members of class as private and added accessor methods for the same, also corrected occurences of the same in framework component.
(OFBIZ-11963)
Also made some related checkstyle code enhancements. Thanks Jacques for review.
2020-09-12 12:05:16 +05:30
Suraj Khurana bc5e945ded Improved: Corrected line is longer than 150 characters checkstyle issues in framework component.
(OFBIZ-11921)
Also fixed some other extra space and naming related checkstyle issues observed.
Thanks Jacques for review.
2020-09-04 12:25:12 +05:30
James Yong 4a03567996 Improved: Allow logging to be disabled for getJs request (OFBIZ-11980)
Hide non-error logs related to getJs request as it doesn't provide meaningful data.

Thanks Jacques for initial review
2020-08-30 21:34:34 +08:00
Akash Jain 66a76ffd5a Improved: Fix Literals comparisons with variable to avoid NPE (OFBIZ-11929)
Thanks, Devanshu Vyas for your contribution.
2020-08-30 17:20:23 +05:30
Suraj Khurana f98f5ebb86 Improved: Added missing Javadocs for some methods, this is required for all classes which looks like designed for extension (can be subclassed).
(OFBIZ-11947)
Also fixed some other checkstyle issues that requires re-factoring.
Thanks Jacques for review.
2020-08-28 16:54:15 +05:30
Jacques Le Roux b42cd5f188 Improved: removes unused MODULE var in FreeMarkerViewHandler.java
Also removes empty line in build.gradle
2020-08-28 09:00:36 +02:00
Jacques Le Roux 8276a0802b Improved: Freemarker macro for JsLanguageFilesMapping (OFBIZ-11958)
Adds a missing ASL2 header
2020-08-27 19:34:35 +02:00