Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkp/pkp-lib#9753 [stable-3_3_0] Update jquery, jquery-ui and chart.js to address security vulnerability reports #10167

Merged
merged 24 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
61ec3bd
pkp/pkp-lib#9753 [stable-3_3_0] Update jquery version from 3.5.1 to 3…
blesildaramirez Jul 5, 2024
f8534d6
pkp/pkp-lib#9753 [stable-3_3_0] Update jquery validation from v1.11.1…
blesildaramirez Jul 5, 2024
18ec6b9
pkp/pkp-lib#9753 [stable-3_3_0] Remove components/jqueryui as a compo…
blesildaramirez Jul 5, 2024
3558cc6
pkp/pkp-lib#9753 [stable-3_3_0] Manually add jquery-ui v1.13.3 to jqu…
blesildaramirez Jul 5, 2024
037c3f4
pkp/pkp-lib#9753 [stable-3_3_0] Move import of jqueryui from vendors …
blesildaramirez Jul 5, 2024
5bebaf5
pkp/pkp-lib#9753 [stable-3_3_0] Remove jquery-ui local files
blesildaramirez Jul 10, 2024
22c2a69
pkp/pkp-lib#9753 [stable-3_3_0] Add jquery-ui dependency to composer …
blesildaramirez Jul 10, 2024
11f1508
pkp/pkp-lib#9753 [stable-3_3_0] Remove jquery-validation local files
blesildaramirez Jul 10, 2024
281ba42
pkp/pkp-lib#9753 [stable-3_3_0] Add jquery-validation to composer fro…
blesildaramirez Jul 10, 2024
db32b3b
pkp/pkp-lib#9753 [stable-3_3_0] Remove jquery, jquery-ui and jquery-v…
blesildaramirez Jul 12, 2024
5e1c3d5
pkp#9753 [stable-3_3_0] Undo updates to jquery, jquery-ui and jquery-…
blesildaramirez Jul 12, 2024
adf20a8
pkp/pkp-lib#9753 [stable-3_3_0] Add js/lib/jquery/plugins/validate/ p…
blesildaramirez Jul 12, 2024
6586b70
pkp/pkp-lib#9753 [stable-3_3_0] Add script to copy jquery and jqueryu…
blesildaramirez Jul 18, 2024
e056252
pkp/pkp-lib#9753 Add composer custom repositories for jquery-ui, jque…
blesildaramirez Aug 12, 2024
a7e43ff
pkp/pkp-lib#9753 Update composer script when copying jqueryui and jqu…
blesildaramirez Aug 12, 2024
b162b82
pkp/pkp-lib#9753 Update FileManager mkdir function to check if folder…
blesildaramirez Aug 14, 2024
09f3a5b
pkp/pkp-lib#9753 Update ComposerScript to use FileManager to copy fil…
blesildaramirez Aug 14, 2024
d1d12c0
pkp/pkp-lib#9753 Undo unintended version bump for plugin-api-version
blesildaramirez Aug 14, 2024
a3a0cb7
pkp/pkp-lib#9753 Update returned value when directory already exists …
blesildaramirez Aug 15, 2024
70ed240
pkp/pkp-lib#9753 Resolve unexpected throw statement on ComposerScript…
blesildaramirez Aug 15, 2024
3624d79
pkp/pkp-lib#9753 Update path when requiring tools/bootstrap.inc.php
blesildaramirez Aug 15, 2024
6270fa6
pkp/pkp-lib#9753 Update ComposerScript to use native functions to cop…
blesildaramirez Aug 21, 2024
1e227f9
pkp/pkp-lib#9753 Undo check of is_dir on mkdir function in FileManager
blesildaramirez Aug 21, 2024
bf243e1
pkp/pkp-lib#9753 Update message log if creating dir fails in Composer…
blesildaramirez Aug 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ te_ST/
lib/tinymce/jscripts/tiny_mce/*.gz
lib/vendor
lib/components
.DS_Store
.DS_Store
js/lib/jquery/plugins/validate/
54 changes: 54 additions & 0 deletions classes/dev/ComposerScript.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
/**
* @file classes/dev/ComposerScript.php
*
* Copyright (c) 2024 Simon Fraser University
* Copyright (c) 2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class ComposerScript
*
* @brief Custom composer scripts to run post installs/updates
*/

namespace PKP\dev;

use Exception;

require_once '../../tools/bootstrap.inc.php';
import('lib.pkp.classes.file.FileManager');

class ComposerScript
{
/**
* A post-install-cmd custom composer script that
* copies composer installs from repositories
* to the correct/existing directories of the following dependencies:
* jquery-ui and jquery validation
*/
public static function copyVendorAssets(): void
{
$fileManager = new \FileManager();
$vendorBaseDir = __DIR__ . '/../../lib/vendor';
$jsPluginsDir = __DIR__ . '/../../js/lib';

$source = [
'jquery-ui.js' => $vendorBaseDir . '/jquery/ui/dist/jquery-ui.js',
'jquery-ui.min.js' => $vendorBaseDir . '/jquery/ui/dist/jquery-ui.min.js',
'jquery-validate' => $vendorBaseDir . '/jquery/validation/dist'
];

$dest = [
'jquery-ui.js' => $vendorBaseDir . '/components/jqueryui/jquery-ui.js',
'jquery-ui.min.js' => $vendorBaseDir . '/components/jqueryui/jquery-ui.min.js',
'jquery-validate' => $jsPluginsDir . '/jquery/plugins/validate'
];

// jQuery UI
$fileManager->copyFile($source['jquery-ui.js'], $dest['jquery-ui.js']) || throw new Exception('Failed to copy jquery-ui.js to destination folder');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tagging @asmecher to confirm if it's ok this breaking change, regarding the required permissions (https://docs.pkp.sfu.ca/admin-guide/en/troubleshooting#configuring-file-permissions).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script is run by Composer during dependency installation, not when OJS is installed and in production. For the most part, it'll be run from the package build script when I build a release, and for folks that host OJS from git it'll be run early in the installation process from the same terminal that's used to e.g. clone the code into place. I don't think the production file permission document is relevant. (This is also why I recommended not using FileManager -- it's intended for execution in the bootstrapped PKP environment, not elsewhere.)

$fileManager->copyFile($source['jquery-ui.min.js'], $dest['jquery-ui.min.js']) || throw new Exception('Failed to copy jquery-ui.min.js to destination folder');

// jQuery Validation
$fileManager->copyDir($source['jquery-validate'], $dest['jquery-validate']) || throw new Exception('Failed to copy jquery-validate to destination folder');
}
}
5 changes: 5 additions & 0 deletions classes/file/FileManager.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,11 @@ function deleteByPath($filePath) {
* @return boolean returns true if successful
*/
function mkdir($dirPath, $perms = null) {
if (is_dir($dirPath)) {
// Directory already exists, no need to create it
return true;
}

if ($perms !== null) {
return mkdir($dirPath, $perms);
} else {
Expand Down
42 changes: 39 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"require": {
"ralouphie/getallheaders": "*",
"components/jqueryui": "1.*",
"components/jquery": "^3.5",
"wikimedia/less.php": "3.*",
"phpmailer/phpmailer": "6.*",
"smarty/smarty": "^4.3",
Expand All @@ -25,7 +23,10 @@
"staudenmeir/laravel-upsert": "^1.3",
"cweagans/composer-patches": "^1.7",
"composer/semver": "*",
"php81_bc/strftime": "^0.5.0"
"php81_bc/strftime": "^0.5.0",
"components/jquery": "3.7.1",
"jquery/ui": "1.13.3",
"jquery/validation": "1.19.5"
jonasraoni marked this conversation as resolved.
Show resolved Hide resolved
},
"require-dev": {
"phpunit/phpunit": "~9",
Expand All @@ -41,10 +42,40 @@
"cweagans/composer-patches": true
}
},
"scripts": {
"post-install-cmd": [
"@copyVendorAssets"
],
"copyVendorAssets": [
"PKP\\dev\\ComposerScript::copyVendorAssets"
]
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/asmecher/ADOdb"
},
{
"type": "package",
"package": {
"name": "jquery/ui",
"version": "1.13.3",
"dist": {
"url": "https://registry.npmjs.org/jquery-ui/-/jquery-ui-1.13.3.tgz",
"type": "tar"
}
}
},
{
"type": "package",
"package": {
"name": "jquery/validation",
"version": "1.19.5",
"dist": {
"url": "https://registry.npmjs.org/jquery-validation/-/jquery-validation-1.19.5.tgz",
"type": "tar"
}
}
}
],
"extra": {
Expand Down Expand Up @@ -85,5 +116,10 @@
"Apply strftime locale patch": "lib/strftime-locale-patch.diff"
}
}
},
"autoload": {
"psr-4": {
"PKP\\": "classes/"
}
}
}
120 changes: 30 additions & 90 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading