Feature Language Change ? NPM Resource Changed ? Pending

User tests: Successful: Unsuccessful:

avatar nikosdion
nikosdion
6 Sep 2022

Address upload and update failures

Pull Request for Issue #38702 .

Summary of Changes

Joomla Update now has the following checks to prevent users from accidentally uploading full installation packages.

Client–side

  • Make sure the user is uploading a ZIP file based on its extension (case–insensitive).
  • Make sure the user is uploading a ZIP file based on the file type reported by the browser.
  • Make sure the user is NOT uploading a Full Package based on whether the file installation/index.php is present in the ZIP file (by looking for its Central Directory record in the file contents). (This was deemed redundant and unnecessary by the maintainers, therefore removed)
  • Make sure the user is uploading an Upgrade Package based on the uploaded file's name pattern.

Server–side

  • Make sure the user is NOT uploading a Full Package based on whether the file installation/index.php is present in the ZIP file (by looking for its Central Directory record in the file contents).

(the check for ZIP file format is already present in Joomla Update without this PR)

Furthermore, this PR updates the messages telling people to go to downloads.joomla.org/latest with the note that they need to click on View All Packages and download the “Upgrade Package (.zip)” item, something which was previously implied but sufficiently unclear as to confuse users.

Testing Instructions

  • Download the Upgrade and Full packages in ZIP and TAR format.
  • Use the Upload and Upgrade tab to try and install an upgrade package.
  • TEST 1: Use the Full Package ZIP
  • TEST 2: Use the Full Package TAR. You can only do that if you drag'n'drop the file to the upload field.
  • TEST 3: Use the Full Package TAR after changing its extension to .zip
  • TEST 4: Use the Upgrade Package TAR. You can only do that if you drag'n'drop the file to the upload field.
  • TEST 5: Use the Upgrade Package TAR after changing its extension to .zip
  • TEST 6: Rename the Full Package ZIP to the name of the Upgrade Package ZIP and use that renamed file
  • TEST 7: Use the right Upgrade Package ZIP (not the one renamed in the previous test)

NOTE: When I say "TAR" above I mean either the .tar.gz or the .tar.bz2. Which one is irrelevant; they will both work the same.

IMPORTANT NOTE: If you click the Choose File button next to the upload file field it will only let you pick ZIP files (unless you are on Windows and see that there is a file type drop-down at the bottom right corner, where you can switch to All Files, as @brianteeman pointed out). However, if you drag'n'drop a file from your Operating System's file manager into the field it will happily accept files of any extension on any Operating System. This is very likely how most of the people who tried using the .tar.gz and .tar.bz2 update files ended up doing it. Of course, these file formats do not work with Joomla Update and the messages they were getting were not very helpful either.

Actual result BEFORE applying this Pull Request

  • TEST 1: The file uploads. The update is incomplete (see Technical Notes). The site MAY be bricked.
  • TEST 2: The file uploads. You get an error when we attempt to extract it.
  • TEST 3: The file uploads. You get an error when we attempt to extract it.
  • TEST 4: The file uploads. You get an error when we attempt to extract it.
  • TEST 5: The file uploads. You get an error when we attempt to extract it.
  • TEST 6: The file uploads. The update is incomplete (see Technical Notes). The site MAY be bricked.
  • TEST 7: Success!

Expected result AFTER applying this Pull Request

IMPORTANT! Remember to run npm ci if you are not using the pre–packaged Joomla ZIP files built by Drone. The Javascript files for com_joomlaupdate have changed.

  • TEST 1: The file DOES NOT upload. You get a message that you are using the wrong package type (Full instead of Upgrade).
  • TEST 2: The file DOES NOT upload. You get a message that you are using the wrong format.
  • TEST 3: The file DOES NOT upload. You get a message that you are using the wrong format.
  • TEST 4: The file DOES NOT upload. You get a message that you are using the wrong format.
  • TEST 5: The file DOES NOT upload. You get a message that you are using the wrong format.
  • TEST 6: The file uploads, but the update doesn't start. You get a message that you are using a package which looks like a full installation package.
  • TEST 7: Success!

Documentation Changes Required

None, this is a self–documenting, multiple–redundant failsafe.

Translation impact

Translations strings are CHANGED and ADDED. Translation teams need to be notified upon merge.

Technical notes

The reason sites break when trying to upgrade them with the Full Package is the existence of the installation folder and files inside that folder.

When the installation folder is present on the disk Joomla will redirect any access on its index.php files to installation/index.php.

However, Joomla Update needs to access administrator/index.php?option=com_joomlaupdate&... after the package is extracted to a. update the database and perform any post-extraction actions and b. to clean up after itself.

Since the existence of the installation folder causes a redirection these two steps are never executed. The user ends up with a half-upgraded site in a state which is probably very broken.

In most cases the site CAN be salvaged by using the CLI command update:joomla:remove-old-files, removing the installation folder and then going to administrator, System, Maintenance, Database, select Joomla CMS and click on Fix. However, this leads to several problems:

  • Most users are not familiar with CLI (duh), if they even have CLI access on their server…
  • New core extensions are NOT installed (Database fix only runs schema changes but not INSERT, DELETE etc queries)
  • Any necessary data manipulation in the database is not executed for the same reason as above
  • If any of these actions really do need to run before accessing the site again, the site is very likely bricked hard and has to be restored from a backup. Yes, we tell users to confirm they are aware of the need of backups yet most of them don't take backups.

Therefore, the only reasonable way to address this problem is to try really hard to prevent people from shooting their own two feet by not allowing them to upload anything which looks like the Full Package and trying to make sure they are uploading something which looks like an Upgrade Package.

Implementation notes

I avoided using any client– or server–side library to check the contents of the ZIP file package. THIS IS INTENTIONAL.

Third party libraries do a lot more than check for existence of files in an archive (thereby increasing the attack surface area of Joomla), they are slow, and they are evidently much larger by two or three orders of magnitude than the alternative. Moreover, we have the added complication that we have to either use a pure PHP library we need to maintain (no, thank you, we already do that with extract.php), or we have to rely on ZipArchive which may or may not be present on the server.

The code I wrote is based on my knowledge of the ZIP archive format specification (a.k.a. APPNOTE.TXT, named after the file Phil Katz was including with MS-DOS version of PKZip since its inception in 1989). The check is reduced to one string search and two dead simple string comparisons (4 and 2 bytes respectively) which are computationally very cheap. This code runs in around 0.1 milliseconds versus 4 milliseconds for ZIPArchive and around 2 seconds for JavaScript ZIP libraries.

The check is included in both client– and server–side. THIS IS ALSO INTENTIONAL. A false negative — accidentally letting the Full Package go through — will result in a malfunctioning or completely bricked site. We are not in control of the client–side at all. We have no guarantees that our client–side checks ever ran. Therefore, it's prudent to perform the same simple check on the server–side. We lose a fractional millisecond to save the user from hours of hair–pulling. (This was deemed redundant and unnecessary by the maintainers)

avatar nikosdion nikosdion - open - 6 Sep 2022
avatar nikosdion nikosdion - change - 6 Sep 2022
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 6 Sep 2022
Category Administration com_joomlaupdate Language & Strings JavaScript Repository NPM Change
avatar brianteeman
brianteeman - comment - 6 Sep 2022

I don't think we have a policy on this but I would think it is better not to use 66/99 quotation marks in our strings. They dont even exist on my keyboard and it will be too easy for someone to use a regular quotation mark which will break the string. I would either use an escaped " or a single '

@tecpromotion ??

avatar nikosdion
nikosdion - comment - 6 Sep 2022

I would prefer to fix the content of latest as I have requested from @HLeithner d of the change to the language string.

I don't disagree with that. I am also aware that they are using a very old, very customised version of Akeeba Release System so I am not entirely sure if they can do that. Years ago Michael had told me some of the configuration he had to make and I had told him that's bonkers. I'll leave it at that.

I don't think we have a policy on this but I would think it is better not to use 66/99 quotation marks in our strings.

My bad, I should have changed these to « and ». Let me merge your suggestions and I'll get back to that.

FYI, you should have these quotes using the right ALT key (AltGr — Alternate Graph). It exists in all European ISO layouts but the actual glyphs may vary between keyboard layouts and OS. On Windows I believe you can press WIN+. (Windows key and dot held down together) to get the Emoji picker which also has alternate graphs in its last pages. I am on the MacBook Pro now, can't check to be 100% sure at the moment.

avatar nikosdion nikosdion - change - 6 Sep 2022
Labels Added: Language Change NPM Resource Changed ?
avatar nikosdion
nikosdion - comment - 6 Sep 2022

I obviously meant “ and ”. Brain, brain, oh where are thou?

avatar nikosdion
nikosdion - comment - 6 Sep 2022

Amazing, GitHub converts the HTML entities. Ampersand ldquo semicolon and ampersand rdquo semicolon. Hopefully you get what I mean. Sigh.

avatar Kostelano
Kostelano - comment - 6 Sep 2022

I obviously meant “ and ”. Brain, brain, oh where are thou?

\"text_inside\"

UPD
I see that they didn't work. very strange, because there are a lot of places in the admin panel where we use them.

avatar nikosdion
nikosdion - comment - 6 Sep 2022

@Kostelano I was trying to avoid using these wrong quotes but HTML entities don't work with alerts so... I have up and used the wrong quotes. Oh well...

avatar brianteeman
brianteeman - comment - 6 Sep 2022

I know how to type the ” with the keyboard ( alt 0147). I meant that its not on an actual key.

avatar richard67
richard67 - comment - 7 Sep 2022
avatar brianteeman
brianteeman - comment - 7 Sep 2022

Can you fix the conflicts please and then I will test it

avatar nikosdion
nikosdion - comment - 7 Sep 2022

Done

avatar brianteeman
brianteeman - comment - 7 Sep 2022

The horrible alerts that I wish we didnt use any more do not support html

image

avatar brianteeman
brianteeman - comment - 7 Sep 2022

Incorrect message
image

avatar brianteeman
brianteeman - comment - 7 Sep 2022

incorrect message
image

avatar brianteeman
brianteeman - comment - 7 Sep 2022

test 2 and test 4
there is no tar only tar.gz
its not possible to select those files as the file selector is restricted to zip
so cant get the "expected result" from your instructions

avatar nikosdion
nikosdion - comment - 7 Sep 2022

Tests 2 & 4: I had rigged my local site to allow any file. You are right that in the release it won't allow you to select these files. Ignore them.

avatar nikosdion
nikosdion - comment - 8 Sep 2022

@brianteeman Try again, I fixed the JavaScript.

Also, it's worth noting that you cannot pass double or single quotes to JavaScript using \' or \" in the language string. Therefore I reverted these language strings to use calligraphic quotes.

avatar brianteeman
brianteeman - comment - 8 Sep 2022

thanks will check - hopefully with a little help from @Fedik the alerts will be getting a facelift with sweetalert2

avatar nikosdion
nikosdion - comment - 8 Sep 2022

I am done arguing with @dgrammatiko so let him figure out how to solve this on his own. If he's a know-it-all he'd better bloody prove it by writing AND maintaining code for the core.

avatar nikosdion nikosdion - change - 8 Sep 2022
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2022-09-08 10:10:59
Closed_By nikosdion
avatar nikosdion nikosdion - close - 8 Sep 2022
avatar dgrammatiko
dgrammatiko - comment - 8 Sep 2022

@nikosdion you have some serious issues, how the heck am I even involved here? I haven't participated in this PR!

avatar nikosdion
nikosdion - comment - 8 Sep 2022

Dimitri, when you finally get your you know what together you'll see it's the PR for the issue you participated in, where YOU told me that the approach I proposed (and which I implemented in this PR) is wrong.

So, if you think you know better, show us your code or get lost. Kthxbye

avatar Fedik
Fedik - comment - 8 Sep 2022

Nicholas can you please reopen the PR.
And please exchange alert to Joomla.renderMessages

Joomla.renderMessages({error:['Errororororo message!']})

But if you do not want to bother with JavaScript part, just trash it, and leave all hard job to Server side, that also fine ?
I would really keep only a server side validation for "Package or not to Package".

avatar nikosdion nikosdion - change - 8 Sep 2022
Status Closed New
Closed_Date 2022-09-08 10:10:59
Closed_By nikosdion
avatar nikosdion nikosdion - change - 8 Sep 2022
Status New Pending
avatar nikosdion nikosdion - reopen - 8 Sep 2022
avatar nikosdion
nikosdion - comment - 8 Sep 2022

@Fedik Do you have some time to do the change yourself? You SHOULD have write access as you're a repo maintainer and I've selected the GitHub option to allow y'all to make changes to the code. If not let me know and I'll try to do that over the weekend. I have paid work I need to finish.

Just a note about Joomla.renderMessages. Have you guys tried using the Upload & Update page on a small screen (13" to 15") with two or three messages about PHP upload options showing on the screen? I had to scroll about a page and a half down to find the upload field. If I use Joomla.renderMessages how would I know there's a message (if I remember correctly it doesn't make the page auto-scroll to the top)? :)

avatar Fedik
Fedik - comment - 8 Sep 2022

Just a note about Joomla.renderMessages. Have you guys tried using the Upload & Update page on a small screen (13" to 15") with two or three messages about PHP upload options showing on the screen?

Yeah that not very nice, but that another issue.

Do you have some time to do the change yourself?

I will do later on, PR to your branch

avatar Fedik
Fedik - comment - 8 Sep 2022

@nikosdion I made PR to your branch.

Note about \" ? to know:
To avoid such thing need to use Text::script('POTATO'); instead of Text::script('POTATO', true);.
$jsSafe param is a legacy thing from times when we render JS, instead of using JSON.

avatar nikosdion
nikosdion - comment - 8 Sep 2022

@Fedik Would you make a PR with a DocBlock change to explain that second parameter? Its use is very opaque. I saw we were passing it in the existing code for Joomla Update and just copied it over. Apparently I don't use it in my own software because at some point years ago I did debug that and saw what it does but I forgot in the meantime...

40f7ab9 8 Sep 2022 avatar Fedik jscs
ebe1363 8 Sep 2022 avatar Fedik jscs
avatar brianteeman
brianteeman - comment - 8 Sep 2022

still getting the wrong error message

image

avatar Fedik
Fedik - comment - 8 Sep 2022

Did you run npm install? There should not be alerts anymore

avatar brianteeman
brianteeman - comment - 8 Sep 2022

i used the generated build

avatar Fedik
Fedik - comment - 8 Sep 2022

I hope it was not Joomla_4.2.2_to_4.2.3-dev+pr.38707 or Joomla_4.2.x_to_4.2.3-dev+pr.38707.

Please update /media/com_joomlaupdate/ files from Joomla_4.2.3-dev+pr.38707-Development-Full_Package.zip or Joomla_4.2.3-dev+pr.38707-Development-Update_Package.zip

avatar brianteeman
brianteeman - comment - 8 Sep 2022

I used

https://ci.joomla.org/artifacts/joomla/joomla-cms/4.2-dev/38707/downloads/57644/pr_list.xml

trying a clean install now

avatar brianteeman
brianteeman - comment - 8 Sep 2022

grrh - I was seeing a cached download link

avatar brianteeman
brianteeman - comment - 8 Sep 2022

ok I have the correct install now and see the messages instead of alerts.

However every test produces the same error message
COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_NOTZIP="You need to upload the “Upgrade Package (.zip)” file of the Joomla version you want to upgrade to. You are trying to upload a file which is not in the ZIP format. The Joomla Update does not support the upgrade package files with .tar.gz and .tar.bz2 extensions."

I never get the message
COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_FULLINSTALLATION="The ZIP file you uploaded looks like the Full Package of Joomla! which is only for creating new sites. You can only use the “Upgrade Package (.zip)” to update your site."

avatar Fedik
Fedik - comment - 8 Sep 2022

That strange, because it works for me.

Can you please try next: enable debug, edit media/com_joomlaupdate/js/default.js to add console.log(file);return; somwhere after here:

const file = form.install_package.files[0];

Open Browser Dev console, try upload the file (update and full) and make screenshot of result.

Should be kind of this:
Screenshot 2022-09-08_21-41-09

avatar brianteeman
brianteeman - comment - 8 Sep 2022

Test 1
w/ log
image

w/o log
COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_NOTZIP

Test 2
image

COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_NOTZIP

Test 3
image
COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_NOTZIP

avatar Fedik
Fedik - comment - 8 Sep 2022

hmhm, I wonder what is application/x-zip-compressed, should be application/zip.
what browser do you use, Safari?

avatar brianteeman
brianteeman - comment - 8 Sep 2022

google chrome on windows 11

avatar brianteeman
brianteeman - comment - 8 Sep 2022

according to python.org this is the expected mimetype on windows
https://bugs.python.org/issue41738

avatar nikosdion
nikosdion - comment - 9 Sep 2022

@brianteeman Let me set up my Windows 11 machine for core development and I'll take a look later today. I think I know exactly how to address it but I'd like to test it, not just do a blind fix :)

avatar Fedik
Fedik - comment - 9 Sep 2022

@nikosdion I think we can just remove "type check" and leave only ".zip" extension. The server side will throw an error if it not valid zip anyway. Or what do you think?

avatar nikosdion
nikosdion - comment - 9 Sep 2022

The PR as is works on macOS (therefore also any BSD box) and Linux. Let me get my Windows box ready so I can run more tests. I want to make an informed decision.

avatar nikosdion nikosdion - change - 9 Sep 2022
The description was changed
avatar nikosdion nikosdion - edited - 9 Sep 2022
avatar nikosdion
nikosdion - comment - 9 Sep 2022

I have updated the PR with the following changes:

  • Reinstated the checks for the Update Package and Full Package based only on their naming pattern. This is important to provide an early and helpful message to users trying to use the wrong package.
  • Fixed the Windows ZIP file type detection.
  • Replaced calligraphic quotes with regular double quotes using @Fedik's advice on the second parameter of Text::script().
  • Updated the PR test instructions, explaining how you can drag'n'drop a .tar.gz file even though clicking on Choose File doesn't let you choose it. This also explains how people ended up trying to use these files. I only noticed because I instinctively dragged and dropped the update ZIP file when upgrading a local site earlier today on my Windows box (which I had not used for a month) at which point I went "d'oh, that's what other people must be doing, too!".

Happy testing!

avatar brianteeman
brianteeman - comment - 9 Sep 2022

TEST 1: The file DOES NOT upload. You get a message that you are using the wrong package type (Full instead of Upgrade).
TEST 2: The file DOES NOT upload. You get a message that you are using the wrong format.
TEST 3: The file DOES NOT upload. You get a message that you are using the wrong format. wrong package type message (but i think thats correct message and your expected result is wrong)
TEST 4: The file DOES NOT upload. You get a message that you are using the wrong format.
TEST 5: The file DOES NOT upload. You get a message that you are using the wrong format.
I d/l this file Joomla_4.2.2-Stable-Update_Package.tar.gz which i used in test 4 and renamed it to Joomla_4.2.2-Stable-Update_Package.zip
wrong package type message
TEST 6: Success!

avatar brianteeman
brianteeman - comment - 9 Sep 2022

PS your comment about needing to do drah n'drop is not required on windows
image

avatar nikosdion nikosdion - change - 9 Sep 2022
The description was changed
avatar nikosdion nikosdion - edited - 9 Sep 2022
avatar nikosdion nikosdion - change - 9 Sep 2022
The description was changed
avatar nikosdion nikosdion - edited - 9 Sep 2022
avatar nikosdion nikosdion - change - 9 Sep 2022
The description was changed
avatar nikosdion nikosdion - edited - 9 Sep 2022
avatar nikosdion
nikosdion - comment - 9 Sep 2022

TEST 3: The file DOES NOT upload. You get a message that you are using the wrong format. wrong package type message (but i think thats correct message and your expected result is wrong)

Yes, it was a typo. I fixed it in the PR description.

TEST 5: The file DOES NOT upload. You get a message that you are using the wrong format.

It took me a few re-reads but I realised that what you got is actually what you should be getting now that we changed the way PR works. Even though you uploaded a file with a ZIP extension its MIME type says it's a Gzip file so, yes, it should tell you that you're using the wrong format. I need to update the PR description about that.

PS your comment about needing to do drah n'drop is not required on windows

I have yet to see a real user using that drop-down but I have seen plenty use drag'n'drop. You also missed that drop-down yesterday yourself which tells me a lot about how “invisible” it is to real users ?

avatar nikosdion nikosdion - change - 9 Sep 2022
The description was changed
avatar nikosdion nikosdion - edited - 9 Sep 2022
avatar nikosdion
nikosdion - comment - 9 Sep 2022

There, I have edited the PR description. Now the test instructions reflect the code. If you can @brianteeman please check that the messages printed make sense for each case from a user's perspective. I am too close to the implementation now to make an objective judgement of that.

avatar brianteeman
brianteeman - comment - 9 Sep 2022

I have tested this item successfully on 1c9f344

acknowleding that the strings might be refined this is still a successful test


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38707.

avatar brianteeman brianteeman - test_item - 9 Sep 2022 - Tested successfully
avatar richard67 richard67 - alter_testresult - 15 Sep 2022 - brianteeman: Tested successfully
avatar RickR2H
RickR2H - comment - 20 Oct 2022

I used the pre build package to test. For some reason some of the language strings are not outputted. I noticed that the language strings are present in the language file com_joomlaupdate.ini. Also installing the right update package produces an error.

Here are my results:

Test 1: Error
You are trying to upload the "Full Package (.zip)" which can only be used to create new sites. You need to upload the "Upgrade Package (.zip)" file of the Joomla version you want to upgrade to.

Test 2: Error
You are trying to upload a file which is not in the ZIP format. The Joomla Update does not support the upgrade package files with .tar.gz and .tar.bz2 extensions. You need to upload the "Upgrade Package (.zip)" file of the Joomla version you want to upgrade to.

Test 3: Error
You are trying to upload the "Full Package (.zip)" which can only be used to create new sites. You need to upload the "Upgrade Package (.zip)" file of the Joomla version you want to upgrade to.

Test 4: Error
COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_NOTZIP

Test 5: Error
COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_FULLINSTALLATION_PREUPLOAD

Test 6: Error
COM_JOOMLAUPDATE_VIEW_UPLOAD_ERROR_FULLINSTALLATION_PREUPLOAD


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38707.

avatar nikosdion
nikosdion - comment - 31 Oct 2022

@RickR2H You need to clear your browser's cache.

avatar richard67 richard67 - alter_testresult - 4 Dec 2022 - brianteeman: Tested successfully
avatar richard67
richard67 - comment - 4 Dec 2022

@brianteeman I've restored your test result in the issue tracker so it's properly counted. Changes which invalidated the count were only the language string changes which you had requested. If you know some other PR where test results need to be restored, let me know.

@RickR2H Could you try again with all kinds of cache cleared, including browser cache? Thanks in advance.

avatar richard67
richard67 - comment - 4 Dec 2022

Will update the branch so we get new test packages built.

avatar richard67 richard67 - alter_testresult - 4 Dec 2022 - brianteeman: Tested successfully
avatar nikosdion nikosdion - change - 7 Dec 2022
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2022-12-07 12:24:42
Closed_By nikosdion
avatar nikosdion nikosdion - close - 7 Dec 2022
avatar nikosdion nikosdion - change - 7 Dec 2022
Status Closed New
Closed_Date 2022-12-07 12:24:42
Closed_By nikosdion
avatar nikosdion nikosdion - change - 7 Dec 2022
Status New Pending
avatar nikosdion nikosdion - reopen - 7 Dec 2022
avatar richard67
richard67 - comment - 7 Dec 2022

@brianteeman Could you test again? Thanks in advance.

avatar richard67 richard67 - test_item - 7 Dec 2022 - Tested successfully
avatar richard67
richard67 - comment - 7 Dec 2022

I have tested this item successfully on 76c52d0

Tested with success the described cases and a few more.

What was not working as described was the test with the tar.gz or tar.bz2 with extension changed to zip, i.e. the test which uses the MIME type verification by the browser, in my case Firefox. The reason for this is that the browser does not really do a MIME type check based on the content of the file but on the extension. I've verified this by renaming a JPEG image to "Joomla_4.2.6-rc2-dev-Development-Update_Package.zip" and adding an alert(file.type); to the JS. The type was "application/x-zip-compressed". As said, it was a renamed JPEG ?

So the PR works, only the browser is a bit stupid :-)


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38707.

avatar richard67
richard67 - comment - 7 Dec 2022

One remark in addition to my test result: In my opinion the checks for the file names are too restrictive.

They check for the file names to match the right, unmodified file names.

But when I download nightly build packages, I am used to add a date part to the end of the base name, e.g. Joomla_4.2.6-rc2-dev-Development-Full_Package_2022-12-07.zip or Joomla_4.2.6-rc2-dev-Development-Update_Package_2022-12-07.zip.

Other people might do the same but use a different scheme for that date part.

I think this should still be allowed, but this PR will inhibit to use these files.

I am sure I could provide the right regular expressions to allow such suffixes in any format but still checking the constant part of the file name right.

But this might be subject of discussion.

Therefore I don't suggest a change to this PR.

This PR here is a huge improvement for keeping people from doing silly things, and I want it to come forward.

When it will be merged, I will make a follow up PR to allow modifications at the end of the file's base name, which then can be discussed.

avatar jwaisner jwaisner - test_item - 8 Dec 2022 - Tested successfully
avatar jwaisner
jwaisner - comment - 8 Dec 2022

I have tested this item successfully on 76c52d0

Works for me. Encountered similar situation with FF that Richard did, but agree this is a huge improvement that can be improved upon.

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38707.

avatar jwaisner jwaisner - change - 8 Dec 2022
Status Pending Ready to Commit
avatar nikosdion
nikosdion - comment - 8 Dec 2022

I am not going to be contributing to this project anymore. I won't be replying to any questions or making any changes until then. I will close any outstanding PRs and delete their code on December 31st, 2022. Merge whatever you want until then.

avatar richard67 richard67 - test_item - 19 Dec 2022 - Not tested
avatar richard67
richard67 - comment - 19 Dec 2022

I have not tested this item.

Reverting my test result because I have investigated deeper. Will post more details later. For now just reverting my test so the PR goes back from RTC to pending so it is not merged.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38707.

avatar richard67 richard67 - change - 19 Dec 2022
Status Ready to Commit Pending
avatar richard67
richard67 - comment - 19 Dec 2022

Back to pending.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38707.

avatar richard67 richard67 - test_item - 19 Dec 2022 - Tested unsuccessfully
avatar richard67
richard67 - comment - 19 Dec 2022

I have tested this item ? unsuccessfully on 76c52d0

TEST 3: Use the Full Package TAR after changing its extension to .zip fails on all browsers on all OS which I have tested.

The reason is that browsers do not really determine the MIME type for an input field of type "file" by the file's content. They set the mime type according to the file name extension, at least if there is one. So it you rename the tar.gz or tar.bz2 or any other file like e.g. a GIF image file to a zip file, you get 'application/x-zip-compressed' on Windows and 'application/zip' on Linux (or vice versa, don't remember now). And if you rename the file to something else with a different extension, it will fail the check for the extension and so not run into the check for the type. So the check for the file.type in this line here is not doing anything: https://github.com/joomla/joomla-cms/pull/38707/files#diff-550b2e9757e1fef80e3714191e4f70f3dd9bd7441ff3e7679698de031551e346R24 .

When I had noticed that first, I thought it was just a known limitation by a broswer, so I thought it was accebtable, but further investigation has shown it doesn't depend on the browser or the OS.

That's why I have to correct my test result to a negative one.

The right fix would be to change the description of the PR by removing the "Make sure the user is uploading a ZIP file based on the file type reported by the browser." point of the client-side checks, removing TEST 3: ... from the testing instructions, and removing the || (file.type !== 'application/zip' && file.type !== 'application/x-zip-compressed') from the line of code mentioned above.

As the author of this PR has stated that he won't reply to any comments and not make any changes, I don't know what to do now: Force change this PR against the will of the author, or close it and replace it by a new one?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38707.

avatar nikosdion
nikosdion - comment - 19 Dec 2022

I won't have time to work on it tomorrow, I will try to take a look on Wednesday.

I definitely don't want to see Joomla pulling in Yet Another over-engineered, third party JavaScript library to do something that simple, quite possibly cocking up the chunked download in the process. Core updates are too important and affect everyone, including myself.

avatar richard67
richard67 - comment - 19 Dec 2022

I won't have time to work on it tomorrow, I will try to take a look on Wednesday.

That would be really much appreciated.

I definitely don't want to see Joomla pulling in Yet Another over-engineered, third party JavaScript library to do something that simple, quite possibly cocking up the chunked download in the process.

I fully agree. We should not use such kinds of third party libraries.

For now it would maybe be the best just to remove that type check like I suggested in my test result.

The PR still would keep people from accidentally uploading the wrong file.

Anything else, protecting against sabotage by people changing the file name extension of files, is a different task.

avatar nikosdion
nikosdion - comment - 22 Dec 2022

I got really sick, I could not take a look as I promised. The fun life of parents when the weather turns cold. Sigh. Hopefully sometime between Christmas and New Year's I will have the time and not be sick.

avatar nikosdion
nikosdion - comment - 23 Dec 2022

@richard67 I removed the MIME type check, replacing it with a signature-based ZIP file type detection which is far more reliable. I was able to successfully follow all of the tests in the PR like that on macOS. Tests with more Operating Systems are always welcome.

avatar richard67
richard67 - comment - 23 Dec 2022

@nikosdion Thanks. I will test later today or tomorrow. If you would unblock Brian, he could test, too. As long as he is blocked for commenting here, he can’t submit a test result with the issue tracker.

avatar nikosdion
nikosdion - comment - 23 Dec 2022

The only people I have blocked on my personal GitHub account are those who have chronically treated Joomla contributors and/or me personally with disrespect and contempt. Interacting with them is unproductive and toxic.

Nobody has been blocked in the heat of the moment. All of them have been given multiple chances, over several years, before being blocked.

I would only unblock someone if I receive an apology and the person commits to doing better. I have plenty of contact avenues, even for people who do not know my email address. My sites are linked to my GitHub profile and they both have a contact form.

Ultimately, it's the project's responsibility for enforcing its Code of Conduct and protecting its contributors from toxic people. Asking me to unblock toxic people and forcing me to interact with them doesn't make me feel safe contributing to this project.

avatar richard67
richard67 - comment - 24 Dec 2022

@nikosdion Sorry, it was me only. Blame me but not the project. I was not speaking for anybody else.

avatar nikosdion
nikosdion - comment - 24 Dec 2022

@richard67 No problem, I understood. I was just stating my point of view in more general terms so it's clear where I stand on the matter. Merry Christmas!

avatar richard67
richard67 - comment - 24 Dec 2022

@nikosdion I have just tested, and I've observed that it needs to adjust the testing instructions. Now with the last change for the zip signature check, I get for test "TEST 3" and "TEST 5" the message about wrong format and not the one about wrong package type. That means the expected results of these 2 tests should just be changed back to like they were before, i.e. the stroke through text is right again. Could you do that or shall I do it for you?

avatar richard67
richard67 - comment - 24 Dec 2022

P.S.: For completeness it would also need to add a 7th test with the full package zip renamed to the name of the update package zip so file type and extension are right but there is an installation/index.php inside.

P.P.S: The result of that test is the special message for this case, I've just tested that with success.

avatar brianteeman brianteeman - test_item - 24 Dec 2022 - Tested unsuccessfully
avatar nikosdion
nikosdion - comment - 24 Dec 2022

Yes, the test instructions do need an update as you said. Can you please do that? I'm helping my girls bake Christmas cookies atm :)

avatar richard67
richard67 - comment - 24 Dec 2022

@nikosdion I will update them and post my test result in some 30 minutes. I wish you a merry Christmas. Hopefully you won't need to give a GDPR consent on every cookie your girls are baking.

avatar nikosdion
nikosdion - comment - 24 Dec 2022

Appropriate consent was given by all data subjects :D Merry Christmas! ???

avatar richard67 richard67 - change - 24 Dec 2022
The description was changed
avatar richard67 richard67 - edited - 24 Dec 2022
avatar richard67 richard67 - change - 24 Dec 2022
The description was changed
avatar richard67 richard67 - edited - 24 Dec 2022
avatar richard67 richard67 - change - 24 Dec 2022
The description was changed
avatar richard67 richard67 - edited - 24 Dec 2022
avatar nikosdion
nikosdion - comment - 5 Mar 2023

Is there any interest in this PR or did I just waste my time?

avatar HLeithner
HLeithner - comment - 5 Mar 2023

Is there any interest in this PR or did I just waste my time?

if it's not taken by 4.3 (which I think it's too late) and 4.4 (which doesn't get new features, exceptions are possible by production I think) I would talk it for 5.0.

avatar nikosdion
nikosdion - comment - 6 Mar 2023

If it's going to 4.3 please let me know a.s.a.p. as it'll need rebasing. I have some time now but if you ask me after Easter things are getting a bit hairy.

avatar obuisard
obuisard - comment - 6 Mar 2023

Hi Nicholas @nikosdion, we are interested by the PR, but it's too late for 4.3, we froze beta 4 and release it on Tuesday and jumping into RC a week later. I would love to see this included into Joomla, as the uploads are prone to mistakes. Allon @laoneo, any thoughts?

avatar nikosdion nikosdion - change - 8 Mar 2023
Labels Added: ?
avatar laoneo
laoneo - comment - 8 Mar 2023

I would love to see this one in to the 4.x series. As 4.3 is in RC phase, can you rebase this one to the 4.4.-dev branch?

avatar nikosdion
nikosdion - comment - 8 Mar 2023

Will do!

avatar richard67
richard67 - comment - 8 Mar 2023

When this PR was made I first was very much in favour of it because I want the CMS to protect people from accidentally using the wrong file for upload & update.

But meanwhile I think it has several weak points:

  1. In past, when I have downloaded nightly builds for testing purpose, I have changed their name by adding a suffix to the base name with the date when it was built, e.g. Joomla_4.2.9-rc2-dev-Development-Update_Package_2023-03-08.zip. When this PR will be merged, this is not possible anymore. I will always have to rename them again and remove that suffix before I can use them.

  2. The PR does more than it should do. It shall protect people from accidentally uploading the wrong file, but the TEST 6: Rename the Full Package ZIP to the name of the Upgrade Package ZIP and use that renamed file is more than that. Such a renaming of the file would never be made by accident but by purpose. Catering for such hacking attempts make the code in this function unnecessarily complicated and so hard to maintain: https://github.com/joomla/joomla-cms/pull/38707/files#diff-617530abeea53181b5e5f641ba3906dcbf758238861e8a5281422722533d8532R1728 .

  3. The code mentioned with point 2 executes after the zip has been uploaded. This is not really nice if the upload takes longer on a slow connection.

All in all, for the reasons stated with points 2 and 3, we should only do a check for the right file name in the javascript and use a regex which allows to add any kind of suffix to the base name.

This would be sufficient to protect the user from choosing the wrong file by accident, which by the way can be any file, not only the full package, The user might by accident select any file from the same folder, and this may be a gif or jpeg or txt file or whatever.

Anything else beside a check for the name in the js would be trying to protect the user from hacking themselves, or trying to protect from hacked zip files, but this would be easily to circumvent with this PR. The hacker only has to give it the right name and make sure it doesn't contain an installation/index.php. So this PR will not really protect from hacking, and as said, for protecting from mistakes it simply does too much.

avatar brianteeman
brianteeman - comment - 8 Mar 2023

if we didnt generate the useless update tar files it would be even easier and simpler

avatar nikosdion
nikosdion - comment - 8 Mar 2023

@richard67 Please start re-reading the original issue from here #38702 (comment)

Then read the history of my commits and this PR.

As you can see, my original implementation was to check if it's a ZIP file and if it has the installation folder in it, as I had already explained. More to the point, I was AGAINST matching filenames.

I added the filename check because you were all stuck on it as being a necessary feature.

Do remember that this was never about hacking yourself. It was about preventing the upload of a. a tar file which cannot be used; and b. the full installation package which leads to a broken site as soon as the first files of the installation folder are extracted.

The server-side check is only meant as a failsafe, not as the primary method of preventing the wrong upload. It's the "what if, somehow, that JavaScript failed to execute for any reason we cannot possibly imagine" failsafe. All client-side checks MUST have a server-side equivalent.

So, you are all coming back to what I was saying back in September, when you were insisting I am wrong. At which point do I get an apology? I am waiting…

avatar brianteeman
brianteeman - comment - 8 Mar 2023

So, you are all coming back to what I was saying back in September, when you were insisting I am wrong. At which point do I get an apology? I am waiting…

what did I insist you did? i must be missing something.

This is an issue which has existed for years. It wasnt until I realised the commonality in a series of forum posts that I created the original issue and then brought it to the attention of a variety of people to get their input in an open collaborative manner.

avatar nikosdion
nikosdion - comment - 8 Mar 2023

@brianteeman Why are you replying to this? I was not talking about you. I was talking about the maintainers, at-mentioning Richard.

avatar richard67
richard67 - comment - 8 Mar 2023

I added the filename check because you were all stuck on it as being a necessary feature.

@nikosdion Where haven’t done that? The only change I had suggested besides code style was the removal of the not working mime type check.

avatar nikosdion
nikosdion - comment - 8 Mar 2023

@richard67 To clarify, Harald did it: #38702 (comment)

would check for the correct filename on upload, if people thinks they have to rename it then they should rename it that the update can understand for example:
Joomla_4.2.2-MYCUSTOMBUILD-Stable-Update_Package.zip or something like that

I was replying to you because you are the one who commented that the filename check is the wrong approach. I agree with that! I said so myself. Nobody in Production accepted this point in September (or at least nobody said so, which is the same for all intents and purposes), therefore my contribution had to make that change to be in line with the opinion expressed by Production.

Just to make it clear, it doesn't matter if a request for a feature or feature change comes from the department coordinator, a release lead, team lead, or team member. You are all holding an official position in the Production department. You speak for the project. You hold the power to approve or reject a contribution. When you say "jump" us volunteer contributors ask "how high", not "why".

Furthermore, you can't pretend the buck stops with the release lead because, as we've seen here, the release lead can simply ignore a PR they don't want to take responsibility for and kick it down to the next release lead. Not maliciously, but because they are overworked and, frankly, no matter what they do people are going to yell at them.

So here we are, finding myself again in the unsavoury position of having to ask for the equivalent of a hot-fix to a broken process: @laoneo @HLeithner and @bembelimen please hand me a PLT edict which describes what should and should not be in this contribution and I'll stick to it.

avatar HLeithner
HLeithner - comment - 2 May 2023

This pull request has been automatically rebased to 5.0-dev.

avatar nikosdion nikosdion - change - 10 May 2023
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2023-05-10 18:32:15
Closed_By nikosdion
Labels Added: Feature
avatar nikosdion nikosdion - close - 10 May 2023

Add a Comment

Login with GitHub to post a comment