When you use a callback, at this time we haven't to possibility to resolve the area target from the context like this
<wm:link target="WorkEffortAgreement/delete">
....
<wm:set-callback area-target="${useThisTarget}">
...
</wm-setcallback>
</wm:link>
Fixes random object created and used only once in classes:
SSLUtil
OrderTestServices
FinAccountHelper
GiftCertificateServices
Also related minor formatting in HashCrypt and ContextFilter
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
SpotBugs reports that
<<org.apache.ofbiz.base.util.collections.FlexibleServletAccessor.equals(Object)
does not check for parameter nullity
This implementation of equals(Object) does not respect the contract defined by
java.lang.Object.equals() because it does not check the nullity of the parameter
received as argument. All equals() methods must return false when they receive
a null value.>>
This fixes it, but despite SpotBugs continues to report the same error, excludes
it.
Also removes unused expandContext private var
We don't fear collisions for "url". It's only used in testXmlRpcRequest during
a sole test, write that in exclude.xml
Also removes an unused MODULE in XmlRpcTests class
CacheSoftReference<V> extends ReferenceCleaner.Soft<V> and implements
Serializable. But ReferenceCleaner does not implement Serializable.
I see no reasons for CacheSoftReference<V> to implement Serializable. So I
simply remove that.
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]
In ProductWorker::getProductFeaturesApplIncludeMarketingPackage fixes a possible
null dereferencement (tested too late)
In FileUtil::unZip uses a try-w-resource w/ ZipFile to close it. I crossed an
issue with automated OOTB formatting (clean-up on save in Eclipse). Fixed with
my external default editor (could not find where to change that in
OFBizJavaFormatter.xml
In ServiceArtifactInfo::calledServiceEcaSet fixes a possible null dereferencement
(tested too late), also minor formatting
In MacroScreenRenderer::renderScreenletSubWidget fixes a possible null
dereferencement (tested too late)
in FileUtil
Despite by best efforts in SecuredUpload::isValidFile and
PricatParseExcelHtmlThread::storePricatFile SpotBugs still reports possible null
dereferencements.
The error is NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE. It's false reports to me.
Hence excluding them in these places
In exclude.xml:
removes Confidence lines, no need to complicate things
Adds 2 DC_DOUBLECHECK false reports; synchronized is used there (maybe not the
best way but it's OK as is)
In ProductConfigWrapper::equals fixes use of == instead of equals (tested)
In UspsServices::uspsPriorityMailInternationalLabel fixes 2 possible null
dereferencements
In EntityExpr::checkRhsType fixes a possible null dereferencement
ComparableRange is a super class of DateRange that is Serializable. So
ComparableRange needs to be Serializable Too. Same with AbstractJob for PurgeJob
and GenericServiceJob
Renames ControlServlet class to OfbizControlServlet, because it shadowed the
simple name of it superclass
It can be exceptionally confusing, create lots of situations in which you have
to look at import statements to resolve references and creates many
opportunities to accidentally define methods that do not override methods
in their superclasses.
Same for XmlRpcClient.java
I blindly followed SpotBugs advice, using a "try with resource" because the
EntityListIterator was not closed. Forgetting that it's done by purpose.
Thanks: Thanks Pierre Smits for report
Fixes possible null dereferencings in PackingSession.java and FormRenderer.java
Also a try with resource for FormRenderer because the EntityListIterator was not
closed.
Also removes not used setShipmentBoxTypeId method and shipmentBoxTypeId var in
PackingSession.java
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