Repository navigation
Codebase quality sweep - #418
Merged
Merged
Conversation
- syslog_process_alerts(): compile all rules to condition-only SQL and evaluate every rule's count in one consolidated SUM(CASE) scan of syslog_incoming (one scan per cycle regardless of rule count); rules below threshold or with zero counts skip their record fetches - syslog_device_rule_sql(): qualify the correlated host column so the mute filter was not a tautology (dr.host = dr.host silently matched every staged record and suppressed all alerts) - Add message_digest char(32) to syslog/syslog_removed (fresh installs via CREATE, existing via syslog_ensure_message_digest_columns()), backfill bounded per poller run via syslog_backfill_message_digest(); archive, move, and replication paths write MD5(message) at ingest - Viewer: grouped queries and nav counts key on the digest with an IF(digest = '', MD5(message), digest) exactness fallback, degrading to the old message GROUP BY when the column does not exist yet - Bounded per-render host-name fetch (host_id IN instead of full table) - tests: MessageDigestGroupingTest source-shape coverage
…helpers - Add lib/QueryBuilder.php to phpunit.xml <source> so the patch-coverage gate can verify the filter-document compiler this branch touched. - Hoist the QueryBuilder-availability degradation into syslog_query_builder_unavailable() and route all three guard sites through it, so the partial-deploy path stays observable in-process. - Cover the timeseries panel branch, invalid-database-name partition guards, retroactive removal-rule field maps, dMaxValue metadata extraction, the metadata label/filter button renderers, and the failed-compile removal fallback. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The QueryBuilder availability guards fail closed when lib/QueryBuilder.php is missing (a partial deploy); their bodies cannot run inside the Pest process, where the class is always loaded. The guard test now runs the plugin's real includes/functions.php in a shimmed tree without the lib file, collects xdebug coverage of the degraded run, and writes a sibling Clover fragment that patch-coverage.php merges by trailing path components. Without the fragment the gate still fails, so the coverage requirement stays honest. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pest materializes the coverage directory only after the whole suite finishes, so the guard fragment write failed silently on a fresh CI checkout. The shim runner now creates the directory, and the test asserts the fragment exists so a silent write failure fails loudly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… PR #418 Reflow 20 over-120-character lines across syslog_device_rules.php, includes/processing.php, includes/functions.php, lib/syslog_dashboard.php, setup.php, syslog.php and syslog_alerts.php: wrap long prepared-statement calls, ternaries, mapping arrays and string concatenation, and re-align drifted PHPDoc comment blocks. No behavior changes. Associate the Device Alert Rule filter controls (Search, Enabled, Rules) with accessible <label for> elements to clear the two WCAG label findings. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
TheWitness
approved these changes
Oct 16, 2026
This was referenced Oct 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Remote collector schema lifecycle (6 commits)
Prevent schema repair from undoing plugin uninstall (e550b4d) — schema auto-repair is suppressed during lifecycle operations and while Syslog is disabled/uninstalled, so a stale processor launch can't resurrect dropped tables.
Repair missing schema on all collectors before processing (96cbdbe) — syslog_connect() now runs syslog_ensure_table_structures() on the main collector and enabled remotes; processing skips with a logged error if repair fails instead of failing with a return-type error.
Resolve Cacti 1.2.x default connection for rule replication (55ef7c7) — explicit resolution of $local_db_cnn_id / $database_sessions, since 1.2.x doesn't always set $local_db_cnn_id.
Auto-initialize remote collector schema after reinstall (d3a7122) — reconnecting remotes bootstrap their own tables after a master reinstall.
Remove all remote collector tables on full uninstall (b780050) — uses Cacti's native api_plugin_drop_remote_table() across the full plugin-owned table list (message history + operational tables included).
Clean up remote rule snapshots on full uninstall (39bf31c) — rule table snapshots no longer leak on remote collectors.
Alert staging scalability + message-digest grouping (5c65781)
syslog_process_alerts() compiles all rules to condition-only SQL and evaluates every rule's count in one consolidated SUM(CASE) scan of syslog_incoming — one scan per cycle regardless of rule count; rules below threshold skip record fetches.
Adds a message_digest CHAR(32) column to syslog/syslog_removed (fresh installs via CREATE, existing via ensure-column + bounded per-run backfill). Viewer grouped queries and nav counts key on the digest with an IF(digest = '', MD5(message), digest) fallback, degrading to the old GROUP BY message when the column doesn't exist yet — shrinking temp tables that previously grouped on full message TEXT.
Fixes a functional bug: the device-rule mute filter was a tautology (dr.host = dr.host matched every staged record), silently suppressing all device alerts; the correlated column is now qualified.
Critical PHP audit findings (b6e3ac9)
XSS: stored removal/report rule names are now escaped in all bulk-action confirmations (new BulkRuleNameEscapingTest.php covers 9 action/file combos × 3 payloads).
Atomic rule replication: syslog_replicate_data() was rewritten into a failure-safe syslog_replace_data() — table allowlist, column regex validation, staged table + atomic RENAME TABLE swap under GET_LOCK, chunked inserts, false never clears a table. Replication now routes through the configured Syslog database (dedicated-DB support), and imports publish complete snapshots including empty tables.
Digest migration fix: backfill is bounded to the registered master and a fixed migration range, retaining the last durable cursor when a batch or progress write fails (the old settings-based cursor could skip failed batches) — DigestMigrationTest.php.
Dashboard write-failure handling: deletes, copies, panel ordering and saves report errors and roll back partial transactions via a transactional syslog_dashboard_delete() (DashboardWriteFailureTest.php).
Shell-escaping of the processor path, plus count correctness for equal retained/removed totals in uninstall-all.
Host autocomplete joins (f51fcd7)
get_ajax_hosts() in syslog.php no longer four-way OR-joins syslog_hosts against the Cacti host table, which forced full device-table probes per keystroke (>60 s on large installs). Rewritten as a two-phase bounded plan: candidate rows from syslog_hosts, device resolution via exact IN probes (hostname, description, first dot segment), with deterministic most-specific match — ≈150 ms on the same data volume.
Housekeeping
e99f49b — linting/style alignment (alignment formatting, brace style, comment syntax).
4945845 — .gitignore update.
CI workflow runs the new quality_must_fix_database_test.php regression; cli/syslog_schema.php required-table fixture repaired; docs and cacti.pot updated; new MustFixEntryPoints, PipelineHealth, RemoteUninstall, RemoteSchemaBootstrap, RepeatInterval unit tests.