Skip to content
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
10 changes: 0 additions & 10 deletions lib/Pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,6 @@ public static function menu(): array {
];
}

/**
* Pages whose load re-checks the schema, matching how maintained plugins
* apply upgrades in a core that never calls plugin_*_upgrade() itself.
*
* @return list<string>
*/
public static function upgradeTriggers(): array {
return array_merge(['plugins.php'], self::files());
}

/**
* @return array<string, array{title: string, mapping: string, url: string, level: string}>
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
],
'redfish_uninstall_keep_tables' => [
'friendly_name' => __('Keep Plugin Tables on Uninstall', 'redfish'),
'description' => __('When checked, uninstalling the plugin keeps its BMC registry, encrypted passwords, and reading cache. Clear it to have the uninstall drop them. This release creates no Cacti devices, and uninstall never touches devices, graphs, or BMCs.', 'redfish'),
'description' => __('When checked, uninstalling the plugin keeps its BMC registry, encrypted passwords, and reading cache. Clear it to have the uninstall drop them. Uninstall never touches Cacti devices, graphs, or BMCs, including devices the plugin created.', 'redfish'),

Check warning on line 172 in lib/Settings.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 278 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=somethingwithproof_plugin_redfish&issues=AaH3H06SDKUrjaOBOIeA&open=AaH3H06SDKUrjaOBOIeA&pullRequest=79
'method' => 'checkbox',
'default' => 'on',
],
Expand Down
Binary file modified locales/LC_MESSAGES/ar-SA.mo
Binary file not shown.
Binary file modified locales/LC_MESSAGES/es-419.mo
Binary file not shown.
Binary file modified locales/LC_MESSAGES/es-ES.mo
Binary file not shown.
Binary file modified locales/LC_MESSAGES/hi-IN.mo
Binary file not shown.
Binary file modified locales/LC_MESSAGES/zh-CN.mo
Binary file not shown.
4 changes: 2 additions & 2 deletions locales/po/ar-SA.po
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,8 @@ msgid "Keep Plugin Tables on Uninstall"
msgstr "الاحتفاظ بجداول الإضافة عند إلغاء التثبيت"

#: lib/Settings.php
msgid "When checked, uninstalling the plugin keeps its BMC registry, encrypted passwords, and reading cache. Clear it to have the uninstall drop them. This release creates no Cacti devices, and uninstall never touches devices, graphs, or BMCs."
msgstr "عند تحديده، يحتفظ إلغاء التثبيت بسجل BMC وكلمات المرور المشفرة وذاكرة القراءات المؤقتة. ألغِ تحديده لحذفها. لا ينشئ هذا الإصدار أجهزة Cacti، ولا يمس إلغاء التثبيت الأجهزة أو الرسوم أو وحدات BMC مطلقًا."
msgid "When checked, uninstalling the plugin keeps its BMC registry, encrypted passwords, and reading cache. Clear it to have the uninstall drop them. Uninstall never touches Cacti devices, graphs, or BMCs, including devices the plugin created."
msgstr "عند تحديده، يحتفظ إلغاء التثبيت بسجل BMC وكلمات المرور المشفرة وذاكرة القراءات المؤقتة. ألغِ تحديده لحذفها. لا يمس إلغاء التثبيت أجهزة Cacti أو الرسوم أو وحدات BMC مطلقًا، بما في ذلك الأجهزة التي أنشأتها الإضافة."

#: lib/TlsMode.php
msgid "Verify against the system CA store"
Expand Down
2 changes: 1 addition & 1 deletion locales/po/cacti.pot
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ msgid "Keep Plugin Tables on Uninstall"
msgstr ""

#: lib/Settings.php
msgid "When checked, uninstalling the plugin keeps its BMC registry, encrypted passwords, and reading cache. Clear it to have the uninstall drop them. This release creates no Cacti devices, and uninstall never touches devices, graphs, or BMCs."
msgid "When checked, uninstalling the plugin keeps its BMC registry, encrypted passwords, and reading cache. Clear it to have the uninstall drop them. Uninstall never touches Cacti devices, graphs, or BMCs, including devices the plugin created."
msgstr ""

#: lib/TlsMode.php
Expand Down
4 changes: 2 additions & 2 deletions locales/po/es-419.po
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,8 @@ msgid "Keep Plugin Tables on Uninstall"
msgstr "Conservar tablas al desinstalar"

#: lib/Settings.php
msgid "When checked, uninstalling the plugin keeps its BMC registry, encrypted passwords, and reading cache. Clear it to have the uninstall drop them. This release creates no Cacti devices, and uninstall never touches devices, graphs, or BMCs."
msgstr "Si está marcado, se conservan el registro BMC, las contraseñas cifradas y la caché de lecturas al desinstalar. Desmárquelo para eliminarlos. Esta versión no crea dispositivos Cacti y la desinstalación nunca toca dispositivos, gráficos ni BMC."
msgid "When checked, uninstalling the plugin keeps its BMC registry, encrypted passwords, and reading cache. Clear it to have the uninstall drop them. Uninstall never touches Cacti devices, graphs, or BMCs, including devices the plugin created."
msgstr "Si está marcado, se conservan el registro BMC, las contraseñas cifradas y la caché de lecturas al desinstalar. Desmárquelo para eliminarlos. La desinstalación nunca toca dispositivos, gráficos ni BMC de Cacti, incluidos los dispositivos que creó el plugin."

#: lib/TlsMode.php
msgid "Verify against the system CA store"
Expand Down
4 changes: 2 additions & 2 deletions locales/po/es-ES.po
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,8 @@ msgid "Keep Plugin Tables on Uninstall"
msgstr "Conservar tablas al desinstalar"

#: lib/Settings.php
msgid "When checked, uninstalling the plugin keeps its BMC registry, encrypted passwords, and reading cache. Clear it to have the uninstall drop them. This release creates no Cacti devices, and uninstall never touches devices, graphs, or BMCs."
msgstr "Si está marcado, se conservan el registro BMC, las contraseñas cifradas y la caché de lecturas al desinstalar. Desmárquelo para eliminarlos. Esta versión no crea dispositivos Cacti y la desinstalación nunca toca dispositivos, gráficos ni BMC."
msgid "When checked, uninstalling the plugin keeps its BMC registry, encrypted passwords, and reading cache. Clear it to have the uninstall drop them. Uninstall never touches Cacti devices, graphs, or BMCs, including devices the plugin created."
msgstr "Si está marcado, se conservan el registro BMC, las contraseñas cifradas y la caché de lecturas al desinstalar. Desmárquelo para eliminarlos. La desinstalación nunca toca dispositivos, gráficos ni BMC de Cacti, incluidos los dispositivos que creó el plugin."

#: lib/TlsMode.php
msgid "Verify against the system CA store"
Expand Down
4 changes: 2 additions & 2 deletions locales/po/hi-IN.po
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,8 @@ msgid "Keep Plugin Tables on Uninstall"
msgstr "अनइंस्टॉल पर प्लगइन तालिकाएँ रखें"

#: lib/Settings.php
msgid "When checked, uninstalling the plugin keeps its BMC registry, encrypted passwords, and reading cache. Clear it to have the uninstall drop them. This release creates no Cacti devices, and uninstall never touches devices, graphs, or BMCs."
msgstr "चयनित होने पर अनइंस्टॉल BMC रजिस्ट्री, एन्क्रिप्टेड पासवर्ड और पठन कैश रखता है। मिटाने के लिए चयन हटाएँ। यह संस्करण Cacti डिवाइस नहीं बनाता और अनइंस्टॉल कभी डिवाइस, ग्राफ़ या BMC नहीं छूता।"
msgid "When checked, uninstalling the plugin keeps its BMC registry, encrypted passwords, and reading cache. Clear it to have the uninstall drop them. Uninstall never touches Cacti devices, graphs, or BMCs, including devices the plugin created."
msgstr "चयनित होने पर अनइंस्टॉल BMC रजिस्ट्री, एन्क्रिप्टेड पासवर्ड और पठन कैश रखता है। मिटाने के लिए चयन हटाएँ। अनइंस्टॉल कभी Cacti डिवाइस, ग्राफ़ या BMC नहीं छूता, इसमें प्लगइन द्वारा बनाए गए डिवाइस भी शामिल हैं।"

#: lib/TlsMode.php
msgid "Verify against the system CA store"
Expand Down
4 changes: 2 additions & 2 deletions locales/po/zh-CN.po
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,8 @@ msgid "Keep Plugin Tables on Uninstall"
msgstr "卸载时保留插件表"

#: lib/Settings.php
msgid "When checked, uninstalling the plugin keeps its BMC registry, encrypted passwords, and reading cache. Clear it to have the uninstall drop them. This release creates no Cacti devices, and uninstall never touches devices, graphs, or BMCs."
msgstr "选中时,卸载会保留 BMC 注册表、加密密码和读数缓存。取消选中则删除这些内容。此版本不创建 Cacti 设备,卸载也永远不会修改设备、图表或 BMC。"
msgid "When checked, uninstalling the plugin keeps its BMC registry, encrypted passwords, and reading cache. Clear it to have the uninstall drop them. Uninstall never touches Cacti devices, graphs, or BMCs, including devices the plugin created."
msgstr "选中时,卸载会保留 BMC 注册表、加密密码和读数缓存。取消选中则删除这些内容。卸载永远不会修改 Cacti 设备、图表或 BMC,包括插件创建的设备。"

#: lib/TlsMode.php
msgid "Verify against the system CA store"
Expand Down
16 changes: 8 additions & 8 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ function plugin_redfish_check_config(): bool {
function redfish_page_start(): bool {
if (redfish_boot() && api_plugin_is_enabled('redfish')) {
if (redfish_page_allowed()) {
// The repair runs only for an authenticated, authorized request:
// config_arrays fires before Cacti checks the session.
plugin_redfish_upgrade();

return true;
}
http_response_code(403);
Expand Down Expand Up @@ -252,15 +256,15 @@ function redfish_summary_script(): \Somethingwithproof\Redfish\SummaryScript {
/**
* Bring the schema, hooks, and realms up to the code's version.
*
* Cacti 1.2.31 never calls this itself; check_config and the config_arrays
* hook do. Fresh installs take the same path as upgrades. The version stored
* Cacti 1.2.31 never calls this itself; check_config and redfish_page_start()
* do. Fresh installs take the same path as upgrades. The version stored
* in plugin_config changes only after every migration has succeeded, so an
* interrupted run is finished by the next one (REQ-LIFE-001, REQ-LIFE-002).
*
* $grant gives newly registered realms to the current user. Only install and
* check_config pass it: both run from the Plugins page, which needs plugin
* management. A repair triggered from config_arrays can run for anyone who
* opens a plugin page, so it must never grant anything.
* management. A repair triggered from redfish_page_start() can run for any
* user allowed on a plugin page, so it must never grant anything.
*/
function plugin_redfish_upgrade(bool $grant = false): bool {
if (!redfish_boot()) {
Expand Down Expand Up @@ -380,10 +384,6 @@ function redfish_config_arrays(): void {
foreach (\Somethingwithproof\Redfish\Pages::menu() as $file => $title) {
$menu[__('Management')]['plugins/redfish/' . $file] = $title;
}

if (in_array(get_current_page(), \Somethingwithproof\Redfish\Pages::upgradeTriggers(), true)) {
plugin_redfish_upgrade();
}
}

function redfish_config_settings(): void {
Expand Down
14 changes: 14 additions & 0 deletions tests/Security/SourceRulesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,17 @@ function redfish_entry_points(): array {

expect($missing)->toBe([]);
});

it('runs the schema repair only after a plugin page is authorized, never from config_arrays', function () {
$source = (string) file_get_contents(redfish_root() . '/setup.php');

// config_arrays fires while include/global.php loads, before the session
// check, so nothing it calls may migrate or import.
preg_match('/function redfish_config_arrays\(\): void \{.*?\n\}\n/s', $source, $arrays);
preg_match('/function redfish_page_start\(\): bool \{.*?\n\}\n/s', $source, $start);

expect($arrays)->not->toBeEmpty()
->and($arrays[0])->not->toContain('plugin_redfish_upgrade')
->and($start)->not->toBeEmpty()
->and(strpos($start[0], 'plugin_redfish_upgrade'))->toBeGreaterThan(strpos($start[0], 'redfish_page_allowed()'));
});