diff --git a/lib/Pages.php b/lib/Pages.php index 25eadb9..1bfdb75 100644 --- a/lib/Pages.php +++ b/lib/Pages.php @@ -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 - */ - public static function upgradeTriggers(): array { - return array_merge(['plugins.php'], self::files()); - } - /** * @return array */ diff --git a/lib/Settings.php b/lib/Settings.php index 68dfafc..e993151 100644 --- a/lib/Settings.php +++ b/lib/Settings.php @@ -169,7 +169,7 @@ public static function form(): array { ], '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'), 'method' => 'checkbox', 'default' => 'on', ], diff --git a/locales/LC_MESSAGES/ar-SA.mo b/locales/LC_MESSAGES/ar-SA.mo index 28b26fd..4174ed3 100644 Binary files a/locales/LC_MESSAGES/ar-SA.mo and b/locales/LC_MESSAGES/ar-SA.mo differ diff --git a/locales/LC_MESSAGES/es-419.mo b/locales/LC_MESSAGES/es-419.mo index bd26e39..ae6e32e 100644 Binary files a/locales/LC_MESSAGES/es-419.mo and b/locales/LC_MESSAGES/es-419.mo differ diff --git a/locales/LC_MESSAGES/es-ES.mo b/locales/LC_MESSAGES/es-ES.mo index 6f8276d..d0a108a 100644 Binary files a/locales/LC_MESSAGES/es-ES.mo and b/locales/LC_MESSAGES/es-ES.mo differ diff --git a/locales/LC_MESSAGES/hi-IN.mo b/locales/LC_MESSAGES/hi-IN.mo index aa8ab07..da5dade 100644 Binary files a/locales/LC_MESSAGES/hi-IN.mo and b/locales/LC_MESSAGES/hi-IN.mo differ diff --git a/locales/LC_MESSAGES/zh-CN.mo b/locales/LC_MESSAGES/zh-CN.mo index 1bb00db..1d196f6 100644 Binary files a/locales/LC_MESSAGES/zh-CN.mo and b/locales/LC_MESSAGES/zh-CN.mo differ diff --git a/locales/po/ar-SA.po b/locales/po/ar-SA.po index 8c2968b..df87990 100644 --- a/locales/po/ar-SA.po +++ b/locales/po/ar-SA.po @@ -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" diff --git a/locales/po/cacti.pot b/locales/po/cacti.pot index 02d829b..3d192b3 100644 --- a/locales/po/cacti.pot +++ b/locales/po/cacti.pot @@ -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 diff --git a/locales/po/es-419.po b/locales/po/es-419.po index 8fd6664..c04f268 100644 --- a/locales/po/es-419.po +++ b/locales/po/es-419.po @@ -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" diff --git a/locales/po/es-ES.po b/locales/po/es-ES.po index 8d9fb0b..3a36c4d 100644 --- a/locales/po/es-ES.po +++ b/locales/po/es-ES.po @@ -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" diff --git a/locales/po/hi-IN.po b/locales/po/hi-IN.po index 2defc99..0623a5c 100644 --- a/locales/po/hi-IN.po +++ b/locales/po/hi-IN.po @@ -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" diff --git a/locales/po/zh-CN.po b/locales/po/zh-CN.po index 9da68a0..3c9c709 100644 --- a/locales/po/zh-CN.po +++ b/locales/po/zh-CN.po @@ -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" diff --git a/setup.php b/setup.php index 9b7693a..b5bc2c3 100644 --- a/setup.php +++ b/setup.php @@ -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); @@ -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()) { @@ -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 { diff --git a/tests/Security/SourceRulesTest.php b/tests/Security/SourceRulesTest.php index fdb61c1..4e5dbb0 100644 --- a/tests/Security/SourceRulesTest.php +++ b/tests/Security/SourceRulesTest.php @@ -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()')); +});