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

Draft: TUF Implementation #20

Closed
wants to merge 163 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
163 commits
Select commit Hold shift + click to select a range
f765340
Set up tuf_updates mysql queries
fancyFranci Mar 20, 2022
fd82ae8
Fix table structure for TUF metadatas
bembelimen Mar 20, 2022
f43a95e
Change ordering of timestamp
bembelimen Mar 20, 2022
68ec0b1
Add allow null
bembelimen Mar 20, 2022
37d2341
Fix null values
bembelimen Mar 20, 2022
5909617
Merge pull request #2 from bembelimen/tuf/db-structure
fancyFranci Mar 20, 2022
351bb65
Add TUF databaseStorage
fancyFranci Mar 20, 2022
8e5bffb
Merge branch 'tuf-client' of github.com:fancyFranci/joomla-cms into t…
fancyFranci Mar 20, 2022
e69ec81
Create tuf table
fancyFranci Mar 20, 2022
7571ead
Add TUF exceptions
fancyFranci Mar 20, 2022
702d212
Implement all ArrayAccess methods
bembelimen Mar 20, 2022
69055f3
Merge pull request #3 from bembelimen/tuf/databasestorage
fancyFranci Mar 20, 2022
e83a573
Set TUF exception
fancyFranci Mar 20, 2022
798bc72
implement basic version of the tuf validator
Mar 23, 2022
0a3f0b4
remove php-tuf library
Mar 23, 2022
b06ed49
What zero-24 says
fancyFranci Jun 10, 2022
5b8e736
Merge branch '4.2-dev' into tuf-client
fancyFranci Jun 10, 2022
130e62d
Merge branch '4.2-dev' into validator
Jun 10, 2022
9b62a03
Merge remote-tracking branch 'magnus-tuf/validator' into tuf-client
fancyFranci Jun 10, 2022
133eacd
Merge pull request #3 from fancyFranci/tuf-client
bembelimen Jun 10, 2022
f81e015
Update drone hash
bembelimen Jun 10, 2022
7934f52
Add symfony/validator into composer.lock
bembelimen Jun 10, 2022
7fd25c8
Codestyle fixes
bembelimen Jun 10, 2022
dd22ede
Fix code style
bembelimen Jun 10, 2022
93fcbfb
wip tuf
nielsnuebel Jun 11, 2022
effde12
Change GuzzleFilteFetcher to HttpFileFetcher
nielsnuebel Jun 11, 2022
3b057a8
add missing semicolon
nielsnuebel Jun 11, 2022
1da619b
initial wip
zero-24 Jun 11, 2022
f6ac9c5
doc block updates
zero-24 Jun 11, 2022
5585d32
wip php minimum & stability
zero-24 Jun 11, 2022
f35a4a9
wip stability validation
zero-24 Jun 11, 2022
59eb40c
property_exists and variable names
zero-24 Jun 11, 2022
ee8d1e9
added tests and tweaks
SniperSister Jun 11, 2022
36010be
Merge pull request #9 from joomla-projects/snipersister/ConstraintsCh…
zero-24 Jun 11, 2022
9965451
wip
nielsnuebel Jun 11, 2022
caecbf3
Merge pull request #8 from joomla-projects/ConstraintsCHecker
nielsnuebel Jun 12, 2022
6086b2d
throw exception in installer update model when update site is tuf
Jun 12, 2022
d1f622b
Enqueue message instead of throwing an exception
Jun 12, 2022
88a99f7
move jhttp file fetcher into CMS library, update TUF client fork branch
SniperSister Jun 12, 2022
2442045
change stabilityTags to stability
nielsnuebel Jun 12, 2022
0bed04f
wip tuf
nielsnuebel Jun 12, 2022
393f7ed
cs fixes, tweaks
SniperSister Jun 12, 2022
3c20851
Apply suggestions from code review
SniperSister Jun 12, 2022
9805efa
cs fixes
SniperSister Jun 12, 2022
a4e1e21
Update composer.json
SniperSister Jun 12, 2022
311051b
Update composer.json
SniperSister Jun 12, 2022
c594935
Update tests/Unit/Libraries/Cms/TUF/HttpFileFetcherTest.php
SniperSister Jun 12, 2022
b749a32
Update tests/Unit/Libraries/Cms/TUF/HttpFileFetcherTest.php
SniperSister Jun 12, 2022
3e65cc2
Apply suggestions from code review
SniperSister Jun 12, 2022
b0c0097
cs fixes
SniperSister Jun 12, 2022
b416c8a
Merge branch 'snipersister/tuf-http-client' of github.com:joomla-proj…
SniperSister Jun 12, 2022
48f0b34
cs fixes
SniperSister Jun 12, 2022
b664303
Merge pull request #11 from joomla-projects/snipersister/tuf-http-client
SniperSister Jun 12, 2022
cd1eb5f
fix baseuri usage
SniperSister Jun 12, 2022
b4f00c0
Merge remote-tracking branch 'upstream/tuf' into validator
nielsnuebel Jun 12, 2022
271c544
remove unused import
Jun 12, 2022
b28fc93
implement HttpFileFetcher
nielsnuebel Jun 12, 2022
ff330d3
Update TufAdapter.php
zero-24 Jun 12, 2022
a4d8b47
remove typehint for paramater to support php 7.2.5
nielsnuebel Jun 12, 2022
dc9bcc7
Merge branch 'nielsnuebel/tuf' of github.com:joomla-projects/joomla-t…
nielsnuebel Jun 12, 2022
258a290
Update ConstraintCheckerTest.php
zero-24 Jun 12, 2022
cf6c1a3
remove whitespace
nielsnuebel Jun 12, 2022
8941c23
Merge branch 'nielsnuebel/tuf' of github.com:joomla-projects/joomla-t…
nielsnuebel Jun 12, 2022
c5c8f42
Update ConstraintChecker.php
zero-24 Jun 12, 2022
5f175af
Apply suggestions from code review
nielsnuebel Jun 12, 2022
4ba32cc
Merge pull request #10 from MagnusSinger/um-change
fancyFranci Sep 17, 2022
b930db6
Merge branch 'tuf' into nielsnuebel/tuf
fancyFranci Sep 17, 2022
3b4f8dc
Merge pull request #12 from joomla-projects/nielsnuebel/tuf
fancyFranci Sep 17, 2022
52b59d3
TufValidation add quoteName on delete query (#13)
Sep 17, 2022
d6bb842
Convert to PSR12 code style (#15)
fancyFranci Sep 17, 2022
16108c1
Add error messages (#14)
fancyFranci Sep 17, 2022
4def416
Merge branch '4.2-dev' of https://github.com/joomla-projects/joomla-t…
fancyFranci Sep 17, 2022
e1cfeb4
Continue integration of TUF into Joomla (#16)
Sep 18, 2022
5a0341f
Merge remote-tracking branch 'upstream/5.0-dev' into tuf
SniperSister Jun 30, 2023
86b583a
add file exists check in downloadPackage
nielsnuebel Jun 30, 2023
26d4cb8
reset to main tuf repo
SniperSister Jun 30, 2023
2e872d5
Merge pull request #1 from joomla-projects/snipersister/tuf-j5
tfeuerst Jun 30, 2023
63deea8
WIp commit of compatible interfaces
SniperSister Jun 30, 2023
a6baf3f
hotfix data fetching
SniperSister Jun 30, 2023
1708545
add additional catch case
SniperSister Jul 1, 2023
a3f6749
Add TUF Debug Message
nielsnuebel Jul 1, 2023
f009732
Remove PHPUnit methods
nielsnuebel Jul 1, 2023
3278179
Merge branch 'snipersister/tuf-j5' of github.com:tfeuerst/joomla-tuf …
Jul 1, 2023
695d8ca
Provide patch to drop patch level for php-tuf via composer-patches
Jul 1, 2023
792a4d0
Merge pull request #17 from tfeuerst/snipersister/tuf-j5
SniperSister Jul 1, 2023
4656fb3
adjust database storage handling
SniperSister Jul 1, 2023
0c34ae8
Merge branch 'snipersister/tuf-j5' of github.com:joomla-projects/joom…
SniperSister Jul 1, 2023
076ae0d
fix notices
SniperSister Jul 1, 2023
7ecf711
Patch for proper sorting of canonical json in php-tuf
Jul 1, 2023
0d59113
Merge pull request #18 from tfeuerst/snipersister/tuf-j5
SniperSister Jul 1, 2023
9c16fad
write hashsum information from tuf into update object
SniperSister Jul 1, 2023
4558bbb
Merge branch 'snipersister/tuf-j5' of github.com:joomla-projects/joom…
SniperSister Jul 1, 2023
765e023
fix data format
SniperSister Jul 1, 2023
35ceeb7
Fix invalid canonical JSON of TargetsMetadata in php-tuf
Jul 1, 2023
ad6714d
Merge pull request #19 from tfeuerst/snipersister/tuf-j5
SniperSister Jul 2, 2023
9794793
update repo url
SniperSister Jul 2, 2023
4daa658
Merge branch 'snipersister/tuf-j5' of github.com:joomla-projects/joom…
SniperSister Jul 2, 2023
2905f4c
cleanup update model
SniperSister Jul 2, 2023
bd37751
Merge remote-tracking branch 'upstream/5.0-dev' into snipersister/tuf-j5
SniperSister Jul 2, 2023
5235f8d
cleanup branch
SniperSister Jul 2, 2023
66eea9f
further cleanup
SniperSister Jul 2, 2023
105c5a1
refactor update class and add support for update channels
SniperSister Jul 2, 2023
0d79cab
Merge remote-tracking branch 'upstream/5.1-dev' into snipersister/tuf-j5
SniperSister Dec 8, 2023
2dbbdc5
resolve comflicts
SniperSister Dec 8, 2023
6cb18f2
downgrade to pinned client version
SniperSister Dec 8, 2023
e6cd7fa
adjust loader to return promise
SniperSister Dec 8, 2023
25e1290
update repo path
SniperSister Dec 8, 2023
c8b7823
cs fix
SniperSister Dec 8, 2023
cbcd846
move update class
SniperSister Dec 8, 2023
2bfe797
restore channels
SniperSister Dec 8, 2023
97d44e7
Apply suggestions from code review
SniperSister Dec 8, 2023
100caed
apply suggestions from code review
SniperSister Dec 8, 2023
eb30306
fix call
SniperSister Dec 8, 2023
13b515e
cleanup
SniperSister Dec 9, 2023
ec8262d
Remove "nochange" update channel
bembelimen Dec 9, 2023
bb110c6
Use single quotes
bembelimen Dec 9, 2023
f643011
Use early return and no regex check
bembelimen Dec 9, 2023
cecaae6
Update libraries/src/Updater/Adapter/TufAdapter.php
bembelimen Dec 9, 2023
96c5cef
Fix TufFetcher rollback and use DI
bembelimen Dec 9, 2023
591827d
Use single quotes
bembelimen Dec 9, 2023
cd617dc
Merge branch 'snipersister/tuf-j5' of https://github.com/joomla-proje…
bembelimen Dec 9, 2023
2ddac30
added missing execute call
SniperSister Dec 9, 2023
28cb249
Merge branch 'snipersister/tuf-j5' of github.com:joomla-projects/joom…
SniperSister Dec 9, 2023
d8dd59f
Go back to the default behaviour of having a detailsUrl when updating
bembelimen Dec 9, 2023
ae44417
Implement TUF live parser
bembelimen Dec 9, 2023
eaff5fd
Fix TUF cleanup
bembelimen Dec 9, 2023
4b33268
Update root key
bembelimen Dec 9, 2023
73b521e
Merge branch 'snipersister/tuf-j5' of https://github.com/joomla-proje…
bembelimen Dec 9, 2023
05d47f1
improve seperation of concerncs
SniperSister Dec 9, 2023
8bee440
Map channels zu specific versions
bembelimen Dec 9, 2023
2d1d967
Merge branch 'snipersister/tuf-j5' of https://github.com/joomla-proje…
bembelimen Dec 9, 2023
670ee45
Fix update channel
bembelimen Dec 9, 2023
e370fe8
Fix wrong check
bembelimen Dec 9, 2023
038a335
Fix data format
bembelimen Dec 9, 2023
8815e21
Use correct download URL
bembelimen Dec 9, 2023
4bf7b2b
Update root key postgresql (#22)
LadySolveig Dec 10, 2023
295a96c
use tuf client to-refetch core update information, improve soc
SniperSister Dec 10, 2023
9d6a481
revert changes
SniperSister Dec 10, 2023
11386a2
cs fix
SniperSister Dec 10, 2023
c98ab26
ensure that the shown version and the downloaded versions match
SniperSister Dec 10, 2023
bc481c7
Comment typos
brianteeman Jan 6, 2024
b58b7cc
Lang String
brianteeman Jan 6, 2024
9ecfe84
more
brianteeman Jan 6, 2024
5301ba6
Merge pull request #23 from brianteeman/lang
SniperSister Jan 27, 2024
5f26aa0
Merge pull request #24 from brianteeman/typos
SniperSister Jan 27, 2024
78f2d37
Added test case for databasestorage class
SniperSister Jan 27, 2024
4e29938
Added test for httploader class
SniperSister Jan 27, 2024
b03fd02
Added test cases for tuf adapter
SniperSister Jan 27, 2024
f2dfc6e
use forked TUF client and remove composer patches
SniperSister Jan 27, 2024
9c41012
cs fixes
SniperSister Jan 27, 2024
e092f8d
cs fixes
SniperSister Jan 27, 2024
a3f0ff4
Merge remote-tracking branch 'upstream/5.1-dev' into snipersister/tuf-j5
SniperSister Jan 27, 2024
f30c4ec
update system tests
SniperSister Jan 27, 2024
87ed8df
added system test for both cases
SniperSister Jan 27, 2024
0d8c3e9
fix codestyles
SniperSister Jan 27, 2024
91a0676
update base sql files
SniperSister Jan 28, 2024
4874fab
fix test
SniperSister Jan 28, 2024
0683f95
cs fix
SniperSister Jan 28, 2024
037b860
fix final repo config
SniperSister Feb 1, 2024
e1b7a13
fix posgres inserts
SniperSister Feb 2, 2024
95edb75
fix postgres column name
SniperSister Feb 2, 2024
8662e0e
fix missing query for updates_sites table
LadySolveig Feb 9, 2024
36b08ea
Merge pull request #25 from LadySolveig/snipersister/tuf5/sql-update
SniperSister Feb 9, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--
SniperSister marked this conversation as resolved.
Show resolved Hide resolved
-- Table structure for table `#__tuf_metadata`
--

CREATE TABLE IF NOT EXISTS `#__tuf_metadata` (
`id` int NOT NULL AUTO_INCREMENT,
`update_site_id` int DEFAULT 0,
`root` text DEFAULT NULL,
`targets` text DEFAULT NULL,
`snapshot` text DEFAULT NULL,
`timestamp` text DEFAULT NULL,
`mirrors` text DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci COMMENT='Secure TUF Updates';

-- --------------------------------------------------------
INSERT INTO `#__tuf_metadata` (`update_site_id`, `root`)
VALUES ((SELECT ue.`update_site_id` FROM `#__update_sites_extensions` AS ue JOIN `#__extensions` AS e ON (e.`extension_id` = ue.`extension_id`) WHERE e.`type`='file' AND e.`element`='joomla'), '{"signed":{"_type":"root","spec_version":"1.0","version":2,"expires":"2025-03-02T11:22:17Z","keys":{"07eb082f367c034a95878687f6648aa76d93652b6ee73e58817053d89af6c44f":{"keytype":"ed25519","scheme":"ed25519","keyid_hash_algorithms":["sha256","sha512"],"keyval":{"public":"9b2af2d9b9727227735253d795bd27ea8f0e294a5f3603e822dc5052b44802b9"}},"1b1b1dd55b2c1c7258714cf1c1ae06f23e4607b28c762d016a9d81c48ffe5669":{"keytype":"ed25519","scheme":"ed25519","keyid_hash_algorithms":["sha256","sha512"],"keyval":{"public":"a18e5ebabc19d5d5984b601a292ece61ba3662ab2d071dc520da5bd4f8948799"}},"2dcaf3d0e552f150792f7c636d45429246dcfa34ac35b46a44f5c87cd17d457e":{"keytype":"ed25519","scheme":"ed25519","keyid_hash_algorithms":["sha256","sha512"],"keyval":{"public":"cb0a7a131961a20edea051d6dc2b091fb650bd399bd8514adb67b3c60db9f8f9"}},"31dd7c7290d664c9b88c0dead2697175293ea7df81b7f24153a37370fd3901c3":{"keytype":"ed25519","scheme":"ed25519","keyid_hash_algorithms":["sha256","sha512"],"keyval":{"public":"589d029a68b470deff1ca16dbf3eea6b5b3fcba0ae7bb52c468abc7fb058b2a2"}},"9e41a9d62d94c6a1c8a304f62c5bd72d84a9f286f27e8327cedeacb09e5156cc":{"keytype":"ed25519","scheme":"ed25519","keyid_hash_algorithms":["sha256","sha512"],"keyval":{"public":"6043c8bacc76ac5c9750f45454dd865c6ca1fc57d69e14cc192cfd420f6a66a9"}}},"roles":{"root":{"keyids":["1b1b1dd55b2c1c7258714cf1c1ae06f23e4607b28c762d016a9d81c48ffe5669","2dcaf3d0e552f150792f7c636d45429246dcfa34ac35b46a44f5c87cd17d457e"],"threshold":1},"snapshot":{"keyids":["07eb082f367c034a95878687f6648aa76d93652b6ee73e58817053d89af6c44f","2dcaf3d0e552f150792f7c636d45429246dcfa34ac35b46a44f5c87cd17d457e"],"threshold":1},"targets":{"keyids":["31dd7c7290d664c9b88c0dead2697175293ea7df81b7f24153a37370fd3901c3"],"threshold":1},"timestamp":{"keyids":["9e41a9d62d94c6a1c8a304f62c5bd72d84a9f286f27e8327cedeacb09e5156cc"],"threshold":1}},"consistent_snapshot":true},"signatures":[{"keyid":"2dcaf3d0e552f150792f7c636d45429246dcfa34ac35b46a44f5c87cd17d457e","sig":"2a225a560ec0837b721d4c5e379fedbd3c7c9079a94e6b31e47e0184c8b95421b6036b4286c5d90f29ab4c468d79a712fdb65e96511394ceb3aa8e2b3983a501"},{"keyid":"1b1b1dd55b2c1c7258714cf1c1ae06f23e4607b28c762d016a9d81c48ffe5669","sig":"8ce0b2a7bdc1e6dcba12081f440510df0a593c072dcf591631c2dd0f456844a7da63be8e8ac31ffbddf42641fde84dc733a336031d182c2163b4c1eaf2117005"}]}');

-----------------------------------------------------------
UPDATE `#__update_sites`
SET `type` = 'tuf', `location` = 'https://update.joomla.org/cms/'
WHERE `update_site_id` = (SELECT ue.`update_site_id` FROM `#__update_sites_extensions` AS ue JOIN `#__extensions` AS e ON (e.`extension_id` = ue.`extension_id`) WHERE e.`type`='file' AND e.`element`='joomla');
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--
-- Table structure for table "#__tuf_metadata"
--

CREATE TABLE IF NOT EXISTS "#__tuf_metadata" (
"id" serial NOT NULL,
"update_site_id" bigint DEFAULT 0 NOT NULL,
"root" text DEFAULT NULL,
"targets" text DEFAULT NULL,
"snapshot" text DEFAULT NULL,
"timestamp" text DEFAULT NULL,
"mirrors" text DEFAULT NULL,
PRIMARY KEY ("id")
);

COMMENT ON TABLE "#__tuf_metadata" IS 'Secure TUF Updates';

INSERT INTO "#__tuf_metadata" ("update_site_id", "root")
VALUES (1, '{"signed":{"_type":"root","spec_version":"1.0","version":2,"expires":"2025-03-02T11:22:17Z","keys":{"07eb082f367c034a95878687f6648aa76d93652b6ee73e58817053d89af6c44f":{"keytype":"ed25519","scheme":"ed25519","keyid_hash_algorithms":["sha256","sha512"],"keyval":{"public":"9b2af2d9b9727227735253d795bd27ea8f0e294a5f3603e822dc5052b44802b9"}},"1b1b1dd55b2c1c7258714cf1c1ae06f23e4607b28c762d016a9d81c48ffe5669":{"keytype":"ed25519","scheme":"ed25519","keyid_hash_algorithms":["sha256","sha512"],"keyval":{"public":"a18e5ebabc19d5d5984b601a292ece61ba3662ab2d071dc520da5bd4f8948799"}},"2dcaf3d0e552f150792f7c636d45429246dcfa34ac35b46a44f5c87cd17d457e":{"keytype":"ed25519","scheme":"ed25519","keyid_hash_algorithms":["sha256","sha512"],"keyval":{"public":"cb0a7a131961a20edea051d6dc2b091fb650bd399bd8514adb67b3c60db9f8f9"}},"31dd7c7290d664c9b88c0dead2697175293ea7df81b7f24153a37370fd3901c3":{"keytype":"ed25519","scheme":"ed25519","keyid_hash_algorithms":["sha256","sha512"],"keyval":{"public":"589d029a68b470deff1ca16dbf3eea6b5b3fcba0ae7bb52c468abc7fb058b2a2"}},"9e41a9d62d94c6a1c8a304f62c5bd72d84a9f286f27e8327cedeacb09e5156cc":{"keytype":"ed25519","scheme":"ed25519","keyid_hash_algorithms":["sha256","sha512"],"keyval":{"public":"6043c8bacc76ac5c9750f45454dd865c6ca1fc57d69e14cc192cfd420f6a66a9"}}},"roles":{"root":{"keyids":["1b1b1dd55b2c1c7258714cf1c1ae06f23e4607b28c762d016a9d81c48ffe5669","2dcaf3d0e552f150792f7c636d45429246dcfa34ac35b46a44f5c87cd17d457e"],"threshold":1},"snapshot":{"keyids":["07eb082f367c034a95878687f6648aa76d93652b6ee73e58817053d89af6c44f","2dcaf3d0e552f150792f7c636d45429246dcfa34ac35b46a44f5c87cd17d457e"],"threshold":1},"targets":{"keyids":["31dd7c7290d664c9b88c0dead2697175293ea7df81b7f24153a37370fd3901c3"],"threshold":1},"timestamp":{"keyids":["9e41a9d62d94c6a1c8a304f62c5bd72d84a9f286f27e8327cedeacb09e5156cc"],"threshold":1}},"consistent_snapshot":true},"signatures":[{"keyid":"2dcaf3d0e552f150792f7c636d45429246dcfa34ac35b46a44f5c87cd17d457e","sig":"2a225a560ec0837b721d4c5e379fedbd3c7c9079a94e6b31e47e0184c8b95421b6036b4286c5d90f29ab4c468d79a712fdb65e96511394ceb3aa8e2b3983a501"},{"keyid":"1b1b1dd55b2c1c7258714cf1c1ae06f23e4607b28c762d016a9d81c48ffe5669","sig":"8ce0b2a7bdc1e6dcba12081f440510df0a593c072dcf591631c2dd0f456844a7da63be8e8ac31ffbddf42641fde84dc733a336031d182c2163b4c1eaf2117005"}]}');

UPDATE "#__update_sites"
SET "type" = 'tuf', "location" = 'https://update.joomla.org/cms/'
WHERE "update_site_id" = 1;
17 changes: 17 additions & 0 deletions administrator/components/com_installer/src/Model/UpdateModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,23 @@ public function update($uids, $minimumStability = Updater::STABILITY_STABLE)
continue;
}

$app = Factory::getApplication();
$db = $this->getDatabase();
$query = $db->getQuery(true)
->select('type')
->from('#__update_sites')
->where($db->quoteName('id') . ' = :id')
->bind(':id', $instance->update_site_id, ParameterType::INTEGER);

$updateSiteType = (string) $db->setQuery($query)->loadResult();

// Tuf is currently only supported for Joomla core
if ($updateSiteType === 'tuf') {
$app->enqueueMessage(Text::_('JLIB_INSTALLER_TUF_NOT_AVAILABLE'), 'error');

return;
}

$update->loadFromXml($instance->detailsurl, $minimumStability);

// Find and use extra_query from update_site if available
Expand Down
1 change: 0 additions & 1 deletion administrator/components/com_joomlaupdate/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
validate="options"
>
<!-- Note: Changed the values lts to default and sts to next with 3.4.0 -->
<!-- Eliminated the 'nochange' option with 3.4.0 -->
<!-- All invalid/unsupported/obsolete options equated to default in code with 3.4.0 -->
<option value="default">COM_JOOMLAUPDATE_CONFIG_UPDATESOURCE_DEFAULT</option>
<option value="next">COM_JOOMLAUPDATE_CONFIG_UPDATESOURCE_NEXT</option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,24 @@ public function download()
$message = null;
$messageType = null;

// The versions mismatch
if ($result['version'] !== $this->input->get('targetVersion')) {
$message = Text::_('COM_JOOMLAUPDATE_VIEW_UPDATE_VERSION_WRONG');
$messageType = 'error';
$url = 'index.php?option=com_joomlaupdate';

$this->app->setUserState('com_joomlaupdate.file', null);
$this->setRedirect($url, $message, $messageType);

try {
Log::add($message, Log::ERROR, 'Update');
} catch (\RuntimeException $exception) {
// Informational log only
}

return;
}

// The validation was not successful so stop.
if ($result['check'] === false) {
$message = Text::_('COM_JOOMLAUPDATE_VIEW_UPDATE_CHECKSUM_WRONG');
Expand Down
55 changes: 36 additions & 19 deletions administrator/components/com_joomlaupdate/src/Model/UpdateModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Table\Tuf as TufMetadata;
use Joomla\CMS\Updater\Update;
use Joomla\CMS\Updater\Updater;
use Joomla\CMS\User\UserHelper;
Expand Down Expand Up @@ -87,12 +88,7 @@ public function applyUpdateSite()
// Determine the intended update URL.
$params = ComponentHelper::getParams('com_joomlaupdate');

switch ($params->get('updatesource', 'nochange')) {
// "Minor & Patch Release for Current version AND Next Major Release".
SniperSister marked this conversation as resolved.
Show resolved Hide resolved
case 'next':
$updateURL = 'https://update.joomla.org/core/sts/list_sts.xml';
break;

switch ($params->get('updatesource', 'default')) {
// "Testing"
case 'testing':
$updateURL = 'https://update.joomla.org/core/test/list_test.xml';
Expand All @@ -111,17 +107,20 @@ public function applyUpdateSite()
break;

/**
* "Minor & Patch Release for Current version (recommended and default)".
* All "non-testing" releases of the official project hosted in the TUF repo.
* The commented "case" below are for documenting where 'default' and legacy options falls
* case 'default':
* case 'next':
* case 'lts':
* case 'sts': (It's shown as "Default" because that option does not exist any more)
* case 'nochange':
*/
default:
$updateURL = 'https://update.joomla.org/core/list.xml';
$updateURL = 'https://update.joomla.org/cms/';
}

$updateType = (pathinfo($updateURL, PATHINFO_EXTENSION) === 'xml') ? 'collection' : 'tuf';

$id = ExtensionHelper::getExtensionRecord('joomla', 'file')->extension_id;
$db = version_compare(JVERSION, '4.2.0', 'lt') ? $this->getDbo() : $this->getDatabase();
$query = $db->getQuery(true)
Expand All @@ -137,10 +136,11 @@ public function applyUpdateSite()
$db->setQuery($query);
$update_site = $db->loadObject();

if ($update_site->location != $updateURL) {
if ($update_site->location !== $updateURL || $update_site->type !== $updateType) {
// Modify the database record.
$update_site->last_check_timestamp = 0;
$update_site->location = $updateURL;
$update_site->type = $updateType;
$db->updateObject('#__update_sites', $update_site, 'update_site_id');

// Remove cached updates.
Expand All @@ -156,7 +156,7 @@ public function applyUpdateSite()
/**
* Makes sure that the Joomla! update cache is up-to-date.
*
* @param boolean $force Force reload, ignoring the cache timeout.
* @param boolean $force Force reload, ignoring the cache timeout.
*
* @return void
*
Expand All @@ -176,7 +176,7 @@ public function refreshUpdates($force = false)
$minimumStability = Updater::STABILITY_STABLE;
$comJoomlaupdateParams = ComponentHelper::getParams('com_joomlaupdate');

if (\in_array($comJoomlaupdateParams->get('updatesource', 'nochange'), ['testing', 'custom'])) {
if (\in_array($comJoomlaupdateParams->get('updatesource', 'default'), ['testing', 'custom'])) {
$minimumStability = $comJoomlaupdateParams->get('minimum_stability', Updater::STABILITY_STABLE);
}

Expand Down Expand Up @@ -298,14 +298,34 @@ public function getUpdateInformation()

$minimumStability = Updater::STABILITY_STABLE;
$comJoomlaupdateParams = ComponentHelper::getParams('com_joomlaupdate');
$channel = $comJoomlaupdateParams->get('updatesource', 'default');

if (\in_array($comJoomlaupdateParams->get('updatesource', 'nochange'), ['testing', 'custom'])) {
if (\in_array($channel, ['testing', 'custom'])) {
$minimumStability = $comJoomlaupdateParams->get('minimum_stability', Updater::STABILITY_STABLE);
}

// Fetch the full update details from the update details URL.
$update = new Update();
$update->loadFromXml($updateObject->detailsurl, $minimumStability);

$updateType = (pathinfo($updateObject->detailsurl, PATHINFO_EXTENSION) === 'xml') ? 'collection' : 'tuf';

// Check if we have a local JSON string with update metadata
if (!empty($updateType === 'tuf')) {
// Use the correct identifier for the update channel
$updateChannel = Version::MAJOR_VERSION . '.x';

if ($channel === 'next') {
$updateChannel = (Version::MAJOR_VERSION + 1) . '.x';
}

$metadata = new TufMetadata($this->getDatabase());
$metadata->load(['update_site_id' => $updateObject->update_site_id]);

// Fetch update data from TUF repo
$update->loadFromTuf($metadata, $updateObject->detailsurl, $minimumStability, $updateChannel);
} else {
// We are using the legacy XML method
$update->loadFromXml($updateObject->location, $minimumStability, $channel);
}

// Make sure we use the current information we got from the detailsurl
$this->updateInformation['object'] = $update;
Expand Down Expand Up @@ -370,12 +390,12 @@ public function download()
$httpOptions = new Registry();
$httpOptions->set('follow_location', false);

$response = ['basename' => false, 'check' => null, 'version' => $updateInfo['latest']];

try {
$head = HttpFactory::getHttp($httpOptions)->head($packageURL);
} catch (\RuntimeException $e) {
// Passing false here -> download failed message
$response['basename'] = false;

return $response;
}

Expand All @@ -387,8 +407,6 @@ public function download()
$head = HttpFactory::getHttp($httpOptions)->head($packageURL);
} catch (\RuntimeException $e) {
// Passing false here -> download failed message
$response['basename'] = false;

return $response;
}
}
Expand All @@ -409,7 +427,6 @@ public function download()
)
->clean(Factory::getApplication()->get('tmp_path'), 'path');
$target = $tempdir . '/' . $basename;
$response = [];

// Do we have a cached file?
$exists = is_file($target);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@
</div>';

if ($this->getCurrentUser()->authorise('core.admin', 'com_joomlaupdate')) :
$displayData['formAppend'] = '<div class="text-center"><a href="' . $uploadLink . '" class="btn btn-sm btn-outline-secondary">' . Text::_('COM_JOOMLAUPDATE_EMPTYSTATE_APPEND') . '</a></div>';
$displayData['formAppend'] = '
<div class="text-center"><a href="' . $uploadLink . '" class="btn btn-sm btn-outline-secondary">' . Text::_('COM_JOOMLAUPDATE_EMPTYSTATE_APPEND') . '</a></div>
<input type="hidden" name="targetVersion" value="' . $this->updateInfo['latest'] . '" />
';
endif;

echo '<div id="joomlaupdate-wrapper">';
Expand Down
1 change: 1 addition & 0 deletions administrator/language/en-GB/com_joomlaupdate.ini
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ COM_JOOMLAUPDATE_VIEW_DEFAULT_UPLOAD_INTRO="You can use this feature to update J
COM_JOOMLAUPDATE_VIEW_UPDATE_BYTESEXTRACTED="Bytes extracted"
COM_JOOMLAUPDATE_VIEW_UPDATE_BYTESREAD="Bytes read"
COM_JOOMLAUPDATE_VIEW_UPDATE_CHECKSUM_WRONG="File Checksum Failed"
COM_JOOMLAUPDATE_VIEW_UPDATE_VERSION_WRONG="The version of the update package and the requested version do not match, try to refresh the update information."
COM_JOOMLAUPDATE_VIEW_UPDATE_DOWNLOADFAILED="Download of update package failed."
COM_JOOMLAUPDATE_VIEW_UPDATE_ITEMS="items"
COM_JOOMLAUPDATE_VIEW_UPDATE_FILESEXTRACTED="Files extracted"
Expand Down
7 changes: 7 additions & 0 deletions administrator/language/en-GB/lib_joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,13 @@ JLIB_INSTALLER_SQL_BEGIN="Start of SQL updates."
JLIB_INSTALLER_SQL_BEGIN_SCHEMA="The current database version (schema) is %s."
JLIB_INSTALLER_SQL_END="End of SQL updates."
JLIB_INSTALLER_SQL_END_NOT_COMPLETE="End of SQL updates - INCOMPLETE."
JLIB_INSTALLER_TUF_FREEZE_ATTACK="Update not possible because the offered update has expired."
JLIB_INSTALLER_TUF_DEBUG_MESSAGE="TUF Debug Message: %s"
JLIB_INSTALLER_TUF_INVALID_METADATA="The saved TUF update information is invalid."
JLIB_INSTALLER_TUF_NOT_AVAILABLE="TUF is not available for extensions yet."
JLIB_INSTALLER_TUF_DOWNLOAD_SIZE="The size of the update did not match the expected size."
JLIB_INSTALLER_TUF_ROLLBACK_ATTACK="Update not possible because the offered update version is older than the currently installed version."
JLIB_INSTALLER_TUF_SIGNATURE_THRESHOLD="Update not possible because the offered update does not have enough signatures."
JLIB_INSTALLER_UNINSTALL="Uninstall"
JLIB_INSTALLER_UPDATE="Update"
JLIB_INSTALLER_UPDATE_LOG_QUERY="Ran query from file %1$s. Query text: %2$s."
Expand Down
11 changes: 10 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
"type": "vcs",
"url": "https://github.com/joomla-backports/json-api-php.git",
"no-api": true
},
{
"type": "vcs",
"url": "https://github.com/joomla-backports/php-tuf.git",
"no-api": true
}
],
"autoload": {
Expand Down Expand Up @@ -100,7 +105,8 @@
"web-token/signature-pack": "^3.2.8",
"phpseclib/bcmath_compat": "^2.0.1",
"jfcherng/php-diff": "^6.15.3",
"voku/portable-utf8": "^6.0.13"
"voku/portable-utf8": "^6.0.13",
"php-tuf/php-tuf": "dev-main"
},
"require-dev": {
"phpunit/phpunit": "^9.6.11",
Expand All @@ -121,6 +127,9 @@
"symfony/polyfill-php80": "*",
"symfony/polyfill-php81": "*"
},
"extra": {
"composer-exit-on-patch-failure": true
},
"scripts": {
"post-install-cmd": [
"php build/update_fido_cache.php"
Expand Down
Loading