Commit Graph
10472 Commits
Author SHA1 Message Date
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
Jacques Le Roux 20e7fc5435 Fixed: Creating a new Customer create a wrong record in CommunicationEvent (OFBIZ-12142)
In https://markmail.org/message/pf3d3qyjfucicbj7 I initially answered:
In demo data 13 parties use <<infoString="ofbiztest@example.com">> as in
<ContactMech contactMechId="FRA01" contactMechTypeId="EMAIL_ADDRESS" infoString="ofbiztest@example.com"/>
This one is loaded last. Rather
<ContactMech contactMechId="Company" contactMechTypeId="EMAIL_ADDRESS" infoString="ofbiztest@example.com"/>
which is the 1st one, should be loaded last.

A better solution is to use "ofbizsupport@example.com" in EmailServices.xml

Indeed, fortunately the Company party also uses this infoString and using it in
EmailServices.xml does not affect the integration test and should not affect
other parts of the (only) demo data

Thanks: Emad Radwan for opiniated report :) and Pritam Kute for issue analysis
2021-01-18 19:41:08 +01:00
Jacques Le Roux 3f76f86014 Improved: Marked unused HTML renderers as deprecated (OFBIZ-11927)
Upcoming Branch is actually another name for trunk. It's always evolving and
never released. Better put a date when deprecating a Class or method. Else you
have no idea when it was deprecated, apart referring to git-blame.
2021-01-16 10:14:28 +01: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 406f51d032 Improved: Marked unused HTML renderers as deprecated
(OFBIZ-11927)
2021-01-14 17:30:03 +00:00
Daniel Watford 7830328bb4 Improved: Removed deprecated ExpectedException.none from tests
(OFBIZ-12137)

Prevents logging of deprecation warnings during the build.
2021-01-14 17:07:40 +00:00
Daniel Watford d40081dc86 Improved: Minor changes to reduce checkstyle warnings count 2021-01-13 14:28:19 +00:00
James Yong 9c7dc7b877 Improved: Rename MultiBlockHtmlTemplateUtil to ScriptLinkHelper (OFBIZ-12134)
Rename + Refactor
2021-01-13 09:26:42 +08: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
James Yong 3c83ab53b2 Refactoring 2021-01-12 23:25:25 +08:00
Daniel Watford 3795727ea2 Improved: MacroFormRenderer refactoring of label, display and text
fields

(OFBIZ-11900)

New RenderableFtl elements to represent pre-rendered FTL strings and FTL
macro calls. RenderableFtl elements are able to render themselves to
strings which are processed as an FTL template by the FtlWriter class.

For labels, display fields and text fields, MacroFormRenderer no longer
generates FTL to write to a template itself, but instead calls
RenderableFtlFormElementsBuilder to create corresponding RenderableFtl
elements which are then processed by FtlWriter. This is a WIP to reduce
complexity in MacroFormRenderer.
2021-01-12 10:40:58 +00: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
Suraj Khurana cc17887980 Improved: Added support to calculate distance between two geo points.
(OFBIZ-11901)
Thanks Ravi Lodhi for review and discussion.
2021-01-09 13:37:21 +05:30
James Yong 067db8fe9e Improved: Open Menu file from browser (OFBIZ-12119)
User can open menu definition file from the browser by clicking on the named border.
2021-01-09 13:05:23 +08:00
James Yong f484b0d318 Fixed: Open Screen file from browser (OFBIZ-12038)
Fix named borders not rendered for sub-screens.
2021-01-06 23:23:35 +08:00
Jacques Le Roux c7e1114b74 Fixed: partymgr fails to upload image (OFBIZ-12101)
This is a bug due to OFBIZ-12080, fileToCheck is the complete name of the file
with path not the filename

Thanks: Wai for report
2020-12-26 09:06:02 +01:00
James Yong 203fa5f1c1 Implemented: Support Freemarker square interpolation syntax (OFBIZ-12099)
Use square interpolation syntax when file extension is .spi.ftl
2020-12-21 19:46:11 +08:00
James Yong 483e77ea83 Fixed: Date picker not initialised in ajax-called form (OFBIZ-12097)
Use inline script when request is ajax
2020-12-20 08:46:52 +08: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 ec2b84341e Reverted: "Improved: Hyperlink target-type attribute is deprecated and should be replaced by url-mode (OFBIZ-12091)"
This reverts commit 17eb2e4cf7.

It does not work when using <<target="javascript:........>>
I could change those cases but it's easier and safer to simply revert back to
target-type!

Thanks: James for report
2020-12-18 11:08:32 +01: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
Jacques Le Roux c4650ff9bc Fixed: Secure the uploads (OFBIZ-12080)
According to https://s.apache.org/rpzog, adds few, maybe redundant, Java
API/methods found in webshell, or alike, source code
2020-12-14 19:00:37 +01:00
Jacques Le Roux 179dd2411a Fixed: Secure the uploads (OFBIZ-12080)
Follows OWASP advice on file names:

All the control characters and Unicode ones should be removed from the filenames
and their extensions without any exception. Also, the special characters such as
“;”, “:”, “>”, “<”, “/” ,”\”, additional “.”, “*”, “%”, “$”, and so on should be
discarded as well.

If it is applicable and there is no need to have Unicode characters, it is
highly recommended to only accept Alpha-Numeric characters and only 1 dot as an
input for the file name and the extension; in which the file name and also the
extension should not be empty at all
(regular expression: [a-zA-Z0-9]{1,200}.[a-zA-Z0-9]{1,10}).

So if someone needs other chars in uploaded filenames a change will be needed
2020-12-14 16:46:05 +01:00
Jacques Le Roux 63e2b526b8 Fixed: Secure the uploads (OFBIZ-12080)
Prevents too long filenames as recommended by OWASP.

Based on https://security.stackexchange.com/questions/46484/denial-of-service-when-uploading-a-file#answer-46495
I decided to not limit sizes of files. Anyway we know it's only post-auth...
2020-12-14 12:46:32 +01:00
Jacques Le Roux 93fb762071 Improved: Add unique identifier data to portlet context (OFBIZ-12090)
Add the portalPortletId + portletSeqId to the portlet context. This is useful if
a unique identifier within the portlet body (the portlet content) is required.

Thanks: Ingo Wolfmayr
2020-12-12 19:39:31 +01:00
Jacques Le Roux 17eb2e4cf7 Improved: Hyperlink target-type attribute is deprecated and should be replaced by url-mode (OFBIZ-12091)
Same for sub-hyperlink
2020-12-11 16:52:04 +01:00
Jacques Le Roux caded9e937 Fixed: Hyperlink title under form widget doesn't support character encoding for special characters (OFBIZ-12026)
When we use any title with special characters for hyperlink tag, it shows broken
string on UI, eg:
<hyperlink description="${uiLabelMap.CommonImportExport}"  target="ImportExport">
should render a button with the title "Import/Export. But it shows as
Import&#x2f;Export

jleroux: I have noticed that the same happens with special French characters.
So it's a general issue.
The title (description in code) is HTML encoded and that does not work for
special characters. I simply used a string encoder.

Thanks: Pradeep Choudhary for report, Sourabh Jain for a possible but not
general solution at OFBIZ-12023, ie using target-type="plain"
2020-12-11 13:40:53 +01:00
James Yong 89f36f1a06 Correct spelling for μManager.
Reference: https://imagejdocu.tudor.lu/faq/general/which_file_formats_are_supported_by_imagej
2020-12-08 19:49:15 +08:00
James Yong 931716a628 Improve notes for Tomcat SSO 2020-12-08 19:37:21 +08:00
Jacques Le Roux 100810faeb Fixed: Secure the uploads (OFBIZ-12080)
Adds audio and video as supported formats
2020-12-07 19:48:36 +01:00
Jacques Le Roux 4481f373ca Fixed: Secure the uploads (OFBIZ-12080)
Handles audio and video formats supported by Tika.

Adds few new audio and video formats in seed data.

AFAIK there are no ways to embed a webshell in an audio or video file. So I did
not sophisticate the validation, just rely on Tika.

I have also fixed bugs in SecuredUpload: in isValidSvgFile and
isValidImageIncludingSvgFile
2020-12-07 18:45:24 +01:00
James Yong c1644940e9 Fixed: Make locale available for DateFindField and DateTimeField macros (OFBIZ-12086)
Fixed compile error in MacroFormRendererTest.java.

Thanks: Daniel and Tomek for the finding
2020-12-07 23:46:02 +08:00
Jacques Le Roux 5fa312cfb9 Fixed: Secure the uploads (OFBIZ-12080)
Improves the labels names and format comment in LayoutEvents.java

I backport to ease later works...
2020-12-06 11:16:44 +01:00
James Yong 76a940ab43 Improved: Make locale available for DateFindField and DateTimeField macros (OFBIZ-12086)
DateFindField and DateTimeField macros need to find locale-specific javascript library files.
2020-12-05 23:13:55 +08:00
James Yong cfabbc9b74 Fixed: jquery.ui.datepicker-en.js does not exist (OFBIZ-12071)
Fixed for Jquery DatePicker
2020-12-05 19:24:09 +08: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
Nicolas Malin 816068335c Improved: Improve makeRangeCondition in file EntityDateFilterCondition.java
(OFBIZ-12051)

When we have a value with both from and thrudate greater than given range

Thanks to Leila Mekika for this improvement
2020-11-29 19:21:23 +01:00
James Yong 283752fd26 Fixed: jquery.ui.datepicker-en.js does not exist (OFBIZ-12071)
Default language file specified for DateTime doesn't exist in the project i.e.
/common/js/jquery/ui/i18n/jquery.ui.datepicker-en.js

Changed to /common/js/jquery/plugins/datetimepicker/i18n/jquery-ui-timepicker-en.js
2020-11-28 21:26:47 +08:00
Deepak Dixit 9cf1d78555 Improved: Update IND Geo data as per 2020-11-24 notification (#240)
- Deletion of Union territory IN-DD, IN-DN;
- Addition of Union territory IN-DH;
- Correction of spelling for IN-AR, IN-BR, IN-CH, IN-CT, IN-DH, IN-GJ, IN-HP, IN-HR, IN-JH, IN-JK, IN-KA, IN-LA, IN-MH, IN-ML, IN-NL, IN-RJ, IN-TG, IN-TN, IN-UT;
2020-11-28 12:24:39 +05:30
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 b445e17407 Fixed: Issue in ServiceDemoData.xml due to an error with MX_FED_HOLIDAYS
LoadAll was failing:
2020-11-18 21:08:45 +01:00
Jacques Le Roux 17de4f6e07 Improved: Added multiple "es" and "es-MX" values. Added Mexican Federal Holidays
Fixed: Mexican States Abbreviations

In GeoData_MX.xml abbreviations of the Mexican States were wrong and
"Mexico City" state was labeled as County, which is not.

In CommonUiLabels.xml and CommonEntityLabels.xml were added some missing values
to "es" and "es-MX" languages

In ServiceDemoData.xml were added the Mexican federal holidays under the
temporal expression "MX_FED_HOLIDAYS"

Thanks: Zottacko WallyMan
2020-11-18 17:05:41 +01:00
Jacques Le Roux f34a0d9ff5 Fixed: Prevent arbitary file write using webtools/control/EntitySQLProcessor. (OFBIZ-12057)
Shuibo Ye <shuiboye@gmail.com> reported a possible arbitary file write using
webtools/control/EntitySQLProcessor.

    In the "SQL Command" part, I create a table and insert some strings and
    export the table to a file one sentence at a time.
    PoC: CREATE TABLE "test" (string VARCHAR(80))
    INSERT INTO "test" (string) VALUES ('<%= system.getProperty("user.dir") %>')
    call SYSCS_UTIL.SYSCS_EXPORT_TABLE(null,'test','.\framework\webtools\webapp\webtools\default.jsp',null,'*',null)

    After executing the three sentences,I successfully write the file and its url
    is https://localhost:8443/webtools/default.jsp.

I fixed it preventing execution on SYSCS_UTIL.SYSCS_EXPORT_TABLE and JSP, more
could be added if necessary
2020-11-16 14:11:13 +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 70d3916d4f Improved: Prevent possible post-auth RCE from webtools/control/ProgramExport (OFBIZ-12055)
This was reported to the security team by Shuibo Ye <shuiboye@gmail.com>.
We did not create a CVE because it's a post-auth "vulnerability"

Thanks: Shuibo Ye
2020-11-13 09:34:49 +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