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

Update check: Warning for EOL PHP versions #5728

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@
"system.issues.content": "The content folder seems to be exposed",
"system.issues.eol.kirby": "Your installed Kirby version has reached end-of-life and will not receive further security updates",
"system.issues.eol.plugin": "Your installed version of the { plugin } plugin is has reached end-of-life and will not receive further security updates",
"system.issues.eol.php": "Your installed PHP release { release } has reached end-of-life and will not receive further security updates",
"system.issues.debug": "Debugging must be turned off in production",
"system.issues.git": "The .git folder seems to be exposed",
"system.issues.https": "We recommend HTTPS for all your sites",
Expand Down
14 changes: 14 additions & 0 deletions src/Cms/System/UpdateStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,20 @@ public function messages(): array|null
];
}

// add special message for end-of-life PHP versions
$phpMajor = PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION;
$phpEol = $this->data['php'][$phpMajor] ?? null;
if (is_string($phpEol) === true && $eolTime = strtotime($phpEol)) {
// the timestamp is available and valid, now check if it is in the past
if ($eolTime < time()) {
$messages[] = [
'text' => I18n::template('system.issues.eol.php', null, ['release' => $phpMajor]),
'link' => 'https://getkirby.com/security/php-end-of-life',
'icon' => 'bell'
];
}
}

return $this->messages = $messages;
}

Expand Down
77 changes: 76 additions & 1 deletion tests/Cms/System/UpdateStatusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ public function testLoadData()
'upgrade' => 'https://getkirby.com/releases/99999'
]
],
'php' => [
'8.0' => '2023-11-26',
'8.1' => '2024-11-25',
'8.2' => '2025-12-08'
],
'incidents' => [],
'messages' => [],
'_version' => '88888.8.5'
Expand All @@ -85,6 +90,11 @@ public function testLoadDataCacheKirby()
'status' => 'active-support'
]
],
'php' => [
'8.0' => '2023-11-26',
'8.1' => '2024-11-25',
'8.2' => '2025-12-08'
],
'urls' => [
'*' => [
'changes' => 'https://getkirby.com/releases/{{ version }}'
Expand Down Expand Up @@ -123,6 +133,11 @@ public function testLoadDataCacheKirby()
'upgrade' => 'https://getkirby.com/releases/99999'
]
],
'php' => [
'8.0' => '2023-11-26',
'8.1' => '2024-11-25',
'8.2' => '2025-12-08'
],
'incidents' => [],
'messages' => [],
'_version' => '88888.8.6'
Expand Down Expand Up @@ -236,6 +251,11 @@ public function testLoadDataCacheInvalid()
'upgrade' => 'https://getkirby.com/releases/99999'
]
],
'php' => [
'8.0' => '2023-11-26',
'8.1' => '2024-11-25',
'8.2' => '2025-12-08'
],
'incidents' => [],
'messages' => [],
'_version' => '88888.8.5'
Expand Down Expand Up @@ -1068,6 +1088,33 @@ public function logicProvider(): array
'exceptionMessages' => []
]
],
'EOL warning (PHP)' => [
'app',
'88888.8.8',
false,
$this->data('php'),
[
'currentVersion' => '88888.8.8',
'icon' => 'check',
'label' => 'Up to date',
'latestVersion' => '88888.8.8',
'messages' => [
[
'text' => 'Your installed PHP release ' .
PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION .
' has reached end-of-life and will not receive further security updates',
'link' => 'https://getkirby.com/security/php-end-of-life',
'icon' => 'bell'
]
],
'status' => 'up-to-date',
'targetVersion' => null,
'theme' => 'positive',
'url' => 'https://getkirby.com/releases/88888.8.8',
'vulnerabilities' => [],
'exceptionMessages' => []
]
],
'EOL warning with custom link' => [
'app',
'44444.1.2',
Expand Down Expand Up @@ -1232,6 +1279,25 @@ public function logicProvider(): array
]
]
],
'No PHP' => [
'app',
'77777.7.7',
false,
$this->data('no-php'),
[
'currentVersion' => '77777.7.7',
'icon' => 'info',
'label' => 'Upgrade 88888.8.8 available',
'latestVersion' => '88888.8.8',
'messages' => [],
'status' => 'upgrade',
'targetVersion' => '88888.8.8',
'theme' => 'info',
'url' => 'https://getkirby.com/releases/88888',
'vulnerabilities' => [],
'exceptionMessages' => []
]
],
'No incidents' => [
'app',
'77777.7.7',
Expand Down Expand Up @@ -1561,7 +1627,16 @@ protected function data(string $name): array
}

$path = __DIR__ . '/fixtures/UpdateStatusTest/logic/' . $name . '.json';
return $this->data[$name] = Json::read($path);
$json = Json::read($path);

// dynamically insert the current PHP version
// because we cannot mock it easily
if (isset($json['php']['<CURRENT>']) === true) {
$json['php'][PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION] = $json['php']['<CURRENT>'];
unset($json['php']['<CURRENT>']);
}

return $this->data[$name] = $json;
}

protected function plugin(string|null $version): Plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
"upgrade": "https://getkirby.com/releases/99999"
}
},
"php": {
"8.0": "2023-11-26",
"8.1": "2024-11-25",
"8.2": "2025-12-08"
},
"incidents": [],
"messages": []
}
3 changes: 3 additions & 0 deletions tests/Cms/System/fixtures/UpdateStatusTest/logic/basic.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
"upgrade": "https://getkirby.com/releases/88888"
}
},
"php": {
"<CURRENT>": "9999-01-01"
},
"incidents": [
{
"affected": "<=66666.5.4 || 77777.0.0 - 77777.5.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"upgrade": "https://getkirby.com/releases/88888"
}
},
"php": {},
"incidents": [
{
"affected": "<=66666.5.4 || 77777.0.0 - 77777.5.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"upgrade": "https://getkirby.com/releases/88888"
}
},
"php": {},
"incidents": [
{
"affected": "<=77777.2.5 || 88888.0.0 - 88888.3.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"upgrade": "https://getkirby.com/releases/88888"
}
},
"php": {},
"incidents": [
{
"affected": "<=66666.5.4 || 77777.0.0 - 88888.5.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"upgrade": "https://getkirby.com/releases/88888"
}
},
"php": {},
"incidents": [
{
"affected": "<=77777.5.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"upgrade": "https://getkirby.com/releases/88888"
}
},
"php": {},
"incidents": [
{
"affected": "<=66666.5.4 || 77777.0.0-77777.5.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"upgrade": "https://getkirby.com/releases/88888"
}
},
"php": {},
"incidents": [],
"messages": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"upgrade": "https://getkirby.com/releases/88888"
}
},
"php": {},
"incidents": [],
"messages": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"upgrade": "https://getkirby.com/releases/88888"
}
},
"php": {},
"incidents": [],
"messages": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"upgrade": "https://getkirby.com/releases/88888"
}
},
"php": {},
"incidents": [
{
"description": "Some incident",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"upgrade": "https://getkirby.com/releases/88888"
}
},
"php": {},
"incidents": [],
"messages": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
"upgrade": "https://getkirby.com/releases/88888"
}
},
"php": {},
"messages": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"upgrade": "https://getkirby.com/releases/88888"
}
},
"php": {},
"incidents": [],
"messages": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
"upgrade": "https://getkirby.com/releases/88888"
}
},
"php": {},
"incidents": []
}
24 changes: 24 additions & 0 deletions tests/Cms/System/fixtures/UpdateStatusTest/logic/no-php.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"latest": "88888.8.8",
"versions": {
"88888.8.8": {
"status": "latest"
},
">=77777.5.5": {
"status": "no-vulnerabilities"
},
"*": {
"latest": "77777.7.7",
"status": "active-support"
}
},
"urls": {
"*": {
"changes": "https://getkirby.com/releases/{{ version }}",
"download": "https://repoofthefuture.com/{{ version }}.zip",
"upgrade": "https://getkirby.com/releases/88888"
}
},
"incidents": [],
"messages": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"upgrade": "https://getkirby.com/releases/88888"
}
},
"php": {},
"incidents": [],
"messages": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"status": "active-support"
}
},
"php": {},
"incidents": [],
"messages": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"upgrade": "https://getkirby.com/releases/88888"
}
},
"php": {},
"incidents": [
{
"affected": "<=66666.5.4 || 77777.0.0 - 77777.5.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"upgrade": "https://getkirby.com/releases/88888"
}
},
"php": {},
"incidents": [],
"messages": []
}
27 changes: 27 additions & 0 deletions tests/Cms/System/fixtures/UpdateStatusTest/logic/php.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"latest": "88888.8.8",
"versions": {
"88888.8.8": {
"status": "latest"
},
">=77777.5.5": {
"status": "no-vulnerabilities"
},
"*": {
"latest": "77777.7.7",
"status": "active-support"
}
},
"urls": {
"*": {
"changes": "https://getkirby.com/releases/{{ version }}",
"download": "https://repoofthefuture.com/{{ version }}.zip",
"upgrade": "https://getkirby.com/releases/88888"
}
},
"php": {
"<CURRENT>": "2022-01-01"
},
"incidents": [],
"messages": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"download": "https://repoofthefuture.com/{{ version }}.zip"
}
},
"php": {},
"incidents": [],
"messages": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"upgrade": "https://getkirby.com/releases/88888"
}
},
"php": {},
"incidents": [],
"messages": []
}