diff --git a/README.md b/README.md index 5aaf43b..2e15dbd 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ Out of scope: changing cloud resources, creating or mirroring provider alarms, b - **A guarded install.** On PHP below 8.2, or without ext-openssl, install and enable are refused with a message, and the rest of Cacti keeps working. - **Lifecycle.** Install, upgrade, and uninstall through Cacti's Plugins page. Upgrades are ordered and survive interruption. Uninstall keeps the plugin's tables unless you clear *Keep Plugin Tables on Uninstall*. -- **Separate realms.** *Cloud Admin* opens **Cloud Accounts**; *Cloud View* opens **Cloud Health**. Both pages are under Management. +- **Separate realms.** *Cloud Admin* opens **Cloud Accounts**; *Cloud Operator* opens **Cloud Operations**; *Cloud View* opens **Cloud Health**. Admin inherits Operator, and Operator inherits View. All three pages are under Management. - **Accounts and credentials.** Add, edit, verify, and delete accounts. A credential is either encrypted in the database with a key file kept outside it (AES-256-GCM), or read from a file on the poller. Credentials are write-only in the UI and are redacted from logs. - **The collector.** It starts from each poller run, one instance per poller, within a time budget. It takes a lease per account, runs discovery on its own interval, and reads metrics only for the plugin's own active data sources. - **Health.** Per-account collection, discovery, resource, and freshness state, plus warnings for an unusable vault key, unsafe credential files, and intervals the poller cannot honour. @@ -86,7 +86,7 @@ These steps install the milestone 2 code for evaluation. They require Cacti 1.2. Replace `cacti` with the user that runs your web server and poller. The file holds 32 raw bytes or 64 hexadecimal characters. Back it up with the database; without it, stored credentials must be entered again. 3. In Cacti, open **Configuration > Plugins**, then install and enable *Cloud*. 4. Under **Configuration > Settings > Cloud**, set *Vault Key File* if you used another path. *Collector Time Budget* (default 240 seconds) must stay below the poller interval. -5. Grant *Cloud Admin* or *Cloud View* to users and groups under **Configuration > Users**. Installing grants both realms to the administrator. +5. Grant *Cloud Admin*, *Cloud Operator* or *Cloud View* to users and groups under **Configuration > Users**. Installing grants Cloud Admin and Cloud View to the administrator; Cloud Admin includes Operator access, so the administrator needs no separate Operator grant. 6. Add accounts under **Management > Cloud Accounts**, then check **Management > Cloud Health** for warnings. ## Compatibility targets diff --git a/cloud_accounts.php b/cloud_accounts.php index a5accf4..23570de 100644 --- a/cloud_accounts.php +++ b/cloud_accounts.php @@ -103,7 +103,14 @@ $cloud_saved = $cloud_accounts->save($cloud_parsed->account, $cloud_user); $cloud_raw = trim((string) get_nfilter_request_var('credential')); - if ($cloud_saved > 0 && $cloud_raw !== '') { + if ($cloud_saved > 0 && $cloud_parsed->account->credentialSource !== \Somethingwithproof\Cloud\CredentialSource::Vault) { + // A credential kept in the vault would come back, unprompted, if the + // account were switched back to it with the box left empty. + if ($cloud_credentials->hasVaultCredential($cloud_saved)) { + $cloud_credentials->forget($cloud_saved); + $cloud_accounts->recordCredentialChange($cloud_saved, $cloud_user); + } + } elseif ($cloud_saved > 0 && $cloud_raw !== '') { try { $cloud_credentials->storeVaultCredential($cloud_saved, new \Somethingwithproof\Cloud\Secret($cloud_raw)); $cloud_accounts->recordCredentialChange($cloud_saved, $cloud_user); @@ -127,7 +134,25 @@ header('Location: cloud_accounts.php'); exit; case 'delete': - if ($cloud_accounts->delete((int) get_filter_request_var('id'), $cloud_user)) { + $cloud_id = (int) get_filter_request_var('id'); + + // Deleting drops the stored credential and collected data for good, + // so the first POST only asks; the confirmation form sends the second. + if ((string) get_nfilter_request_var('confirm') !== '1') { + $cloud_account = $cloud_accounts->find($cloud_id); + + if ($cloud_account !== null) { + top_header(); + $cloud_page->renderDeleteConfirm($cloud_account); + bottom_footer(); + exit; + } + + header('Location: cloud_accounts.php'); + exit; + } + + if ($cloud_accounts->delete($cloud_id, $cloud_user)) { raise_message( 'cloud_deleted', __('The account and its collected data were deleted. Its Cacti devices and graphs were left in place.', 'cloud'), diff --git a/docs/i18n/ar-SA/README.md b/docs/i18n/ar-SA/README.md index 2aeb067..9e5e778 100644 --- a/docs/i18n/ar-SA/README.md +++ b/docs/i18n/ar-SA/README.md @@ -1,4 +1,4 @@ - + [English](../../../README.md) | [简体中文](../zh-CN/README.md) | [हिन्दी](../hi-IN/README.md) | [Español (España)](../es-ES/README.md) | [Español (Latinoamérica)](../es-419/README.md) | [العربية](README.md) @@ -62,7 +62,7 @@ - **تثبيت محمي بفحوص.** عند استخدام PHP أقدم من 8.2 أو دون ext-openssl، يُرفض التثبيت والتفعيل مع رسالة، ويستمر باقي Cacti في العمل. - **دورة الحياة.** التثبيت والترقية وإلغاء التثبيت عبر صفحة إضافات Cacti. الترقيات مرتّبة وتتحمل الانقطاع. يحتفظ إلغاء التثبيت بجداول الإضافة إلا إذا ألغيت تحديد *Keep Plugin Tables on Uninstall*. -- **نطاقات منفصلة.** يفتح *Cloud Admin* صفحة **Cloud Accounts**؛ ويفتح *Cloud View* صفحة **Cloud Health**. كلاهما ضمن Management. +- **نطاقات منفصلة.** يفتح *Cloud Admin* صفحة **Cloud Accounts**؛ ويفتح *Cloud Operator* صفحة **Cloud Operations**؛ ويفتح *Cloud View* صفحة **Cloud Health**. يرث Admin صلاحيات Operator، ويرث Operator صلاحيات View. الصفحات الثلاث ضمن Management. - **الحسابات وبيانات الاعتماد.** إضافة الحسابات وتعديلها والتحقق منها وحذفها. تُشفّر بيانات الاعتماد إما في قاعدة البيانات بمفتاح في ملف خارجها (AES-256-GCM)، أو تُقرأ من ملف على المستطلع. لا تُعرض بيانات الاعتماد للقراءة في الواجهة، وتُحجب من السجلات. - **الجامع.** يبدأ من كل تشغيل للمستطلع، بمثيل واحد لكل مستطلع، ضمن ميزانية زمنية. يحصل على حجز مؤقت لكل حساب، ويشغّل الاكتشاف بفاصله الخاص، ولا يقرأ إلا مقاييس مصادر البيانات النشطة التي تملكها الإضافة. - **الصحة.** حالة الجمع والاكتشاف والموارد والحداثة لكل حساب، مع تحذيرات بشأن مفتاح خزنة غير صالح، وملفات اعتماد غير آمنة، وفواصل لا يستطيع المستطلع الالتزام بها. @@ -85,7 +85,7 @@ استبدل `cacti` بالمستخدم الذي يشغّل خادم الويب والمستطلع. يحتوي الملف على 32 بايت خام أو 64 محرفًا ست عشريًا. انسخه احتياطيًا مع قاعدة البيانات؛ بدونه يجب إدخال بيانات الاعتماد المخزّنة مجددًا. 3. في Cacti، افتح **Configuration > Plugins**، ثم ثبّت *Cloud* وفعّله. 4. ضمن **Configuration > Settings > Cloud**، اضبط *Vault Key File* إن استخدمت مسارًا آخر. يجب أن تبقى *Collector Time Budget* (افتراضيًا 240 ثانية) أقل من فاصل المستطلع. -5. امنح *Cloud Admin* أو *Cloud View* للمستخدمين والمجموعات ضمن **Configuration > Users**. يمنح التثبيت النطاقين للمسؤول. +5. امنح *Cloud Admin* أو *Cloud Operator* أو *Cloud View* للمستخدمين والمجموعات ضمن **Configuration > Users**. يمنح التثبيت المسؤولَ Cloud Admin وCloud View؛ ويتضمن Cloud Admin صلاحيات Operator، فلا يحتاج المسؤول إلى منح Operator بشكل منفصل. 6. أضف الحسابات ضمن **Management > Cloud Accounts**، ثم تحقق من التحذيرات في **Management > Cloud Health**. diff --git a/docs/i18n/es-419/README.md b/docs/i18n/es-419/README.md index f522eeb..5e7e8c5 100644 --- a/docs/i18n/es-419/README.md +++ b/docs/i18n/es-419/README.md @@ -1,4 +1,4 @@ - + [English](../../../README.md) | [简体中文](../zh-CN/README.md) | [हिन्दी](../hi-IN/README.md) | [Español (España)](../es-ES/README.md) | [Español (Latinoamérica)](README.md) | [العربية](../ar-SA/README.md) @@ -62,7 +62,7 @@ Quedan fuera del alcance: modificar recursos de nube, crear o replicar alarmas d - **Instalación protegida.** Con PHP anterior a 8.2 o sin ext-openssl, se rechazan la instalación y la activación con un mensaje, y el resto de Cacti sigue funcionando. - **Ciclo de vida.** Instalación, actualización y desinstalación desde la página de complementos de Cacti. Las actualizaciones siguen un orden y sobreviven a interrupciones. La desinstalación conserva las tablas del complemento salvo que desmarque *Keep Plugin Tables on Uninstall*. -- **Ámbitos separados.** *Cloud Admin* abre **Cloud Accounts**; *Cloud View* abre **Cloud Health**. Ambas páginas están en Management. +- **Ámbitos separados.** *Cloud Admin* abre **Cloud Accounts**; *Cloud Operator* abre **Cloud Operations**; *Cloud View* abre **Cloud Health**. Admin hereda Operator, y Operator hereda View. Las tres páginas están en Management. - **Cuentas y credenciales.** Añadir, editar, verificar y eliminar cuentas. Las credenciales se cifran en la base de datos con un archivo de clave externo (AES-256-GCM), o se leen desde un archivo en el sondeador. En la interfaz solo pueden escribirse y se ocultan en los registros. - **El recopilador.** Se inicia en cada ejecución del sondeador, una instancia por sondeador, dentro de un presupuesto de tiempo. Adquiere una concesión temporal por cuenta, ejecuta el descubrimiento con su propio intervalo y solo lee métricas de las fuentes de datos activas que pertenecen al complemento. - **Salud.** Estado de recopilación, descubrimiento, recursos y vigencia por cuenta, junto con advertencias sobre claves de bóveda inutilizables, archivos de credenciales inseguros e intervalos que el sondeador no puede cumplir. @@ -85,7 +85,7 @@ Estos pasos instalan el código del hito 2 para evaluarlo. Requieren Cacti 1.2.3 Sustituya `cacti` por el usuario que ejecuta el servidor web y el sondeador. El archivo contiene 32 bytes sin procesar o 64 caracteres hexadecimales. Haga una copia de seguridad junto con la base de datos; sin él tendrá que volver a introducir las credenciales almacenadas. 3. En Cacti, abra **Configuration > Plugins** e instale y active *Cloud*. 4. En **Configuration > Settings > Cloud**, configure *Vault Key File* si ha utilizado otra ruta. *Collector Time Budget* (240 segundos de forma predeterminada) debe ser menor que el intervalo del sondeador. -5. Conceda *Cloud Admin* o *Cloud View* a usuarios y grupos en **Configuration > Users**. La instalación concede ambos ámbitos al administrador. +5. Conceda *Cloud Admin*, *Cloud Operator* o *Cloud View* a usuarios y grupos en **Configuration > Users**. La instalación concede Cloud Admin y Cloud View al administrador; Cloud Admin incluye el acceso de Operator, así que el administrador no necesita una concesión aparte de Operator. 6. Añada cuentas en **Management > Cloud Accounts** y compruebe si hay advertencias en **Management > Cloud Health**. diff --git a/docs/i18n/es-ES/README.md b/docs/i18n/es-ES/README.md index f147db7..3cb27de 100644 --- a/docs/i18n/es-ES/README.md +++ b/docs/i18n/es-ES/README.md @@ -1,4 +1,4 @@ - + [English](../../../README.md) | [简体中文](../zh-CN/README.md) | [हिन्दी](../hi-IN/README.md) | [Español (España)](README.md) | [Español (Latinoamérica)](../es-419/README.md) | [العربية](../ar-SA/README.md) @@ -62,7 +62,7 @@ Quedan fuera del alcance: modificar recursos de nube, crear o replicar alarmas d - **Instalación protegida.** Con PHP anterior a 8.2 o sin ext-openssl, se rechazan la instalación y la activación con un mensaje, y el resto de Cacti sigue funcionando. - **Ciclo de vida.** Instalación, actualización y desinstalación desde la página de complementos de Cacti. Las actualizaciones siguen un orden y sobreviven a interrupciones. La desinstalación conserva las tablas del complemento salvo que desmarque *Keep Plugin Tables on Uninstall*. -- **Ámbitos separados.** *Cloud Admin* abre **Cloud Accounts**; *Cloud View* abre **Cloud Health**. Ambas páginas están en Management. +- **Ámbitos separados.** *Cloud Admin* abre **Cloud Accounts**; *Cloud Operator* abre **Cloud Operations**; *Cloud View* abre **Cloud Health**. Admin hereda Operator, y Operator hereda View. Las tres páginas están en Management. - **Cuentas y credenciales.** Añadir, editar, verificar y eliminar cuentas. Las credenciales se cifran en la base de datos con un fichero de clave externo (AES-256-GCM), o se leen desde un fichero en el sondeador. En la interfaz solo pueden escribirse y se ocultan en los registros. - **El recopilador.** Se inicia en cada ejecución del sondeador, una instancia por sondeador, dentro de un presupuesto de tiempo. Adquiere una concesión temporal por cuenta, ejecuta el descubrimiento con su propio intervalo y solo lee métricas de las fuentes de datos activas que pertenecen al complemento. - **Salud.** Estado de recopilación, descubrimiento, recursos y vigencia por cuenta, junto con advertencias sobre claves de bóveda inutilizables, ficheros de credenciales inseguros e intervalos que el sondeador no puede cumplir. @@ -85,7 +85,7 @@ Estos pasos instalan el código del hito 2 para evaluarlo. Requieren Cacti 1.2.3 Sustituya `cacti` por el usuario que ejecuta el servidor web y el sondeador. El fichero contiene 32 bytes sin procesar o 64 caracteres hexadecimales. Haga una copia de seguridad junto con la base de datos; sin él tendrá que volver a introducir las credenciales almacenadas. 3. En Cacti, abra **Configuration > Plugins** e instale y active *Cloud*. 4. En **Configuration > Settings > Cloud**, configure *Vault Key File* si ha utilizado otra ruta. *Collector Time Budget* (240 segundos de forma predeterminada) debe ser menor que el intervalo del sondeador. -5. Conceda *Cloud Admin* o *Cloud View* a usuarios y grupos en **Configuration > Users**. La instalación concede ambos ámbitos al administrador. +5. Conceda *Cloud Admin*, *Cloud Operator* o *Cloud View* a usuarios y grupos en **Configuration > Users**. La instalación concede Cloud Admin y Cloud View al administrador; Cloud Admin incluye el acceso de Operator, así que el administrador no necesita una concesión aparte de Operator. 6. Añada cuentas en **Management > Cloud Accounts** y compruebe si hay advertencias en **Management > Cloud Health**. diff --git a/docs/i18n/hi-IN/README.md b/docs/i18n/hi-IN/README.md index bc0d0a6..0b86ed4 100644 --- a/docs/i18n/hi-IN/README.md +++ b/docs/i18n/hi-IN/README.md @@ -1,4 +1,4 @@ - + [English](../../../README.md) | [简体中文](../zh-CN/README.md) | [हिन्दी](README.md) | [Español (España)](../es-ES/README.md) | [Español (Latinoamérica)](../es-419/README.md) | [العربية](../ar-SA/README.md) @@ -62,7 +62,7 @@ Cacti डिवाइस अनुमतियाँ अब भी प्रत - **सुरक्षित स्थापना जाँच।** PHP 8.2 से नीचे या ext-openssl के बिना स्थापना और सक्षम करना संदेश के साथ अस्वीकार होता है, और बाकी Cacti काम करता रहता है। - **जीवनचक्र।** Cacti के Plugins पृष्ठ से इंस्टॉल, अपग्रेड और अनइंस्टॉल करें। अपग्रेड क्रमबद्ध हैं और रुकावट सहते हैं। *Keep Plugin Tables on Uninstall* को अचयनित न करने तक अनइंस्टॉल प्लगइन तालिकाएँ रखता है। -- **अलग अनुमति क्षेत्र।** *Cloud Admin* से **Cloud Accounts**, और *Cloud View* से **Cloud Health** खुलता है। दोनों पृष्ठ Management में हैं। +- **अलग अनुमति क्षेत्र।** *Cloud Admin* से **Cloud Accounts**, *Cloud Operator* से **Cloud Operations**, और *Cloud View* से **Cloud Health** खुलता है। Admin को Operator की, और Operator को View की पहुँच विरासत में मिलती है। तीनों पृष्ठ Management में हैं। - **खाते और क्रेडेंशियल।** खाते जोड़ें, संपादित करें, सत्यापित करें और हटाएँ। क्रेडेंशियल या तो बाहर रखी कुंजी फ़ाइल से डेटाबेस में एन्क्रिप्ट होता है (AES-256-GCM), या पोलर की फ़ाइल से पढ़ा जाता है। UI में क्रेडेंशियल केवल लिखे जा सकते हैं और लॉग में छिपाए जाते हैं। - **संग्राहक।** यह हर पोलर निष्पादन पर, प्रति पोलर एक इंस्टेंस के रूप में और समय बजट में शुरू होता है। यह प्रति खाते लीज़ लेता है, अपने अंतराल पर खोज चलाता है और केवल प्लगइन के अपने सक्रिय डेटा स्रोतों के मेट्रिक पढ़ता है। - **स्वास्थ्य।** प्रति-खाता संग्रह, खोज, संसाधन और ताज़गी की स्थिति, साथ में अनुपयोगी वॉल्ट कुंजी, असुरक्षित क्रेडेंशियल फ़ाइल और पोलर के पूरा न कर सकने वाले अंतराल की चेतावनियाँ। @@ -85,7 +85,7 @@ Cacti डिवाइस अनुमतियाँ अब भी प्रत `cacti` को वेब सर्वर और पोलर चलाने वाले उपयोगकर्ता से बदलें। फ़ाइल में 32 मूल बाइट या 64 हेक्साडेसिमल वर्ण होते हैं। डेटाबेस के साथ बैकअप लें; इसके बिना संग्रहीत क्रेडेंशियल दोबारा दर्ज करने होंगे। 3. Cacti में **Configuration > Plugins** खोलें, फिर *Cloud* इंस्टॉल और सक्षम करें। 4. **Configuration > Settings > Cloud** में, अलग पथ उपयोग किया हो तो *Vault Key File* सेट करें। *Collector Time Budget* (डिफ़ॉल्ट 240 सेकंड) पोलर अंतराल से कम होना चाहिए। -5. **Configuration > Users** में उपयोगकर्ताओं और समूहों को *Cloud Admin* या *Cloud View* दें। इंस्टॉल करने पर प्रशासक को दोनों क्षेत्र मिलते हैं। +5. **Configuration > Users** में उपयोगकर्ताओं और समूहों को *Cloud Admin*, *Cloud Operator* या *Cloud View* दें। इंस्टॉल करने पर प्रशासक को Cloud Admin और Cloud View मिलते हैं; Cloud Admin में Operator पहुँच शामिल है, इसलिए प्रशासक को अलग से Operator देने की ज़रूरत नहीं है। 6. **Management > Cloud Accounts** में खाते जोड़ें, फिर **Management > Cloud Health** पर चेतावनियाँ जाँचें। diff --git a/docs/i18n/zh-CN/README.md b/docs/i18n/zh-CN/README.md index 1d14272..32ec371 100644 --- a/docs/i18n/zh-CN/README.md +++ b/docs/i18n/zh-CN/README.md @@ -1,4 +1,4 @@ - + [English](../../../README.md) | [简体中文](README.md) | [हिन्दी](../hi-IN/README.md) | [Español (España)](../es-ES/README.md) | [Español (Latinoamérica)](../es-419/README.md) | [العربية](../ar-SA/README.md) @@ -62,7 +62,7 @@ Cacti 设备权限仍限制各用户可用的行和操作;未映射对象需 - **带保护检查的安装。** PHP 低于 8.2 或缺少 ext-openssl 时,会拒绝安装和启用并给出提示,Cacti 的其他部分继续工作。 - **生命周期。** 通过 Cacti 插件页面安装、升级和卸载。升级按顺序执行,并可从中断中恢复。除非取消 *Keep Plugin Tables on Uninstall*,否则卸载会保留插件表。 -- **独立权限域。** *Cloud Admin* 打开 **Cloud Accounts**;*Cloud View* 打开 **Cloud Health**。两个页面均位于 Management 下。 +- **独立权限域。** *Cloud Admin* 打开 **Cloud Accounts**;*Cloud Operator* 打开 **Cloud Operations**;*Cloud View* 打开 **Cloud Health**。Admin 继承 Operator,Operator 继承 View。三个页面均位于 Management 下。 - **账户和凭据。** 添加、编辑、验证和删除账户。凭据使用保存在数据库外的密钥文件在数据库内加密(AES-256-GCM),或从轮询器上的文件读取。界面中凭据只能写入,日志中会对其进行遮蔽。 - **采集器。** 每次轮询器运行时启动,每个轮询器一个实例,并受时间预算约束。它为每个账户取得租约,以独立间隔执行发现,并仅读取插件自有的活动数据源对应的指标。 - **健康状态。** 显示每账户的采集、发现、资源和新鲜度状态,并对不可用的凭据库密钥、不安全的凭据文件,以及轮询器无法满足的间隔发出警告。 @@ -85,7 +85,7 @@ Cacti 设备权限仍限制各用户可用的行和操作;未映射对象需 将 `cacti` 替换为运行 Web 服务器和轮询器的用户。文件包含 32 个原始字节或 64 个十六进制字符。请将其与数据库一同备份;没有它,必须重新输入已存储的凭据。 3. 在 Cacti 中打开 **Configuration > Plugins**,然后安装并启用 *Cloud*。 4. 在 **Configuration > Settings > Cloud** 中,如果使用了其他路径,请设置 *Vault Key File*。*Collector Time Budget*(默认 240 秒)必须小于轮询器间隔。 -5. 在 **Configuration > Users** 中向用户和组授予 *Cloud Admin* 或 *Cloud View*。安装会向管理员授予这两个权限域。 +5. 在 **Configuration > Users** 中向用户和组授予 *Cloud Admin*、*Cloud Operator* 或 *Cloud View*。安装会向管理员授予 Cloud Admin 和 Cloud View;Cloud Admin 包含 Operator 访问权限,因此管理员无需单独授予 Operator。 6. 在 **Management > Cloud Accounts** 下添加账户,然后在 **Management > Cloud Health** 中检查警告。 diff --git a/include/operator.php b/include/operator.php index 6179886..ab5adf6 100644 --- a/include/operator.php +++ b/include/operator.php @@ -19,6 +19,7 @@ use Somethingwithproof\Cloud\HealthRepository; use Somethingwithproof\Cloud\Verifier; +use Somethingwithproof\Cloud\VerifyStatus; use Somethingwithproof\Cloud\Drivers; /** @return list */ @@ -50,5 +51,5 @@ function cloud_operator_verify(int $id, int $user): void { throw new RuntimeException('Account unavailable'); } $status = (new Verifier(Drivers::production(), cloud_credentials(), $accounts))->verify($account, $user); - raise_message('cloud_operator_verify', $status->message(), MESSAGE_LEVEL_INFO); + raise_message('cloud_operator_verify', $status->message(), $status === VerifyStatus::Ok ? MESSAGE_LEVEL_INFO : MESSAGE_LEVEL_WARN); } diff --git a/lib/AccountsPage.php b/lib/AccountsPage.php index f91ee32..cb42c94 100644 --- a/lib/AccountsPage.php +++ b/lib/AccountsPage.php @@ -183,6 +183,29 @@ public function renderEdit(?Account $account, array $input = [], array $errors = . ''; } + /** + * The step before a delete: the account's name, what deleting removes, + * and a form that repeats the delete with confirm=1. + */ + public function renderDeleteConfirm(Account $account): void { + html_start_box(__('Delete', 'cloud'), '100%', '', '3', 'center', ''); + + print '' . html_escape(__( + 'Delete %s? This removes the account, its stored credential, series mappings, resources and observations, and cannot be undone. Its Cacti devices and graphs are left in place.', + $account->name, + 'cloud' + )) . ''; + + print '
' + . '' + . '' + . '' + . '' + . '
' . html_escape(__('Cancel', 'cloud')) . ''; + + html_end_box(); + } + private function credentialSummary(Account $account): string { return match ($account->credentialSource) { CredentialSource::Vault => $this->credentials->hasVaultCredential($account->id) diff --git a/locales/LC_MESSAGES/ar-SA.mo b/locales/LC_MESSAGES/ar-SA.mo index 9f5602e..6a525d0 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 5708add..fcf4605 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 064b357..e1b3838 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 4f3a4cb..b78cc55 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 f2d9f23..f4c842f 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 0bcc00a..d19c7da 100644 --- a/locales/po/ar-SA.po +++ b/locales/po/ar-SA.po @@ -211,6 +211,15 @@ msgstr "الحد الشهري" msgid "Save" msgstr "حفظ" +#: lib/AccountsPage.php +#, php-format +msgid "Delete %s? This removes the account, its stored credential, series mappings, resources and observations, and cannot be undone. Its Cacti devices and graphs are left in place." +msgstr "هل تريد حذف %s؟ سيؤدي ذلك إلى حذف الحساب وبيانات الاعتماد المخزّنة وتعيينات السلاسل والموارد والملاحظات، ولا يمكن التراجع عنه. ستُبقى أجهزته ورسومه البيانية في Cacti." + +#: lib/AccountsPage.php +msgid "Cancel" +msgstr "إلغاء" + #: lib/AccountsPage.php msgid "Stored in the vault" msgstr "مخزّنة في الخزنة" diff --git a/locales/po/cacti.pot b/locales/po/cacti.pot index ade056a..a43602e 100644 --- a/locales/po/cacti.pot +++ b/locales/po/cacti.pot @@ -213,6 +213,15 @@ msgstr "" msgid "Save" msgstr "" +#: lib/AccountsPage.php +#, php-format +msgid "Delete %s? This removes the account, its stored credential, series mappings, resources and observations, and cannot be undone. Its Cacti devices and graphs are left in place." +msgstr "" + +#: lib/AccountsPage.php +msgid "Cancel" +msgstr "" + #: lib/AccountsPage.php msgid "Stored in the vault" msgstr "" diff --git a/locales/po/es-419.po b/locales/po/es-419.po index 70613ab..852d8c4 100644 --- a/locales/po/es-419.po +++ b/locales/po/es-419.po @@ -211,6 +211,15 @@ msgstr "Límite mensual" msgid "Save" msgstr "Guardar" +#: lib/AccountsPage.php +#, php-format +msgid "Delete %s? This removes the account, its stored credential, series mappings, resources and observations, and cannot be undone. Its Cacti devices and graphs are left in place." +msgstr "¿Eliminar %s? Se eliminarán la cuenta, su credencial almacenada, las asignaciones de series, los recursos y las observaciones, y no se puede deshacer. Se conservarán sus dispositivos y gráficos de Cacti." + +#: lib/AccountsPage.php +msgid "Cancel" +msgstr "Cancelar" + #: lib/AccountsPage.php msgid "Stored in the vault" msgstr "Almacenada en la bóveda" diff --git a/locales/po/es-ES.po b/locales/po/es-ES.po index 8a849cc..0063e3b 100644 --- a/locales/po/es-ES.po +++ b/locales/po/es-ES.po @@ -211,6 +211,15 @@ msgstr "Límite mensual" msgid "Save" msgstr "Guardar" +#: lib/AccountsPage.php +#, php-format +msgid "Delete %s? This removes the account, its stored credential, series mappings, resources and observations, and cannot be undone. Its Cacti devices and graphs are left in place." +msgstr "¿Eliminar %s? Se eliminarán la cuenta, su credencial almacenada, las asignaciones de series, los recursos y las observaciones, y no se puede deshacer. Se conservarán sus dispositivos y gráficos de Cacti." + +#: lib/AccountsPage.php +msgid "Cancel" +msgstr "Cancelar" + #: lib/AccountsPage.php msgid "Stored in the vault" msgstr "Almacenada en la bóveda" diff --git a/locales/po/hi-IN.po b/locales/po/hi-IN.po index a982eec..8f87029 100644 --- a/locales/po/hi-IN.po +++ b/locales/po/hi-IN.po @@ -211,6 +211,15 @@ msgstr "मासिक सीमा" msgid "Save" msgstr "सहेजें" +#: lib/AccountsPage.php +#, php-format +msgid "Delete %s? This removes the account, its stored credential, series mappings, resources and observations, and cannot be undone. Its Cacti devices and graphs are left in place." +msgstr "%s हटाएँ? इससे खाता, उसका संग्रहीत क्रेडेंशियल, सीरीज़ मैपिंग, संसाधन और अवलोकन हट जाएँगे, और इसे पूर्ववत नहीं किया जा सकता। उसके Cacti डिवाइस और ग्राफ़ यथावत रखे जाएँगे।" + +#: lib/AccountsPage.php +msgid "Cancel" +msgstr "रद्द करें" + #: lib/AccountsPage.php msgid "Stored in the vault" msgstr "वॉल्ट में संग्रहीत" diff --git a/locales/po/zh-CN.po b/locales/po/zh-CN.po index 0486adf..bcba113 100644 --- a/locales/po/zh-CN.po +++ b/locales/po/zh-CN.po @@ -211,6 +211,15 @@ msgstr "每月上限" msgid "Save" msgstr "保存" +#: lib/AccountsPage.php +#, php-format +msgid "Delete %s? This removes the account, its stored credential, series mappings, resources and observations, and cannot be undone. Its Cacti devices and graphs are left in place." +msgstr "删除 %s?这将删除该账户、其已存储的凭据、序列映射、资源和观测数据,且无法撤销。其 Cacti 设备和图表将保留。" + +#: lib/AccountsPage.php +msgid "Cancel" +msgstr "取消" + #: lib/AccountsPage.php msgid "Stored in the vault" msgstr "已存入凭据库" diff --git a/tests/bin/page-permissions.php b/tests/bin/page-permissions.php index 0c9bf9a..8957bcd 100644 --- a/tests/bin/page-permissions.php +++ b/tests/bin/page-permissions.php @@ -26,7 +26,8 @@ * norealm Console only: both pages are denied * * Then shows that a delete sent as GET, or as POST without the csrf-magic - * token, has no effect, and that the same delete as a proper POST works. + * token, has no effect, that a proper POST asks for confirmation, and that + * the confirmed delete works. * Then it saves an account with a vault credential through the form and * searches every response, the Cacti log, and every plugin table for the * credential (#32). Last (#45), it views a cloud graph as users allowed and @@ -210,12 +211,23 @@ function perm_login($user) { perm_expect($exists(), 'a delete POST without the csrf-magic token has no effect'); list(, $list) = perm_http($base . 'cloud_accounts.php', $jar); -perm_http( +list(, $confirm) = perm_http( $base . 'cloud_accounts.php', $jar, array('__csrf_magic' => perm_token($list), 'action' => 'delete', 'id' => $probe) ); -perm_expect(!$exists(), 'the same delete as a POST with the token removes the account'); +perm_expect( + $exists() && strpos($confirm, 'name="confirm" value="1"') !== false + && strpos($confirm, '') === false, + 'a delete POST with the token asks for confirmation, escapes the name, and removes nothing' +); + +perm_http( + $base . 'cloud_accounts.php', + $jar, + array('__csrf_magic' => perm_token($confirm), 'action' => 'delete', 'id' => $probe, 'confirm' => '1') +); +perm_expect(!$exists(), 'the confirmed delete removes the account'); // A credential saved through the form must come back in no response, no // log line, and no plugin table. @@ -301,6 +313,21 @@ function perm_login($user) { } } +// Moving the account to a credential file drops the vault copy, so +// switching back later cannot revive it. +list(, $edit) = perm_http($base . 'cloud_accounts.php?action=edit&id=' . $account, $jar); +perm_http($base . 'cloud_accounts.php', $jar, array( + '__csrf_magic' => perm_token($edit), 'action' => 'save', 'id' => $account, 'provider' => 'digitalocean', + 'name' => $probeName, 'poller_id' => 1, + 'credential_source' => 'file', 'credential_file' => '/etc/cacti/cloud-probe.json', 'collect_interval' => 300, + 'discover_interval' => 3600, 'request_share' => 50, 'enabled' => 'on', +)); +perm_expect( + db_fetch_cell_prepared('SELECT credential_source FROM plugin_cloud_account WHERE id = ?', array($account)) === 'file' + && (int) db_fetch_cell_prepared('SELECT COUNT(*) FROM plugin_cloud_secret WHERE account_id = ?', array($account)) === 0, + 'switching an account from the vault to a credential file removes the stored credential' +); + perm_expect( count($responses) === 6 && $leaks === array(), 'the credential appears in no response, log, or table' . ($leaks === array() ? '' : ': ' . implode( @@ -429,7 +456,7 @@ function perm_login($user) { perm_http( $base . 'cloud_accounts.php', $revokedJar, - array('__csrf_magic' => perm_token($before), 'action' => 'delete', 'id' => $graphAccount) + array('__csrf_magic' => perm_token($before), 'action' => 'delete', 'id' => $graphAccount, 'confirm' => '1') ); perm_expect( (int) db_fetch_cell_prepared('SELECT COUNT(*) FROM plugin_cloud_account WHERE id = ?', array($graphAccount)) === 1,