Skip to content

INFO: set compat to 1.2.29 - #838

Merged
cigamit merged 13 commits into
developfrom
chore/compat-1.2.32
Oct 1, 2026
Merged

cigamit merged 13 commits into
developfrom
chore/compat-1.2.32

Conversation

@TheWitness

@TheWitness TheWitness commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Summary

Two changes for this plugin:

  1. INFO compat floor — sets the plugin's compat (minimum supported Cacti version) in INFO to 1.2.29.
  2. File manifest + upgrade-time pruning — adds the fleet manifest.json + prune mechanism, and consolidates the per-theme themes/ directory into the conventional css/ directory.

themes/ → css/

The per-theme themes/<theme>/main.css files are relocated to css/<theme>/main.css (git mv, history preserved) to match the fleet convention, and thold_page_head()'s stylesheet reference is repointed to css/. The retired themes/ directory is recorded as a manifest tombstone so it is removed from an upgrading install. (The SetupCspHooksTest fixture tree and assertion were updated to the new css/ path.)

File manifest + upgrade pruning

  • New root manifest.json with tombstones = ["themes/"], expected (the current top-level tree; directories carry a trailing /), and whitelist (empty — thold stores its data in the database, not under the plugin directory).
  • thold_prune_files() (in setup.php, called from the version-change branch of plugin_thold_upgrade() after plugin_thold_install(true)) removes the tombstoned themes/ tree plus the dev-only tests/ tree on upgrade, refuses any path resolving outside the plugin directory (a tampered manifest.json), warns in the Cacti log on any file/directory it cannot remove, leaves whitelist/.git* alone, and logs — without removing — any unaccounted top-level entry.
  • tests/bin/validate-manifest.php (wired into plugin-ci-workflow.yml) fails on drift between expected and the real top-level tree.
  • Added tests/Unit/PruneFilesTest.php plus an Integration case that drives the version-drift branch with the full reinstall short-circuited (via the install version guard) and base_path sandboxed to a throwaway tree, so the new prune call line is covered without needing a live Cacti include/database.php.

Docs

  • README.md: extended the Threshold Daemon section with an upgrade note — restart the thold_daemon systemd service after a file upgrade so the long-lived process picks up the new code; also notes the upgrade-time prune of bundled dev-only files.

Validation

php -l clean on all changed PHP files; full Pest suite green (530 passed; the pre-existing deprecations/warnings are unrelated) and patch-coverage passes at 100% (68/68 changed measured lines); manifest drift-check passes and the translation template is up to date.

Revision: hardening & fleet cleanup

Since the initial description, this PR also:

  • Prunes phpunit.xml on upgrade (alongside the dev-only tests/ tree) and leaves .md* lint configs in place — the drift check now ignores tests/, phpunit.xml, .git*, .md*, and whitelisted paths.
  • Hardens the prune against tampered manifests: refuses any tombstone whose normalized path contains a ./.. traversal segment or resolves outside the plugin directory (including via a symlinked directory), and protects a directory when a whitelisted entry lives beneath it — each with added unit coverage.
  • Renames the prune helpers to the documented naming convention: thold_prune_files() / thold_rmtree() (the plugin_thold_ prefix is reserved for lifecycle/hook-registration functions).
  • Gives tests/Unit/PruneFilesTest.php the full standard GPL v2 header and aligns the Project Structure block in .github/copilot-instructions.md.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The focused metadata change matches the stated purpose and introduces no unresolved issues.

Review effort: Balanced
Findings: None

What changed in this PR

Raises the plugin’s minimum supported Cacti version to 1.2.32.

Changes:

  • Updates the compat metadata from 1.2.25 to 1.2.32.
File Description
INFO Updates minimum Cacti compatibility metadata.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

browniebraun
browniebraun previously approved these changes Sep 30, 2026
Copilot added 3 commits September 30, 2026 19:58
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.
… 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.
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The compatibility floor is inconsistent and the prune guard can permit recursive deletion of the plugin root.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity · 4 Low severity

Open (6)

Comment thread setup.php
Comment thread INFO
Comment thread .github/copilot-instructions.md Outdated
Comment thread .github/copilot-instructions.md Outdated
Comment thread .github/copilot-instructions.md Outdated
Comment thread setup.php Outdated
Copilot added 6 commits September 30, 2026 21:51
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.
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.
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.
- 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.
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.
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.
@TheWitness TheWitness changed the title INFO: set compat to 1.2.32 INFO: set compat to 1.2.29 Oct 1, 2026
@cigamit
cigamit merged commit 9b217e0 into develop Oct 1, 2026
3 checks passed
@cigamit
cigamit deleted the chore/compat-1.2.32 branch October 1, 2026 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants