Commit Graph
10090 Commits
Author SHA1 Message Date
Jacques Le Roux f4acda5ade Fixed: The createTaskContent request does not work
(OFBIZ-11246)

It seems that same request can not be parsed multiple times if it has multi part
object in it as the parse method remove it after that.

Found one stackoverflow link around the same:

https://stackoverflow.com/questions/13881272/
servletfileuploadparserequestrequest-returns-an-empty-list

I believe that all places/uploads using this workflow should resulting the same
issue.

One possible solution I could think of without going with new approach is to set
list of file Items into the request attribute and use it if parse method remove
it and unable to retrieve on 2nd call.

Thanks: Ankush Upadhyay for the analysis and initial patch. I only slightly
modified it.
2020-03-27 10:55:59 +01:00
Jacques Le Roux 2bb1de22cc 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-03-27 10:05:37 +01:00
Pawan Verma 91673f1b41 Fixed: Specified key was too long; max key length is 767 bytes for ProductPromoCodeEmail entity.(OFBIZ-5426) (#44)
* Fixed: Specified key was too long; max key length is 767 bytes for ProductPromoCodeEmail entity.
(OFBIZ-5426)

The problem is in the entity model. An email address should not be used in the primary key - mainly because an email address is case-insensitive. A better design would be to use the email address contact mechanism ID in the primary key.

Done Following:
1. Changed Entity Name from ProductPromoCodeEmail to ProductPromoCodeContMech
2. Related Changes for the entity name change
3. Migration service to migrate old data

Thanks, Leon for the report and Adrian Crum, Jacques Le Roux, Ingo Wolfmayr, Deepak Dixit, Pierre Smits and Gil Portenseigne for the discussion and review.

* Improved: Added new line in service definition file and lincence in MigrationServices file.
(OFBIZ-5426)

Thanks, Jacopo for the review.
2020-03-23 17:08:58 +05:30
Jacques Le Roux 1348f9d3be Improved: Added unit testing, using JMockit, to ensure that form macros are
rendered using ids from ModelFormField#getCurrentContainerId.

(OFBIZ-4035)

Fixes check style errors
2020-03-21 23:09:05 +01:00
Jacques Le Roux 28e961c062 Improved: Added unit testing, using JMockit, to ensure that form macros are
rendered using ids from ModelFormField#getCurrentContainerId.

(OFBIZ-4035)

Fixes an issue due to Eclipse automated import organisation.

There are still check style errors
2020-03-21 23:01:36 +01:00
Jacques Le Roux 322df2750c Improved: Added unit testing, using JMockit, to ensure that form macros are
rendered using ids from ModelFormField#getCurrentContainerId.

(OFBIZ-4035)

Fixes a check issue (line too long)

Notice: on Windows I get 20 errors when compiling:
> Task :compileTestJava FAILED
C:\projectsASF\Git\ofbiz-framework\framework\widget\src\test\java\org\apache\
ofbiz\widget\renderer\macro\MacroFormRendererTest.java:134:
error: annotation type not applicable to this kind of declaration
        @Mock
        ^
I guess the change in build.gradle are not enough for Windows, to be seen later...
2020-03-21 22:08:00 +01:00
Daniel Watford e2142dd00e Improved: Added license header to MacroFormRendererTest
(OFBIZ-4035)
2020-03-21 20:02:59 +01:00
Daniel Watford 05d734206a Improved: Added unit testing, using JMockit, to ensure that form macros are
rendered using ids from ModelFormField#getCurrentContainerId.

(OFBIZ-4035)
2020-03-21 20:02:59 +01:00
Jacques Le Roux c2fb314a1b Fixed: Ensure that the SameSite attribute is set to 'strict' for all cookies.
(OFBIZ-11470)

Fixes a typo
2020-03-21 12:02:03 +01:00
Jacques Le Roux fd1e7f477b 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-03-21 11:55:53 +01:00
Jacques Le Roux 7d95c46b83 Fixed: Ensure that the SameSite attribute is set to 'strict' for all cookies.
(OFBIZ-11470)

Forgot to add UtilHttp::SameSiteFilter
2020-03-20 18:04:31 +01:00
Jacques Le Roux 369d5f6c95 Fixed: Ensure that the SameSite attribute is set to 'strict' for all cookies.
(OFBIZ-11470)

As reported by OWASP ZAP:
A cookie has been set without the SameSite attribute, which means that the
cookie can be sent as a result of a 'cross-site' request. The SameSite attribute
is an effective counter measure to cross-site request forgery, cross-site script
inclusion, and timing attacks.

The solution was not obvious in OFBiz for 2 reasons:

1. There is no HttpServletResponse::setHeader. So we need to use a filter
  (SameSiteFilter) and even that is not enough because of 2:
2. To prevent session fixation we force Tomcat to generates a new jsessionId,
ultimately put in cookie, in LoginWorker::login. So we need to add a call to
SameSiteFilter::addSameSiteCookieAttribute in
UtilHttp::setResponseBrowserDefaultSecurityHeaders.
2020-03-20 17:50:17 +01:00
Nicolas Malin 13ee4cc263 Fixed: Unable to view entity row record in webtools if PK contains timestamp field
(OFBIZ-11426)

This problem came from when the GenericEntity try to store fields value on the map,
If the java type didn't match with the current value type, the function failed and
didn't try to convert it on the wanted type.

Thanks to Pawan Verma and Pierre Smits to raise this issue
2020-03-19 14:44:07 +01:00
Daniel Watford 584f1edda5 Improved: Ensure MacroFormRenderer uses
ModelFormField#getCurrentContainerId rather than
ModelFormField#getIdName to ensure any FlexibleStringExpander expression
defined in the field's id-name property is processed before rendering
into the container FTL macro.

(OFBIZ-4035)
2020-03-19 09:51:06 +01:00
Michael Brohl 83b8b27b58 Fixed: Fixed a bug introduced with the removal of the login security
question.

(OFBIZ-11244)

Thanks Olivier Heintz for reporting and Wiebke Pätzold for providing the
patch.
2020-03-17 12:36:40 +01:00
Dennis Balkir 2895da2220 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-15 11:23:33 +01:00
Jacques Le Roux 67531d8bb2 Improved: "auth" should be true for all the request url used for Application
components

(OFBIZ-4956)

Currently there are some URLs present in application components with
auth="false". So anyone can hit these URLs and access these resources without
authorization.
I think all the URLs should be secure with auth="true"

jleroux: I have also fixed the dataResourceId="GZ-DIG"

Thanks: Amardeep Singh Jhajj for report and initial fix
2020-03-14 08:51:23 +01:00
Michael Brohl bb698b9b96 Implemented: Remove the user login security question.
(OFBIZ-11244)

Thanks Wiebke Pätzold for providing the patch.
2020-03-13 17:31:49 +01:00
Jacques Le Roux 308fa20e81 Improved: Remove unused ‘UtilHttp#checkURLforSpiders’
(OFBIZ-11138)

The "link.remove_lsessionid.user_agent_list" properties was forgotten
2020-03-12 15:13:42 +01:00
Nicolas Malin 930f4af7a2 Improved: Convert CommonServices.xml from mini lang to groovy
(OFBIZ-11402)

Thanks to Wiebke Pätzold for providing the patch
2020-03-10 14:09:08 +01:00
Michael Brohl 03b3a7bc02 Improved: Upgrade Freemarker from 2.3.29 to 2.3.30.
(OFBIZ-11445)
2020-03-08 01:13:05 +01:00
Nicolas Malin 9a50fa907b Fixed: Refactoring permission model call, alone permission service failed
(OFBIZ-11440)

During refactoring (OFBIZ-7113), the service reader used two different methods to read a
permission service definition if is present alone or in a group. For the alone version a link
was missing between the service and the permission service to resolve correctly the permission.

To solve this problem I reorganized to use only one method to initialize a service model permission.

Other point, an attribute renaming was missed : action -> permissionMainAction, when service permission call was called

Last, these problems weren't detected before due to missing unit test on failure service permission, now cover.
2020-03-04 21:18:30 +01:00
Daniel Watford 0ece441228 Fixed: Fixed line lengths in ModelFormFieldTest to adhere to coding standards
(OFBIZ-11418)
2020-02-28 08:02:12 +00:00
Daniel Watford 5640de4eba Documented: Documented use of field attribute parameter-name and
lookup field attribute target-parameter in widget-form.xsd

(OFBIZ-11418)
2020-02-27 20:50:41 +00:00
Daniel Watford 08a371d047 Improved: Use FlexibleStringExpander in form widget lookup field field
target parameters

(OFBIZ-11418)

Changed target-parameter attribute of the form widget's Lookup field to
use the FlexibleStringExpander type rather than String. This has been
done to allow reference to other form fields which may have had their
parameter-name attribute set to a FlexibleStringExpander expression.
2020-02-27 18:42:11 +01:00
Suraj Khurana cc52b98151 Improved: Defects reported by code analysis tool.
(OFBIZ-10571)

Following refactoring done -
-- Refactored code to fall in line with some java standards.
-- Based on FindBugs suggestion, refactored some classes to have static nested classes instead of inner class.

Thanks Girish Vasmatkar for reporting the issue and providing the patch.
2020-02-26 16:06:55 +05:30
Jacques Le Roux 4697bf5faa Fixed: DatabaseUtil.getColumnInfo(...) does not retrieve primary keys due to
connection-locks
(OFBIZ-11312)

The method DatabaseUtil.getColumnInfo(...) uses an elaborate algorithm using a
List<Future<AbstractCountingCallable>> object. This does not work properly as it
runs into connection-locks. When debugging the error does not occur. I assume
that the slower pace of debugging prevents the error.

Thanks: Benjamin Jugl
2020-02-26 08:38:26 +01:00
Michael Brohl b55279101b Merge pull request #29 from PierreSmits/OFBIZ-10955-FieldType
Improved: field type Integer is missing in definitions.

(OFBIZ-10955)

Thanks Pierre Smits for the contribution.
2020-02-25 21:55:18 +01:00
Michael Brohl 8afb711ef3 Fixed: Fluent API Bug in getFieldList().
(OFBIZ-10298)

Thanks Benjamin Jugl for reporting and providing the patch.
2020-02-25 21:15:37 +01:00
Michael Brohl 74db8bde12 Improved: Performance optimization for entities in xml data export.
(OFBIZ-10157)

Thanks Kyra Pritzel-Hentley for reporting and providing the patch.
2020-02-25 20:31:53 +01:00
Pierre Smits 75ed0c48ee Fixed: Field Type definitions
(OFBIZ-10955)

Adding missing field type definition for Apache Derby, MySQL, PostgreSQL
2020-02-25 12:59:58 +01:00
Michael Brohl 59f05e6df1 Improved: Move permission checks to service definitions via permission
service.

(OFBIZ-11357)

Thanks Pawan Verma for the suggestion and Wiebke Pätzold for providing
the patch.
2020-02-25 12:05:34 +01:00
Jacques Le Roux 0e7d31912b Fixed: Improve ObjectInputStream class (CVE-2019-0189)
Improved: no functional change
(OFBIZ-10837) (OFBIZ-11398)

Steps to generate:
1. Navigate to - catalog/control/EditProdCatalog?prodCatalogId=TestCatalog
2. Click on - CREATE SEO CATEGORY/PRODUCTS
3. The broken page will be displayed

The issue is due to the use of a GString in
createMissingCategoryAndProductAltUrls().

This:
    result.successMessageList = [
        "Categories updated: ${categoriesUpdated}",
        "Products updated: ${productsUpdated}"

As it's common to use such expressions I have added the necessary
org.codehaus.groovy.runtime.GStringImpl groovy.lang.GString
to the white list of classes in listOfSafeObjectsForInputStream in
SafeObjectInputStream.properties

I finally have also decided to use this property as default and commented for
committers to be aware that it should be also put in DEFAULT_WHITELIST_PATTERN
in SafeObjectInputStream class. Because if, for a reason,
listOfSafeObjectsForInputStream is empty OFBiz will still be protected

Thanks: Dikpal Kanungo for reporting
2020-02-24 11:00:51 +01:00
Daniel Watford e76cbd1f34 Improved: Added ModelFormField testing to ensure getting a field's
current container id will return an evaulated FlexibleStringExpander
expression.

(OFBIZ-4035)
2020-02-23 20:32:50 +01:00
Daniel Watford d6132fa534 Documented: change the id Attribute for input fields in the model macro
form renderer from String to FlexibleStringExpander

(OFBIZ-4035)

Document that the id-name attribute for a form widget's field
element can use ${} notation. Also document the default value if id-name is
not set.
2020-02-23 20:28:45 +01:00
Michael Brohl f5a8479c46 Documented: Upgrades the documentation references in
catalina/ofbiz-component.xml to the 9.0 documentation.
2020-02-23 12:45:21 +01:00
Michael Brohl 0d623c077f Upgrade Tomcat from 9.0.29 to 9.0.31
(OFBIZ-11407)

Overriding the new default property secretRequired to be not required
and added the default property "secret" in the commented out section.
2020-02-23 12:23:43 +01:00
Nicolas Malin dff226ea60 Improved: Refactoring old job process
(OFBIZ-11200)

Before this commit, to purge old job we use the thread job manager to check
if some job need to be run and if the pool is empty, check the old job to purge.

I detected a problem when you have many job's server and more than one pool.
When you have a first pool that run regular job and a second that receive
huge asynchrone services (by persist call), the server who manage the second pool
have rarely the possibility to purge their jobs that, by the way, increase JobSandbox table.

The Server who manage the first pool, call often the purge process, but the table size
generate a long query time to purge few element. Long query time, run often,
this purge process load uselessly the database.

After analyze, I refactoring these following items :

 * When you call JobSandbox table for a purge, use a limit on the query
   with the max thread pool because when you have the database return,
   you purge only with this limit so this help the database to not scan
   the whole table. Other small improvement, do not sort the result
   (no functional gain).

 * Purge by the pool thread is nice, each server can only purge their
   own job (filtered on run_by_instance_id), to help an overloaded server,
   I was rehability purgeOldJobs service that it can run with specific
    parameter to make assistance.

 * Last, all job services are historical on class org.apache.ofbiz.service.ServiceUtil,
   I moved them all in a new dedicate class org.apache.ofbiz.service.job.JobServices
2020-02-22 18:48:32 +01:00
Michael Brohl 211c1924a5 Provide a FileItem entry in UtilHttp.getMultiPartParameterMap.
(OFBIZ-11346)
2020-02-22 11:57:11 +01:00
Michael Brohl 30566a6bde Convert Thesaurus services in CommonServices.xml from mini lang to
groovy.
(OFBIZ-11357)

Thanks Wiebke Pätzold for reporting and providing the patch.
2020-02-22 10:29:35 +01:00
Jacques Le Roux be3da7119c Fixed: replaceFirst sensible to variable pattern
(OFBIZ-11396)

When using variable pattern with replaceFirst you may cross issues if the
pattern contains specific tokens. For instance on Windows with the path
"C:\projectsASF\Git\ofbiz-framework/" you have inside the token "\p" which has
a special meaning.
2020-02-22 09:41:11 +01:00
Deepak Dixit 0e007d80c2 Added missing GeoAssoc data for Ladakh geo
(OFBIZ-11399)
2020-02-22 13:03:01 +05:30
Deepak Dixit 4f25633992 Update India Geo information according to ISO notifications 2019-11-22
(OFBIZ-11399)

Change of subdivision category from state to Union territory for IN-JK; Addition of Union territory IN-LA;
2020-02-22 12:52:45 +05:30
Suraj Khurana 31ff921db3 Merge branch 'trunk' of https://gitbox.apache.org/repos/asf/ofbiz-framework into trunk 2020-02-22 12:42:15 +05:30
Suraj Khurana 24fb560ecf Fixed: UserLoginPasswordHistory is not maintaining password as present in UserLogin.
(OFBIZ-10802)
Thanks Rohit Koushal for the patch. Thanks Jacques Le Roux and Gil Portenseigne for the review.
2020-02-22 12:41:36 +05:30
Jacques Le Roux 549543ace5 Fixed: replaceFirst sensible to variable pattern
(OFBIZ-11396)

When using variable pattern with replaceFirst you may cross issues if the
pattern contains specific tokens. For instance on Windows with the path
"C:\projectsASF\Git\ofbiz-framework/" you have inside the token "\p" which has
a special meaning.
2020-02-22 07:32:15 +01:00
Pawan Verma f25c7d33dc Improved: Enhance the Programmable Export feature for EntityQuery support
(OFBIZ-11158)

EntityQuery usage to perform data fetching is increasing, we should also add support for EntityQuery in ProgramExport feature.

Thanks: Devanshu Vyas for report and patch and Suraj Khurana, Nicolas Malin for the review.
2020-02-22 11:22:34 +05:30
Nicolas Malin 0da10ea897 Fixed: FindGeneric failed to generate forms
(OFBIZ-11335)

The commit 1941a05a34 introduce the visualTheme
to generate a form with FactoryForm and forms present on FindGeneric has been forget

Thanks to Sebastian Berg for raise this issue
2020-02-20 19:34:01 +01:00
Nicolas Malin 296417a7bd Fixed: Correct check style issue on ModelTheme 2020-02-20 14:50:19 +01:00
Nicolas Malin 38f972a0d0 Improved: Add CommonForms as template pattern configured by theme
(OFBIZ-11335)

Currently on OFBiz we implemented a process to define some different
screen and menu that can be implemented by the theming.
But for the form we have nothing. All style are hard coded on each

    <grid name="ListEntities" ...
      odd-row-style="alternate-row" default-table-style="basic-table hover-bar">

I extend the theming implementation principle to forms element with adding :
 * a new xsd element common-forms (like common-screens)
 * some default form templates to extend :
   * grid CommonSimpleGrid
   * grid CommonBasicGrid
   * form CommonSimpleList
   * form CommonBasicList
   * form CommonInLineEditList
   * form CommonBasicSingle

We can use its like :

    <form name="LayoutDemoList" extends="CommonBasicList"
          extends-resource="component://common/widget/CommonForms.xml"

The main difficulty raise to this task was propage the visualTheme during
the ModelForm intanciation, because we need to load wiget style
(and some other information wanted on the template) on model load in memory.
This is cover by commit 1941a05a34.

Forms present on the screen https://localhost:8443/webtools/control/WebtoolsLayoutDemo
are now extend through with theme.

Finally with this we can extend style form (pagination, header, line and so on ...)
directly by your theme without change the framework.
2020-02-20 14:49:11 +01:00