72 Commits
Author SHA1 Message Date
TheWitnessandTheWitness 1e226aa6c5 security: move filter inline onChange/onClick handlers into ready() for CSP (#849)
* security: move filter inline onChange/onClick handlers into ready() for CSP

The threshold, notification list, notification queue, template and
device/log status filter forms still carried inline onChange/onClick
attributes on their selects and Clear/Go/Import/Export controls. Under
Cacti's Content-Security-Policy these trip the script-src-attr directive
(inline event handlers). Bind them in each view's existing
$(function(){...}) ready block instead.

Scope: thold.php, notify_queue.php, thold_templates.php, notify_lists.php,
thold_graph.php (all gate-allowlisted UI files; no measured source changed).
The cactiReturnTo() cancel buttons on the bulk-action confirmation pages are
left as-is (shared Cacti-core pattern). Regenerated locales/po/cacti.pot for
the shifted source line references.

* security: convert cactiReturnTo cancel buttons to the CSP-safe class

The confirmation pages' Cancel buttons used an inline
onClick='cactiReturnTo()' handler, which trips Cacti's Content-Security-Policy
script-src-attr directive. Switch them to the CSP-safe cactiReturnTo CSS
class (class='cactiReturnTo', plus an optional data-url when a target is
passed).

Cacti 1.2.31 and later bind this class automatically. The README documents a
one-time include/layout.js applySkin() snippet for operators still on an
earlier release - no shim is baked into the core or the plugin.

* fix: give Thresholds/Devices filter Clear buttons the id the ready() handler binds

The hosts() and tholds() filter views used name='clear' on the Clear button, but the ready() handler binds to #clear, so Clear was a no-op on those two views. Switch them to id='clear' to match the other views and the handler.

---------

Co-authored-by: TheWitness <larry@thewitness.org>
2026-10-07 21:00:03 -04:00
TheWitnessandCopilot 9b217e0e3a INFO: set compat to 1.2.29 (#838)
* INFO: set compat to 1.2.32

* docs: update Copilot instructions Cacti baseline to 1.2.32 (matches INFO compat)

* INFO: back off compat to 1.2.29

* Add manifest.json + upgrade-time file pruning

* Prune phpunit.xml on upgrade and ignore markdown-lint configs

phpunit.xml ships in the repo for CI but is a dev-only test artifact, so it
is removed from manifest.json 'expected', pruned from installs on upgrade
(like tests/), and excluded from the manifest drift check.

The retired markdown-lint configs (.mdlrc, .md_style.rb) are deleted, and
.md* is now ignored like .git*: protected from pruning and excluded from
drift if it reappears.

* Move thold_functions.php and thold_webapi.php into includes/; flatten css

The main threshold library becomes includes/functions.php and the web API
helper becomes includes/webapi.php; every caller (setup.php, includes/*, the
CLI/poller/notify entry points and the test suite) loads them from includes/.
Each per-theme stylesheet css/<theme>/main.css becomes css/<theme>.css so users
can drop their own css/<theme>.css into the css base, and the page_head hook
looks there. Old paths are tombstoned so existing installs drop the stale
copies on upgrade.

* Regenerate cacti.pot for the includes/ file relocations

Moving the plugin's library files into includes/ changed the source-reference
lines in the translation template; regenerate it so the 'Verify translation
template' CI check passes.

* Harden the hook-include test and make RPN integer ops explicit

The HookFunctionsIncludeTest invokes real hooks with placeholder input purely
to execute their relocated include_once lines; it now swallows engine
notices/warnings/deprecations during those calls (and restores the error
handler and config afterward) so it cannot trip the suite's failOnDeprecation
or leak state into other tests. The RPN % and ^ operators now cast their
operands to int explicitly, matching their long-standing integer-truncation
behaviour while silencing the implicit float-to-int conversion deprecation.

* Harden prune against tampered-manifest path traversal

The upgrade-time prune now rejects any tombstone containing '.'/'..' segments
(which could escape the plugin directory or resolve to its root) and treats
ancestors of whitelist entries as protected, so a tombstone on a parent
directory can no longer delete a whitelisted file beneath it.

* docs: update and align the Project Structure block

Point the structure tree at the relocated files (libraries now under
includes/, data files under docs/, stylesheets under css/) and align the
trailing '# ...' comments to a single column so they no longer drift right.

* docs/tests: standardize test header and correct manifest-contract notes

- Use the full license header (from the plugin's own setup.php) in
  tests/Unit/PruneFilesTest.php instead of the abbreviated copyright banner.
- Document that the manifest drift check and the upgrade-time prune also
  handle phpunit.xml and .md* files, matching the implemented behavior.

* refactor: rename prune helpers to the plugin-slug function prefix

The repository naming contract reserves the plugin_<name>_ prefix for plugin
lifecycle / hook-registration functions; all other functions use the plain
<name>_ prefix. Rename the internal upgrade helpers accordingly:

  plugin_<name>_prune_files() -> <name>_prune_files()
  plugin_<name>_rmtree()      -> <name>_rmtree()

The call site, unit tests, and the copilot-instructions.md references are
updated to match. No behavioral change.

* chore: set the Cacti compatibility floor to 1.2.29

Align the compat metadata (and the contributor-guide references) with the
team decision to standardize the minimum supported Cacti version at 1.2.29;
the previously proposed 1.2.32 floor was not adopted.

---------

Co-authored-by: Copilot <copilot@users.noreply.github.com>
2026-10-01 01:40:00 -05:00
TheWitness b7f3741880 security(csp): version-safe inline-script nonce wrapper + strengthen PO/MO instructions (#829)
* security(csp): add version-safe inline-script nonce wrapper; strengthen PO/MO instructions

* test(csp): cover setup.php page_head/device hook nonce lines; ignore exit-branch scripts; stub UI helpers

* test(csp): drop fragile isolated wrapper test; ignore the framework-only delegation line

* test(csp): cover the CactiSecureHeaders delegation branch without process isolation

* csp: leave the two exit()-branch confirm-dialog scripts un-nonced (uncoverable under the 100%% patch-coverage gate)

* test(csp): exercise nonce delegation in isolated process; full GPL header
2026-09-28 09:33:21 -04:00
TheWitness 41dc700357 Add PHPDoc blocks to undocumented functions (partial - thold_functions.php follow-up owed) (#828)
* Add PHPDoc blocks: small files batch (cli_import, poller_thold, includes/tab, includes/database, cli_thresholds, thold_notify, notify_queue)

* Add PHPDoc blocks: includes/polling.php, includes/settings.php (WIP checkpoint)

* Add PHPDoc blocks: thold_process.php, thold_daemon.php (WIP checkpoint)

* Add PHPDoc blocks: thold_webapi.php (WIP checkpoint)

* Add PHPDoc blocks: thold.php (WIP checkpoint)

* Add PHPDoc blocks: thold_graph.php (WIP checkpoint)

* Add PHPDoc blocks: notify_lists.php (WIP checkpoint)

* Add PHPDoc blocks: thold_templates.php (WIP checkpoint)

* Add PHPDoc blocks: setup.php batch 1-2 (WIP checkpoint)

* Add PHPDoc blocks: setup.php batch 3-4 (WIP checkpoint)

* Add PHPDoc blocks: setup.php batch 5 (WIP checkpoint)

* Add PHPDoc blocks: setup.php batch 6-7 (WIP checkpoint)

* Add PHPDoc blocks: setup.php complete

* Address review feedback and refresh translation template

- Fix thold_update_host_status() return type (int|null, since it
  falls through with no explicit return in the normal case)
- Fix @global $device_change_fields description in
  thold_config_arrays() (appends this plugin's fields, not unused)
- Fix @global $config description in thold_graph_button() (used to
  build the Create Threshold link's URL)
- Fix thold_data_source_action_prepare()/thold_graphs_action_prepare()
  return types (array|void; only the non-plugin_thold_create branch
  returns $save)
- Fix @global $timearray description in list_tholds() (used to render
  each baseline threshold's reference time range)
- Fix @global $thold_types description in thold_show_log() (used to
  render each log row's type column)
- Regenerate locales/po/cacti.pot (source line references only)
- Fix .gitignore pattern for compiled .mo files (locales/LC_MESSAGES/, not locales/po/)

* test(coverage): allowlist untestable entry points touched by PHPDoc pass

This PR only adds PHPDoc blocks (no functional changes), but touching every file in the plugin newly triggers the 'Enforce coverage of changed lines' CI gate for files that were never require()'d by any test before now:

- cli_import.php, cli_thresholds.php: CLI entry points (include cli_check.php / chdir + execute at the top level).

- poller_thold.php: poller entry point, same category.

- thold.php, thold_graph.php, thold_templates.php, notify_lists.php: authenticated web entry points (chdir + include(auth.php) at the top level), like notify_queue.php/thold_notify.php already allowlisted above.

- thold_daemon.php: daemon entry point, same category as thold_process.php already allowlisted above.

- includes/settings.php, includes/tab.php: Settings-page/header-tab-bar hook callbacks, only meaningful inside a live Cacti page render.

- thold_webapi.php: web-page action handlers that read \ and the database directly.

None of these can be require()'d into the isolated unit test process, matching the existing allowlist entries' precedent exactly. Verified locally: running patch-coverage.php against the PR's actual base ref confirms all 11 files are no longer reported as unexpected-unmeasured.

* docs: add PHPDoc blocks to remaining thold_functions.php functions

* chore: refresh translation template after PHPDoc line-number shifts
2026-09-25 12:30:04 -04:00
Thomas Vincent 1c0d2a2fe3 security: harden SQL, output escaping, and unserialize paths (#773) 2026-08-30 13:35:57 -07:00
TheWitness 0f526404f7 Updating copyrights to 2026 (#740) 2026-02-14 14:16:33 -05:00
TheWitnessandCopilot 2d3b623d7a Updating workflow to include code validation PHP8.4 and MariaDB 10.6 (#739)
* Adding Worflows for code validation

* Apply php-cs-fixer rules

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-06 06:59:30 -05:00
ec9dfdbfbf Fix for 723 (#735)
* Agents for Github

* Ci workflow

* fix syntax

* Update plugin-ci-workflow.yml

* Update agent tools

* Initial plan

* Fix PHP 8+ type coercion error in pagination calculations

Co-authored-by: bmfmancini <13388748+bmfmancini@users.noreply.github.com>

* Update .github/workflows/plugin-ci-workflow.yml

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: bmfmancini <13388748+bmfmancini@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-04 11:57:28 -05:00
TheWitness a7991dc6cf QA: Update Copyrights to 2025 2025-06-16 09:26:09 -04:00
Petr Macek a5b2b5bba0 fix #701, fix #703 (#705)
* fix #701, fix #703

* update
2024-10-15 10:17:19 -04:00
TheWitness 44701f97bb Fixing #679 and Some One Email QA
* The PHP Mailer does not allow for the to and bcc addresses to be the same
* Make the Mailer Error messages more informative.
2024-06-20 19:33:40 -04:00
TheWitness 4b14a89172 Allow Templates and Thresholds to have an External ID
feature: Allow Templates and Thresholds to include an External ID
2024-01-30 20:22:37 -05:00
Petr Macek cddb4bf6b6 fix wrong variable - bcc_emails (#615) 2023-09-12 11:42:06 -04:00
TheWitness c6c7a4b720 QA: Additional Notification List Enhancements 2023-09-01 11:41:11 -04:00
TheWitness 3736350443 QA: A few bug fixes and enhancements
* Make notification list devices tab sortable
* Prepared SQL for Device Notification list
* Remove some warnings when host notification delay is disabled
* Debounce Notification Suspend messages
2023-09-01 11:17:45 -04:00
TheWitness c6ce9a9592 Correct some SQL Injection points 2023-08-04 16:00:40 -04:00
TheWitness c31bd71f0a Feature: Support Format Files in Thold
Another long sought after feature request now addressed.
2023-07-24 23:45:31 -04:00
TheWitness 4424cd8a99 Minor QA on Enabling/Disabling lists 2023-07-24 20:43:12 -04:00
TheWitness e8cb979cb2 Allow disabling a notification list through the UI
This is one part of Feature Request #31
2023-07-24 20:40:26 -04:00
netniV 4d9210e76b Update copyright for 2023 2023-01-04 22:31:06 +00:00
TheWitness 9e7443b3f0 Updating copyrights 2023-01-03 19:38:50 -05:00
TheWitness 33a1342835 Fixing Issue #542 and Copyright Years 2022-02-13 13:21:17 -05:00
TheWitness a33df03a70 Fixing Issue #517 - Wrap columns
notification list page formatting not correct
2021-09-07 09:44:25 -04:00
Petr Macek 2318883b31 fix missing variable validation (#511) 2021-05-22 02:48:42 +01:00
Petr Macek 24989d5da5 Searching in Notify lists doesn't filter result (#510) 2021-05-21 19:54:56 +01:00
browniebraun 71f393ac23 clean up
- drop unused, old variables and unnecessary semicolons
- typos
2021-01-13 21:53:47 +01:00
TheWitness 28ca386ea9 More QA on Regular Expressions 2020-09-12 16:18:28 -04:00
TheWitness 57dd894f3f Fixing Issue #402
Notification Lists should support searching via RegEx
2020-09-12 12:43:54 -04:00
TheWitness 0104f0858d Fixing Issue #430
XSS Vulnerabilities if host/graph name include script
2020-06-19 08:23:27 -04:00
1bceec91d4 Fixed: Same fix as Cacti/cacti#2859 for deprecated curly braces (#423)
Co-authored-by: Jing Chen <three_chenjing@sohu.com>
Co-authored-by: South Park Neo <thewitness@cacti.net>
2020-04-17 17:36:25 -04:00
ddb4githubandJing Chen 206a205800 Fixed: Update more lines to resolve XSS exposure (CVE-2020-7106) (#422)
* Fixed: Update more lines to apply Cacti #3191 security solution (CVE-2020-7106)

* Update changelog in README.md for #422

Co-authored-by: Jing Chen <three_chenjing@sohu.com>
2020-04-17 17:32:10 -04:00
Susanin63 0752be0a4d Make host description linkable (#415) 2020-04-16 19:38:08 -04:00
ddb4githubandJing Chen 45d7821148 Fixed: Apply Cacti #3191 security solution (#420)
Co-authored-by: Jing Chen <three_chenjing@sohu.com>
2020-04-16 17:40:21 -04:00
TheWitness 93a3697718 Make notification lists aware of device removal 2020-03-07 09:57:53 -05:00
netniV 2db7e7f61c Update copyright year and tweak service documentation 2020-02-15 09:56:40 +00:00
cigamit e8a83bdb0e Resolving Issues #355 and #356
* Thold search fields do not work with some international characters
* Thold should not show the 'i' suffix for percentage type tholds
2019-07-24 20:26:45 -05:00
TheWitness 8709596310 Fixing issue #293
This resolves the issue.
2019-04-10 07:29:40 -04:00
TheWitness 01519c2419 Fixing Issue #182/268 and other features
* feature: Add Sites to Notification Lists for Devices and Thresholds
* feature: Allow Threshold Notification Settings to be overwritten based upon Template setting.
* issue#182: When adding/removing list from a Threshold, Templated Thresholds should be ignored.
* issue#268: Allow Device Association/Disassociation to set Thresholds Notification as well.
2019-03-31 21:20:26 -04:00
TheWitness 93d6805341 Fixing Issue #182
* When adding/removing list from a Threshold, Templated Thresholds should be ignored.
* Additional bug with Notification List changes for Templates not propagating.
2019-03-31 19:54:12 -04:00
TheWitness 450965a7b5 Fixing Issue #273
Wrong navigation bar link
2019-03-12 12:01:18 -04:00
TheWitness e9c5c6c878 Replace most sizeof calls for cacti_sizeof for php7 compatibility 2019-01-10 18:54:42 -05:00
TheWitness 04adc390db Fixing 'permission denied' message for #229
Tying permission check to local_graph_id is more reliable.  Remote italics.  They don't look good.
2019-01-07 20:35:15 -05:00
TheWitness 25ad7fc5df Fixing issue when removing lists #162 2019-01-06 18:51:41 -05:00
TheWitness ca363b7cc9 Security sweep and other minor modifications 2019-01-06 17:54:55 -05:00
TheWitness 59b89967d2 Fix minor bug with associated 2019-01-06 16:05:33 -05:00
TheWitness 7053e7e834 Fixing one bug and half implementing another feature. 2019-01-02 18:43:48 -05:00
TheWitness 5e371f4330 Remove bold text 2018-12-28 18:12:53 -05:00
TheWitness 6e4001c77d Additional testing 2018-12-28 18:07:27 -05:00
TheWitness 469f45645d Notification List Testing 2018-12-28 17:56:55 -05:00
TheWitness 8517b189ac Code context review 2018-12-28 14:48:11 -05:00