157 Commits
Author SHA1 Message Date
10c93541dd issue: shorten thold VRULE graph drilldown button title (#855)
* issue: shorten thold VRULE graph drilldown button title

The graph action menu now renders each drilldown button's title as a visible label, so 'Toggle Threshold VRULES %s' reads as an overlong menu entry. Shorten it to 'Toggle VRULES %s', add a unit test exercising thold_graph_button()'s VRULE branch (with the two missing request-var stubs it needs) so the changed line stays covered, and regenerate locales/po/cacti.pot.

* Update copyright notice in TholdGraphButtonTest.php

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

* Fix Last-Translator entry in cacti.pot

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

* test: cover the VRULEs-enabled 'Off' title branch for patch coverage

---------

Co-authored-by: TheWitness <1439914+TheWitness@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-10-13 12:38:48 -04:00
TheWitness 9da2bc9967 bug: pass bool (not int) to api_plugin_register_hook() $enable (#852)
* bug: pass bool (not int) to api_plugin_register_hook() enable argument

Cacti 1.3 types api_plugin_register_hook() 5th arg as bool enable. These calls passed int 1, which only coerces while the file lacks declare(strict_types=1); pass true so they stay type-correct. php -l clean.

* Exclude live-DB reinstall body of plugin_thold_install() from coverage

* bug: pass bool true (not string '1') at remaining register-hook upgrade sites

Convert the 17 other api_plugin_register_hook() 5th arguments in includes/database.php from the string '1' to boolean true so the upgrade/re-registration paths are strict_types-safe against Cacti develop's bool \ signature.
2026-10-08 15:21:20 -04:00
TheWitness 4d432a2e20 thold: status pills with sortable/clickable Status column and zebra rows (#851)
* thold: status pills with sortable/clickable Status column and zebra rows

Replace the whole-row status colour on the Thresholds (thold.php) and Device Status (thold_graph.php) pages with a rounded status pill in a new Status column right of Name; rows now fall back to zebra striping. The column is server-side sortable by severity via a new thold_severity_sql() CASE (a faithful SQL mirror of get_thold_severity(), legend-order rank 1=Alert..7=Disabled), the Status filter gains the seven per-severity options (values 101-107 handled in thold_get_state_filter()), and clicking a pill sets that filter and reloads. Pill shape lives in a theme-agnostic css/pills.css; all colours stay theme-aware (reusing each theme's .thold<State> backgrounds, with light pill text added to the saturated classic/modern/paw themes). Adds Pest coverage for thold_severity_sql() and the severity filter branch.

* thold: regenerate cacti.pot for the status-pill i18n strings

* thold: address review - pill contrast, time_warning_low '0' parity, keyboard a11y, stronger test

Light themes (classic/modern/paw all have white/snow backgrounds) now use dark pill text instead of white, which failed 4.5:1 at 11px. thold_severity_sql() treats time_warning_low '0' as falsy (NOT IN ('','0')) to match get_thold_severity(), so the pill never disagrees with sort/filter. Pills are now focusable role=button spans with Enter/Space activation on both pages. TholdSeveritySqlTest now executes the CASE over an in-memory SQLite row and asserts the SQL rank equals get_thold_severity() across branch/boundary scenarios incl. the '0' case.
2026-10-08 14:58:54 -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 614c4883b6 thold: define plugin_thold_csp_nonce() in thold_functions.php so plugin pages do not fatal (#835)
* thold: define plugin_thold_csp_nonce() in thold_functions.php

Fixes a fatal 'Call to undefined function plugin_thold_csp_nonce()' in
thold.php (and the other plugin pages) when they load without setup.php
(e.g. after the plugin is disabled by an error). The helper lived only in
setup.php, but every plugin page includes thold_functions.php - not
setup.php - so move the definition there. setup.php now require_once's
thold_functions.php so its page_head/device/settings hook callbacks, which
also run on core Cacti pages, keep resolving the helper.

* thold: scope-load thold_functions.php in the nonce hooks, not at setup.php top

Address review: don't require the full ~11k-line thold_functions.php at
setup.php top level (it loaded on every core page via page_head and during
CLI/poller). Instead each nonce-emitting hook (page_head, host/device/
template edit, settings) require_once()'s it when it actually fires;
require_once dedupes so the first hook on a page loads it once. Point
CspNonceTest at thold_functions.php directly so it guards the inclusion-
path regression.
2026-09-29 13:08:32 -04: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
Petr Macek d43d679761 fix #721 - notification lists isn't visible (#738)
* fix #721 - notification lists isn't visible

* add missing column

* temporary disable check
2026-01-28 08:42:36 -05:00
TheWitness a7991dc6cf QA: Update Copyrights to 2025 2025-06-16 09:26:09 -04:00
TheWitness deb6719f44 QA: Fix Adding/Remove Thold Templates from Devices 2024-04-05 19:20:19 -04:00
TheWitness 5bc909d372 QA: Fixing issues related to Cacti 1.3 Integration 2024-04-05 17:35:49 -04:00
TheWitness 4875931cf0 QA: Don't let the user add the Thold Template Twice
This is applicable to the Device Templates.
2024-04-05 16:47:33 -04:00
TheWitness 9cd6622c86 Fixing Issue #656 - Duplicate Templates 2024-01-30 20:30:17 -05: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
TheWitness 2eaf5df521 Fixing #643 - Adding Thold Template to Device Template
* Specifically to address Cacti 1.3 issue.
* Adding Threshold Template to new Device template Targets to itself (template is added.. possibly a Thold plugin issue?)
2023-11-24 09:11:19 -05:00
TheWitness d53222e82c QA: Tune Notification Delay
These changes simply make the settings delay a Cacti styled Multi-Select.
2023-07-30 10:00:24 -04:00
TheWitness c6501c1911 Starting #590 - Just the settings with some outstanding issues
Found that there is no good way to hook the settings page without a global JavaScript file.  Really need a hook at the bottom of the settings page.
2023-07-27 21:48:06 -04:00
TheWitness b66b86a703 QA: Add Notify Queue UI
* Todo: Make suspension/resumption work
* Todo: Delete individual events
* Todo: Add Object Name as a column
* Todo: Add event_processing_time double to table
* Todo: Sort on name and filter by type Event Type, and Processed
2023-07-24 10:00:36 -04:00
TheWitness 21c921b888 Issue #435 - Notification Queue Implementation
This is the beginning of the notification queue.
It is not complete yet as the daemon and data collector must still be written.
Then the command line executor will have to be written as well.

Columns that have yet to be added include: environment, and process_id

It's likely that I will change the schema ever so slightly before I'm done as well.
2023-07-22 21:18:19 -04:00
TheWitness 9a05ed6fc0 Fixing #445 More selective auto-create
Allow removal of Threshold from a specifc device ignoring device template
2023-07-22 16:03:20 -04:00
TheWitness 45c643d224 Additional minor QA: #486 - Skipscale
This changes the defaults and adds a rand() call to get the image to change upon changing the scipscale setting
2023-07-22 13:41:49 -04:00
TheWitness fe2053079f Fixing #486 - Add Skipscale to HRules
add ":skipscale" option to prevent diagram area from being scaled by threshold lines, thus losing granularity in the graphs
2023-07-22 13:25:22 -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
Jing Chen 90ff2d5ca9 Fixed: incorrect function name since 6c357c9d for cacti develop branch (#559) 2022-10-25 10:31:58 -04:00
TheWitness 0ad70fbf53 Clear a read_config_option that always queries
This is due to the setting not being anywhere in Cacti.  Thold just keeps calling it.
2022-02-28 20:59:13 -05:00
TheWitness 33a1342835 Fixing Issue #542 and Copyright Years 2022-02-13 13:21:17 -05:00
TheWitness 22947bd695 Fixing Issue #520 - Errors logged when creating a threshold
This resolves an error that takes place within the thold plugin that results in downstream errors.  This change addresses only the warnings generated from #520, but likely not fixing the underlying issues though.
2021-09-06 12:18:45 -04:00
browniebraun 945f81aa0f small clean up 2021-01-13 23:49:42 +01:00
ahoustonandTheWitness d528b18200 Fix DS not found issue from #474 (#478)
* Fix DS not foun issue from #474

* Update setup.php

Co-authored-by: TheWitness <thewitness@cacti.net>
2020-12-12 11:56:33 -05:00
TheWitness 9c68288947 Fix travis. 2020-12-05 10:02:50 -05:00
ahoustonandTheWitness 8d1dc7acd1 Fix: Create threshold from templates fail with multiple data template ids (#474)
* Fix: Create threshold from templates fail with multiple data sources

* updated hard tabs and CHANGELOG.md

* Update CHANGELOG.md

* Update CHANGELOG.md

* Update CHANGELOG.md

* Update CHANGELOG.md

* Fixing softtabs

* Update setup.php

* Update setup.php

* Correcting unchecked bounds

* Correcting bogus logic

Co-authored-by: TheWitness <thewitness@cacti.net>
2020-12-05 09:37:55 -05:00
TheWitness 8a0a7f01de Missed two cases around percentage display 2020-10-28 12:38:57 -04:00
TheWitness 6660ab3155 Percentage threholds that show horizontal rule are cut off 2020-10-28 12:27:29 -04:00
TheWitness 035d757efa Fixing Issue #449
Notification List is not saved when adding new device
2020-10-28 10:32:03 -04:00
Jimmy Conner 8235fb7f35 Add an option per Thresold to display Units
This fixes readability issues for times that you don't necessarily care about extremely small numbers.
2020-10-20 15:49:34 -05:00
TheWitness efe24be877 Feature Migrate Images to Fontawesome Glyphs
* Migrate Images to FontAwesome Glyphs
* Move CHANGELOG.md to separate file
* Correct bug with VRULES that generated warnings
2020-10-02 17:39:42 -04:00
Manuel MauszandTheWitness 11063b63b6 Add support for upper + lower bytes calculation (#443)
Using this data type manipulation allows to calculate the total value
from upper and lower 4 bytes of data. e.g. OID dskAvailLow + dskAvailHigh

See also http://www.muonics.com/Docs/MIBSmithy/UserGuide/commonerrors.php#counter64

Co-authored-by: TheWitness <thewitness@cacti.net>
2020-09-13 12:25:27 -04:00
TheWitness 0059966c4c Additional QA Testing
Fixing threshold messages
Fixing partitioning of messages when creating enmass
2020-09-12 20:44:41 -04:00
TheWitness 7fc9def1e4 Light QA work on pull request #429, bumping version 2020-09-12 11:35:48 -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
TheWitness 0e82a7fbc2 Use linkEditMain vs. hyperLink
This goes to a consistent user experience.
2020-03-27 14:04:40 -04: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 25987e9b0a Fixing Issues #342, #343, #344
* issue#342: Unable to include thold_functions.php in thold regex function
* issue#343: Call to undefined function db_fetch_cell_assoc()
* issue#344: Thold VRules Display is subject to XSS Attack
2019-06-24 10:57:57 -04:00
TheWitness f5f8e337f9 Fixing Issue #324 and better display
* value not correct in Thold - Log page
* No changelog as this is new feature
* Rename functions to ease confusion on purpose
* Support very small numbers for additional threshold use cases
2019-05-24 20:42:34 -04:00
TheWitness 70caaa303e Correcting some minor bugs 2019-05-22 15:12:10 -04:00