Commit Graph
1097 Commits
Author SHA1 Message Date
Jacques Le Roux 80e545c0f8 Improved: Use Error.ftl everywhere it's not yet used (OFBIZ-11890)
We no longer have "/error/error.jsp" file,
so always use "common/webcommon/error/Error.ftl" by default
2020-07-18 11:14:58 +02:00
Suraj Khurana 8b1e0dbd85 Improved: Corrected all checkstyle formatting issues: 'typecast' is not followed by whitespace in framework component.
(OFBIZ-11887)
2020-07-18 12:26:42 +05:30
Suraj Khurana 0c37e80036 Improved: Corrected all checkstyle formatting issues: Line has trailing spaces in framework component.
(OFBIZ-11880)
Thanks Jacques for review.
2020-07-13 14:18:24 +05:30
Suraj Khurana dd4da77d76 Improved: Corrected checkstyle formatting issues, 'is preceded/not preceded with whitespace' for framework component.
(OFBIZ-11874)
This fixes following checkstyle issues:
'{' is not preceded with whitespace.
'{' is not followed by whitespace.
'}' is not followed by whitespace.
'}' is not preceded with whitespace.
'typecast' is not followed by whitespace.
'try' is not followed by whitespace.
';' is preceded with whitespace.
2020-07-11 14:33:47 +05:30
Jacques Le Roux 3c9fe5f916 Improved: better message for host-headers-allowed
Adds an explanation about what to do when using own domain.

Some users don't look into the log so it's better to set also the exception
message in order for them to have it right at 1st glance.
2020-07-11 09:59:16 +02:00
Suraj Khurana 3bb22302c7 Improved: Corrected all checkstyle issues related to succeeding space for comma in framework directory.
(OFBIZ-11805)
Thanks Jacques and Ritesh Kumar for review.
2020-07-09 12:07:29 +05:30
Jacques Le Roux c5cb927124 Documented: POC for CSRF Token (CVE-2019-0235) (OFBIZ-11306)
Clarifies the behaviour of csrf-token

Thanks: James Yong
2020-07-08 10:22:02 +02:00
Suraj Khurana fc6b8a6ca3 Improved: Corrected remaining ', is not followed by whitespace' checkstyle errors in framework component.
(OFBIZ-11805)
2020-07-07 15:08:17 +05:30
Suraj Khurana 4f53828bea Improved: Corrected all 'if is not followed by whitespace' checkstyle errors. Also corrected few ', is not followed by whitespace' checkstyle errors in framework component.
(OFBIZ-11805)
Thanks Jacques Le Roux and Ritesh Kumar for review.
2020-07-06 15:29:58 +05:30
Pawan Verma f0af2894e5 Improved: Merge identical catch blocks in single catch block(OFBIZ-11827)
In Java SE 7 and later, a single catch block can handle more than one type of exception. This feature can reduce code duplication and lessen the temptation to catch an overly broad exception.

Thanks: Jacques for the review.
2020-06-27 11:23:12 +05:30
Pawan Verma 30732dd57b Improved: Replace Map.get() with Map.getOrDefault() method.(OFBIZ-11832)
Set checkstyleMain.maxErrors to 26682 (-2)
2020-06-22 21:26:18 +05:30
Jacques Le Roux 88bda0b4dc Improved: Install a Checkstyle pre-push (on every committer machine?) (OFBIZ-11304)
Updates tasks.checkstyleMain.maxErrors to 26842
Remove a trailing space in RequestHandler I used to test the pre-push hook.

In the previous commit (c4b5f5e) I have pushed a pre-push hook rather than a
pre-commit hook. I think it makes sense. I noticed that this does not clear the
existing pre-commit hook in .git\hooks. You have to clear it by hand.

But anyway I believe we should rather use a webhook as Suggested by Samuel and
proposed by Infra. This for at least 3 reasons:
    Handles PRs and not only local commits
    Minimise the CPU usage locally
    Simplify usage for custom projects

I think it's the best solution but I'll continue the discussion on dev ML about
2020-06-13 10:09:48 +02:00
Jacques Le Roux c4b5f5ec2c Test locally <<hooks = ['pre-push': 'checkstyleMain']>> 2020-06-13 09:41:59 +02:00
Suraj Khurana c00e61aa18 Improved: Enforce noninstantiability to LoginWorker class. (#175)
(OFBIZ-11747)

Made class as final, added private constructor and made static variables as private.
2020-06-07 10:55:06 +05:30
Suraj Khurana 924df4b217 Improved: Enforce noninstantiability to ConfigXMLReader Class (#178)
(OFBIZ-11746)

Made class as final, added private constructor and corrected private data members as per naming convention.
2020-06-06 10:01:55 +05:30
James Yong d1a22a6ba8 Improved: Headerize external script in multi-block html template (OFBIZ-11741)
Cleanup script cache when session ended
2020-05-30 14:32:38 +08:00
James Yong c0e527efb2 Improved: Headerize external script in multi-block html template (OFBIZ-11741)
Allow external scripts within the multi-block html template, to be rendered
within the html head tag, when a new attribute data-import is set to “head”

Thanks: Jacques for review
2020-05-30 12:00:21 +08:00
Suraj Khurana abc7836dde Improved: Made MODULE as private data member of class instead of public in all framework components.
(OFBIZ-11739)
This will reduce checkstlye issues. Thanks Jacques for review.
2020-05-29 13:20:46 +05:30
Jacques Le Roux 32a71c9af4 Improved: Clean how HTTP vs HTTPS is handled
(OFBIZ-11717)

No functional changes, just better comments
2020-05-20 13:01:36 +02:00
James Yong e3e12ee487 Improved: No need to specify externalKeyParam in ofbizUrl calls (OFBIZ-11711)
Let ofbizUrl macro generates externalLoginKey when needed.

Thanks: Jacques for review
2020-05-17 20:37:48 +08:00
James Yong 60c78d24be Improved: <script-template> widget tag (OFBIZ-11686)
Removed script-template tag.
Use multi-block=true on html-template tag instead.
2020-05-15 11:16:15 +08:00
holivier 4f5e6f9f06 Improved: <script-template> widget tag
(OFBIZ-11686)

Correction in javadoc, <script is not authorize in javadoc because it
can introduce some javascript in javadoc, and so generate an error in
javadoc build.
Replace <script-template/> by "script-template"
2020-05-14 09:38:23 +02:00
James Yong 803f7fa060 Improved: <script-template> widget tag (OFBIZ-11686)
The new tag allows us to render a freemarker template containing javascript,
as external script in html instead of inline script.
This helps to reduce CSP errors.
2020-05-13 20:19:05 +08:00
Jacques Le Roux fde21d0b10 reverted: CLONE - Use only HTTPS in OFBiz
(OFBIZ-11643)

Reverted, this needs more work
2020-05-04 13:21:03 +02:00
Jacques Le Roux a8c5c84cec Fixed: CLONE - Use only HTTPS in OFBiz
(OFBIZ-11643)

When doing OFBIZ-6849 I forgot to take care of the https attribute of the
security element used in controllers.

It's not used anymore since we used HTTPS everywhere but in request listed in
http.request-map.list property of url.properties. It's even enforced by HSTS for
requests that are not listed in this property.

This removes the https attribute and removes its usage in in controllers.
2020-05-04 13:10:17 +02:00
Jacques Le Roux 3f60efb343 Improved: Improve ObjectInputStream class
(OFBIZ-10837)

While working on OFBIZ-11633 I crossed an issue in R18 (not in trunk) where
objects from org.apache.commons.fileupload (namely DiskFileItem and
FileItemHeadersImpl) are not serializable.

While at it I decided to handle at the SafeObjectInputStream level
the "fileItems" case I already crossed with, OFBIZ-11534, in RequestHandler

It has an inconvenient in R18 (not in trunk) where ObjectInputStream can't
handle a null class (of course) and so return a benign exception in log (only).

I believe it's better to handle these specific cases at the lower possible
level in all supported branches.
2020-05-02 12:34:56 +02:00
Jacques Le Roux 61e5435b30 Fixed: "entity/list" request is not handled well
(OFBIZ-11593)

The "entity/list" request has been put in with OFBIZ-11007. It's used to call
the entitymaint view and so is a demo/didactic duplicate of entitymaint request.
It's only used in FindGeneric screen (look for WebtoolsBackToEntityList label).
It's problematic because since the CSRF token defense was put in you can no
longer filter the entities from the entities list screen, even when the default
NoCsrfDefenseStrategy is used. It works if you use the entitymaint request
instead.

2020-01-19 I proposed in OFBIZ-11306 a solution for such cases.
It was not used because 2020-02-14 I thought it was no longer needed.
It was necessary for this case and implemented with commit e487122.

But as, Rohit Koushal reported, it breaks some functionalities like adding
address/update address during Quick Finalize Order. The issue can also be
reproduced in ecommerce when trying the same while checking out, or quick
checking out, an order.

More generally the error is of this kind:
|27.0.0.1-8009-exec-3 |ControlServlet                |E| Error in request handler:
java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
  at java.util.LinkedList.checkElementIndex(LinkedList.java:555) ~[?:1.8.0_252]
  at java.util.LinkedList.get(LinkedList.java:476) ~[?:1.8.0_252]
  at org.apache.ofbiz.webapp.control.RequestHandler.getRequestUri(RequestHandler.java:837) ~[main/:?]

and happens with URLs like
updateCheckoutOptions/editcontactmech?DONE_PAGE=checkoutoptions&contactMechId=9015
or
updateCheckoutOptions/editcontactmech?preContactMechTypeId=POSTAL_ADDRESS&
contactMechPurposeTypeId=SHIPPING_LOCATION&DONE_PAGE=checkoutoptions

So I decided to revert the concerned part of commit e487122 and to rather use
entitymaint instead of "entity/list" request.
2020-04-29 08:29:33 +02:00
ravilodhiandRavi Lodhi ae70318fc8 Improved: Added support to consider non-default transaction timeout for Groovy and Simple event handlers.(OFBIZ-11607) (#77)
* Improved: Added support to consider non-default transaction timeout for Groovy and Simple event handlers.(OFBIZ-11607)

* Revert "Improved: Added support to consider non-default transaction timeout for Groovy and Simple event handlers.(OFBIZ-11607)"

This reverts commit 934eaa4539.

* Improved: Added support to consider non-default transaction timeout for Groovy and Simple event handlers.(OFBIZ-11607)

Co-authored-by: Ravi Lodhi <lodhiravi1@gmail.com>
2020-04-26 09:17:30 +02:00
Jacques Le Roux 6d3d8f73c2 Fixed: Error in uploading very large files, ie >2MB
(OFBIZ-11534)

This was not supposed to be committed, actually (wrong) part of OFBIZ-11597
2020-04-16 16:02:20 +02:00
Jacques Le Roux 4725ae68d8 Fixed: Error in uploading very large files, ie >2MB
(OFBIZ-11534)

There is an issue in uploading large files, I am able to upload files up to 2 GB
successfully but getting an error when trying to upload a file larger than 2GB.

Example -
1. Go to party profile -
https://demo-trunk.ofbiz.apache.org/partymgr/control/viewprofile?partyId=admin
2. Try to create a party content with a file larger than 2 GB
3. Error on console

jleroux:
For a 2GB+ file you need to set Xmx to more than the double of the file size,
eg: gradlew ofbiz -PjvmArgs="-Xms1024M -Xmx5048M"

You then get another small issue (only in log) when redirecting to send the
partyId parameter.

This is because, DiskFileItem is a temporary Object with a null value contained
in "fileItems" attribute. It can't be detected by UtilMisc::makeMapSerializable
and that makes "fileItems" not serializable. So it must be removed from
reqAttrMap.

Thanks: Chandan Khandelwal for report, Michael for suggesting a very large file
to upload
2020-04-16 15:46:09 +02:00
Jacques Le Roux 01e98b5b5f Improved: Add security.internal.sso.enabled and security.token.key
SystemProperties

(OFBIZ-11594)

Adds more latitude to set same site by using
EntityUtilProperties::getPropertyValueFromDelegatorName for retrieving the value
possibly from the DB as a SystemProperty.

OF course this would not work with tenants, but I doubt the "internal" SSO
feature will ever be use in a tenants context
2020-04-13 17:25:25 +02:00
Jacques Le Roux 03780e4665 Fixed: "entity/list" request is not handled well
(OFBIZ-11593)

Fixes the resolveURIBasicOverrideView test
2020-04-13 11:38:04 +02:00
Jacques Le Roux e487122624 Fixed: "entity/list" request is not handled well
(OFBIZ-11593)

The "entity/list" request has been put in with OFBIZ-11007. It's used to call
the entitymaint view and so is a demo/didactic duplicate of entitymaint request.
It's only used in FindGeneric screen (look for WebtoolsBackToEntityList label).
It's problematic because since the CSRF token defense was put in you can no
longer filter the entities from the entities list screen, even when the default
NoCsrfDefenseStrategy is used. It works if you use the entitymaint request
instead.

Anyway, 2020-01-19 I proposed in OFBIZ-11306 a solution for such cases.
It was not used because 2020-02-14 I thought it was no longer needed,
but it's necessary for this case, and maybe others not already detected.

Here it's implementation (only trunk)
2020-04-12 13:17:37 +02:00
Jacques Le Roux b95fa36bf4 Improved: follow checkstyle conventions in files committed for CSRF token defense
Mostly manually-automated, so some changes are not perfect. I have manually
changed back excessive ones

Comments out ArrayTypeStyle checkstyle
Updates checkstyleMain.maxErrors
2020-04-06 12:05:16 +02:00
Jacques Le Roux ddb8f4273a Improved: replaces module by MODULE everywhere 2020-04-05 19:46:34 +02:00
Jacques Le Roux 05354b73b7 Improved: prevent [rawtypes] found raw type: List at RequestHandler.java:89 2020-04-04 19:40:26 +02:00
Jacques Le Roux e0f0d5271a Fixed: Prevent Host Header Injection (CVE-2019-12425)
(OFBIZ-11583)
2020-04-04 19:32:02 +02:00
Jacques Le Roux e666c65b7c Improved: Improve Web Content Caching
(OFBIZ-11477)

According to OWASP OFBiz Web Content Caching is weak:

Independently of the cache policy defined by the web application, if caching web
application contents is allowed, the session IDs must never be cached, so it is
highly recommended to use the Cache-Control: no-cache="Set-Cookie, Set-Cookie2"
directive, to allow web clients to cache everything except the session ID

I though noticed that Set-Cookie2 is deprecated for a long time now. And we new
browsers policies it to often updated. So no need to use Set-Cookie2.
2020-04-04 15:49:43 +02:00
Jacques Le Roux 866c742e8f Fixed: Ensure that the SameSite attribute is set to 'strict' for all cookies.
(OFBIZ-11470)

It's better to allow users to change from strict to lax, at least for all
cookies. Some could want to change it by cookie type. I let the exercise for
them :)
See:https://blog.mozilla.org/security/2018/04/24/same-site-cookies-in-firefox-60
2020-04-04 15:49:40 +02:00
Jacques Le Roux 3a5a657604 Fixed: Ensure that the SameSite attribute is set to 'strict' for all cookies.
(OFBIZ-11470)

Forgot to add UtilHttp::SameSiteFilter
2020-03-21 11:31:56 +01:00
Dennis Balkir 54a429e8cc Implemented: _WARNING_MESSAGE_
(OFBIZ-10587)

Added warning message as a message type, by adding it in the
messages.ftl and the request-handler

Thanks to Niklas Fallik for reporting
2020-03-21 11:31:54 +01:00
Jacques Le Roux 0da38998a9 Improved: Remove unused ‘UtilHttp#checkURLforSpiders’
(OFBIZ-11138)

The "link.remove_lsessionid.user_agent_list" properties was forgotten
2020-03-21 11:31:47 +01:00
Jacques Le Roux c34491892a Improved:
Implemented:
Documented:
Completed:
Reverted:
Fixed:
Improved: no functional change
(OFBIZ-)
Explanation
Thanks:
2020-02-27 14:36:26 +01:00
Jacques Le Roux 969f48b7c9 Fixed: Add 'controlPath' attribute to 'ofbizUrl' freemarker macro
(OFBIZ-11317)

In some place, like at least themes/tomahawk/template/AppBarClose.ftl the CSRF
token is not generated. Because in those places OfbizUrlTransform is used.

An immediate solution is to add the CSRF token generation in OfbizUrlTransform
class.

A definitive solution is to complete OFBIZ-11229
"Merge UrlRegexpTransform and OfbizUrlTransform classes"
2020-02-15 13:24:09 +01:00
Nicolas Malin 11cf350302 Improved: Change 'restMethod' by '_method' in request parameters
(OFBIZ-11332)

When we analyse a request method, we currently check the parameter "restMethod".
Mathieu Lirzin propose [1] to use "_method" instead to use a parameter name more generic

I create a new function UtilHttp.getRequestMethod() to centralize the request method resolution.

[1] https://issues.apache.org/jira/browse/OFBIZ-11007?focusedCommentId=17012712&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-17012712
2020-01-29 10:50:29 +01:00
James Yong 05ffbd2817 Improved: Add 'controlPath' attribute to 'ofbizUrl' freemarker macro
(OFBIZ-11317)

Adding the controlPath attribute to allow the controls by ofbizUrl to support uri to other OFBiz web application.

Thanks: Jacques for the review
2020-01-12 22:25:50 +08:00
Mathieu Lirzin 20e0bbe55c Improved: Use ‘forEach’ in ‘RequestHandler’ for conciseness
No functional changes.
2020-01-03 14:32:31 +01:00
Mathieu Lirzin 7508917a0a Improved: Remove ‘RequestHandler#ControllerConfig’ wrapper
(OFBIZ-11313)

‘RequestHandler#ControllerConfig’ was a wrapper around
‘ConfigXMLReader#ControllerConfig’ used as a convenience to gather
error handling when accessing configuration properties. Since the
later is now only throwing exceptions when instantiating the object,
‘RequestHandler#ControllerConfig’ is not useful anymore.
2019-12-30 09:54:24 +01:00
Mathieu Lirzin 6c745f6ea5 Improved: Retrieve the included controller files eagerly
(OFBIZ-11313)

The included controller files resolution was previously delayed when
accessing the configuration properties. The issue is that it imposes
callers to handle exceptions when accessing those
properties. Additionally this has the drawback of detecting inclusion
issues late.

We are now retrieving the included files when instantiating the
controller configuration object. This provides more guarantee on the
integrity of instantiated controllers and relax the error handling
requirements on configuration properties callers.
2019-12-30 09:47:55 +01:00
Mathieu Lirzin aae1c8a8f5 Reverted: "Improved: Use ‘depends-on’ attribute instead of “component-load.xml”"
(OFBIZ-11296)

This reverts commit eeabe69813.
2019-12-18 12:09:20 +01:00