Commit Graph
118 Commits
Author SHA1 Message Date
Thomas VincentandTheWitness fa050a2417 Revoke server-side auth tokens on logout (#7677)
* Revoke server-side auth tokens on logout

clear_auth_cookie() ran after cacti_cookie_logout() had already unset
$_COOKIE['cacti_remembers'], so its guard short-circuited and the
user_auth_cache row was never deleted; the timeout/disabled/remote branch
never called it at all. Move it ahead of the cookie clear so every logout
revokes the remember-me token, and have logout-everywhere also terminate the
user's other database sessions.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* Guard the logout test function-body offsets and reorder the changelog entry

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

---------

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Co-authored-by: TheWitness <thewitness@cacti.net>
2026-08-16 21:22:49 -04:00
61a542a670 fix(auth): correct auth system bugs (#7187)
* fix(auth): correct auth system bugs

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* Address auth PR review findings

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* Guard remember cookie cache deletion

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* fix(auth): prevent remote agent lockout on FCrDNS failure and add regression tests

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* docs: update CHANGELOG for auth system correctness fixes

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* fix(auth): stop returning 2fa secret from verification

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* fix(auth): reject remote agent requests that fail forward-confirmed reverse DNS

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* ci: ignore phpstan function.alreadyNarrowedType identifier

Clears the level 6 alreadyNarrowedType error on lib/data_query.php:2591 that
develop currently emits, matching the sibling narrowing identifiers already ignored.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* docs: reword FCRDNS change as a refactor, not a security fix

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* Potential fix for pull request finding

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

---------

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Co-authored-by: TheWitness <thewitness@cacti.net>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-06-24 18:01:37 -04:00
TheWitnessandCopilot 2810342f65 fix: Simplify redirect handling in Cacti and Fix Multi-Sort (#6955) (#6978)
* fix: Simplify redirect handling in Cacti and Fix Multi-Sort (#6955)

* fix: Simplify redirect handling in Cacti

* fix: Slight improvements from Copilot review

* fix: Fix for compatibility

* fix: Fix small syntax error

* fix: Remove comments

* fix: Make the query case insensitive

* fix: Encode the reference url

* fix: More copilot review comments

* fix: More copilot comments

* fix: Double semicolon

* fix: Missed one commit

* fix: Encode the correct url

* Update lib/html_utility.php

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

* fix: Add additional checks

* fix: Fix order string updates for multiple sort

* fix: Add a sanitization function and do further checks

* fix:Switch to local variables

---------

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

* Refactor authentication method check in auth.php

* Fix HTML encoding in goBack variable assignment

* Change get_order_string_page parameter to false

* Apply suggestion from @Copilot

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

* Fix error message capitalization for aggregate graph

* Apply suggestion from @Copilot

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

* Apply suggestion from @Copilot

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

* Apply suggestion from @Copilot

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

* Fix goBack link formatting in permission_denied.php

* Update lib/html_utility.php

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

* Add type hints to sanitize_uri and validation functions

* Fix comment formatting in validate_redirect_url

* Fix header location formatting in auth.php

* fix: Fixing PSR Issues with remote agent

* fix: Additional psr comments

* fix: More psr comments

* fix: PHPStan Issues

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-04-05 10:56:17 -04:00
TheWitness 82f0204666 Comment out shell lint and coverage steps (#6874)
* Comment out shell lint and coverage steps

We will remove these checks until all the issues indenified by them have first been resolved.

* Disable shell-lint job in quality-extended.yml

Completely remove the step

* Disable spell check job in syntax.yml

Comment out the spelling job in the workflow.

* Fixing Syntax issue in lib/html_graph.php

* Fixing PHPDoc in lib/html_graph.php

* Fixing some style issues in syntax.xml

* Fix more style issues.

* Commenting out actionlint for the moment

* Fixing last issue with html_graph.php

* Fixing issue with auth_profile.php

* Fixing PHPStan issues

* Fix another PHPStan issue

* Fixing Unit Test

* Fix config.php prime step

* Fixing syntax check style

* Going back to old approach

* Moving csrf.php inclusion back to main line for automation

* Fixing issue with create logic

* Fix issue where poller exits with non-zero exit code

* Fix logging only for *NIX

* Fix poller completion detection by reverting code

* Fixing syslog change

* Fixing syslog change
2026-03-21 17:51:52 -04:00
Thomas VincentandTheWitness 678c50d5ba hardening: sanitize JS contexts in UI pages (#6827)
* hardening: sanitize JS output contexts and add tests

* hardening: encode return targets in password flow JS handlers

* hardening: address review feedback in JS context fixes

* refactor: extract sanitize_graph_id_list() helper

Extracts repeated graph list CSV parsing into a reusable function
per TheWitness review on #6827. Uses ctype_digit validation and
deduplication. Replaces inline loop at line 1435.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

---------

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Co-authored-by: TheWitness <thewitness@cacti.net>
2026-03-18 21:21:22 -04:00
Thomas VincentandTheWitness fcbcbdd1d7 refactor: replace strpos() boolean checks with str_contains/str_starts_with (#6645)
* refactor: replace strpos() boolean checks with str_contains/str_starts_with

Completes the PHP 8.x string function migration started in lib/.
Converts remaining legacy patterns across 81 files:

- strpos($x, $y) !== false → str_contains($x, $y)
- strpos($x, $y) === false → !str_contains($x, $y)
- strpos($x, $y) != false  → str_contains($x, $y)
- bare if (strpos($x, $y)) → if (str_contains($x, $y))
- substr($x, 0, strlen($y)) == $y → str_starts_with($x, $y)

Intentionally preserves strpos() calls that use the return value as
an integer offset:
- user_admin.php / user_group_admin.php (4 calls, ternary for position)
- auth_profile.php (2 calls, offset for substr); guards fixed from
  bare if ($pos) to if ($pos !== false)

Behavior fix: ss_esxi_vhosts.php:55 bare strpos() missed position-0
matches; str_contains() now correctly detects 'not installed' at any
position. Adjacent line already used str_contains().

Ref: https://github.com/Cacti/cacti/issues/6641

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* fix: correct dead-code elseif in plugin_display_compat() version comparison

The if/elseif chain in plugin_display_compat() checked >=, >=, >, <
— the second >= was unreachable dead code. Corrected to <= to complete
the operator set (>=, <=, >, <).

Without this fix, <= constraints (e.g. "<=1.2") fell through to the <
branch and were rendered as "< =1.2" instead of "<= 1.2".

This pre-existing bug was exposed when converting strpos() to
str_contains(), which made PHPStan detect the always-false condition.

Ref: https://github.com/Cacti/cacti/issues/6641

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* fix: add limit to explode('=') in CLI argument parsers

17 CLI scripts used explode('=', $parameter) without a limit of 2,
silently truncating values containing = (e.g. --note=a=b parsed as
$value='a' instead of 'a=b'). The other 40 CLI scripts already had
the correct limit.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

---------

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Co-authored-by: TheWitness <thewitness@cacti.net>
2026-02-25 11:38:59 -05:00
TheWitness 27919c50d7 Updating Copyrights to 2026 (#6578) 2026-01-28 16:11:10 -05:00
TheWitnessandCopilot b993471579 Fix #6539 - Allow Standard Cacti Log Files to be Rotated on Demand,PHPdoc, and Typing (#6540)
* Fix #6539 - Allow Standard Cacti Log Files to be Rotated on Demand from the Cacti UI

* QA: php-cs-fixer updates and documentation for lib/database.php

* QA: Update .gitignore for composer files

* QA: Update .gitignore for composer files

* QA: Back off .gitignore change its duplicated

* QA: Fix typing of db_has_permissions

* QA: Fixing typing issue in db_format_index_create

* Update lib/clog_webapi.php

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

* QA: Fix additional code issues

* QA: Applying more defaults to add device

* QA: Fix at the database layer

* QA: Fixes based upon automated testing

* QA: Fix at the database layer

* QA: After new SQL checking

* QA: Skip MacTrack oui database download warnings

* QA: Fixing type issue

* QA: Recommendation from Copilot

* QA: Recommendation from Copilot

* QA: Recommendation from Copilot

* QA: Recommendation from Copilot

* QA: Some minor changes to avoid errors in testing

* QA: Unused variable

* QA: Recommendation from Copilot

* QA: Recommendation from Copilot

* QA: Recommendation from Copilot

* QA: Minor introduced code defect

* QA: Adding some unifying space around concatination

* QA: Consistent comments and new function alias'

* QA: Multi-line comment corrections

* QA: Fix SQL Style

* QA: Missed one function alias

* QA: PHPStan Level 2 and PHPDoc fixes

* QA: PHPStan Level 2 and PHPDoc Fixes

* QA: PHPStan Level 6 Fixes

* QA: Fix lib/xml.php to PHPStan Level 6

* QA: Wrong grep -v

* PHPStan Level 6 for lib/vdef.php

* PHPStan Level 8 for lib/time.php

* QA: Raise PHPStan to Level 6 for lib/database.php

* QA: Remove @deprecated tag from grv()

* QA: Switch to htmle() alias over html_escape()

* QA: More addressing PHPStan issues at Level 6

* QA: Change recommended by Copilot for Readability

* QA: More PHPStan fixes

* QA: More PHPStan fixes

* QA: More PHPStan fixes for lib/utility.php

* QA: More PHPStan fixes at Level 6

* QA: Raise PHPStan to Level 6 More Functions

* QA: Raise PHPStan to Level 6 More Functions

* QA: Raise PHPStan to Level 6 More Functions

* QA: Raise PHPStan to Level 6 More Functions

* QA: Raise PHPStan to Level 6 More Functions

* QA: More PHPStan fixes at Level 6

* QA: Raise PHPStan to Level 6 More Functions

* QA: Raise PHPStan to Level 6 More Functions

* QA: More PHPStan fixes at Level 6

* QA: More PHPStan fixes at Level 6

* QA: Raise PHPStan to Level 6 More Functions

* QA: Raise PHPStan to Level 6 More Functions

* QA: More PHPStan fixes at Level 6

* QA: Raise PHPStan to Level 6 More Functions

* QA: Raise PHPStan to Level 6 More Functions

* QA: More PHPStan fixes at Level 6

* QA: Raise PHPStan to Level 6 More Functions

* QA: Raise PHPStan to Level 6 More Functions

* QA: More PHPStan fixes at Level 6

* QA: More PHPStan fixes at Level 6

* QA: More PHPStan fixes at Level 6

* QA: Raise PHPStan to Level 6 More Functions

* QA: More PHPStan fixes at Level 6

* QA: Some phpseclib3 fixups to update to latest

* QA: More fixups for graphing for magic strings

* QA: More PHPStan fixes at Level 6

* QA: Fixing order string type on get_allowed_graphs()

* QA: Fixing improper use of print

* QA: Optimization of color_templates

* QA: Copilot recommendation

* QA: Copilot recommendation

* QA: Copilot recommendation

* QA: Copilot recommendation

* QA: Copilot recommendation

* QA: Copilot recommendation

* QA: Copilot recommendation

* QA: Copilot recommendation

* QA: Raise PHPStan to Level 6 More Functions

* QA: Issues insalling Cacti

* QA: Issues insalling Cacti

* QA: Issues insalling Cacti

* QA: Issues insalling Cacti

* QA: Issues insalling Cacti

* QA: Issues testing Cacti

* QA: Copilot recommendation

* QA: More PHPStan fixes at Level 6

* QA: More PHPStan fixes at Level 6

* QA: More PHPStan fixes at Level 6

* QA: More PHPStan fixes at Level 6

* QA: More PHPStan fixes at Level 6

* QA: Installer failing

* Undo ownership changes to remove tar errors

* QA: Updates after php-cs-fixer

* QA: Adding code checks to syntax checking

* QA Change syntax flow language

* QA: Reduce the number of cures

* QA: Use sequentional option

* Change runner to self-hosted for check job

* Fix typo in OS version in workflow file

* Add Git installation step in workflow

Added step to install Git if not already installed.

* Add '-y' flag to apt-get install and update commands

Updated apt-get commands to include '-y' for automatic confirmation.

* Change workflow OS version to 'ubuntu-latest'

Updated the workflow to use 'ubuntu-latest' instead of 'ubuntu:latest' and modified the 'runs-on' configuration.

* Remove sequential option from phpcsfixer script

* Remove PHPCS fixer step from workflow

Removed PHP coding standards check from workflow.

* Move code checks to before plugins

Moving these core checks to before the plugins are installed as we really want to check only the base Cacti here.

* Add Composer validation and caching to start of workflow

* QA: Addressing PHPStan additional

* QA: Restore composer lock file

* QA: Addressing PHPStan additional

* QA: Addressing PHPStan additional

* QA: Complete LDAP Project

* QA: php-cs-fixer doing it's thing

* QA: Syntax is already happening in PHPStan

* QA: The md5 function no longer exists

* QA: Update after ldap changes

* QA: Undo that last password hack

* QA: Attempting to switch to MariaDB 11.8

* QA: Attempting to switch to MariaDB 11.8

* QA: Resolving some issues with PHP8.4

* QA: Resolving some issues with PHP8.4

* QA: Add PHP8.5 to the matrix

* QA: Removing PHP8.5 due to dependency issues

* QA: Add the DB version to the testing output

* QA: Switch back to MySQL for the moment

* QA: More fidelity in reporting

* QA: The pipe must be mixed

* QA: Moving audit_schema.php changes from 1.2.x

* QA: Moving audit_schema.php changes from 1.2.x

* QA: Restore mysql monitoring

* QA: php-cs-fixer issues

* QA: Attempt to roll back to MariaDB 10.6

* QA: Attempt to fix check_all_pages.sh

* QA: Make installer functional again

* QA: Fix installer php-cs-fixer issues

* QA: Type to a string

* QA: Get the database version correctly

* QA: Fix issue with reports in check_all_pages.sh

* QA: Check the server version in the right place

* Feature: Support SHA256 as a new hash for passwords

* QA: Function definition and return typing audit

* QA: Refinement of form types

* QA: Refinement of form types

* QA: Consistency of comments

* QA: Issues with php-cs-fixer and more comments

* QA: More typing issues

* QA: php-cs-fixer on merge conflict resolution

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-25 10:13:56 -05:00
Browniebraun 1627c7a150 Font Awesome Icons to Tabler Icons migration 2025-12-16 20:27:05 +01:00
TheWitness b70dca887e QA: Fixing additional files at phpstan level 1 2025-11-18 22:30:01 -05:00
TheWitness 8b9c29708c QA: Finishing up buttons 2025-07-13 12:58:53 -04:00
TheWitness d73ea2edbf QA: Language switch not wrking and two memory leaks 2025-06-29 11:49:12 -04:00
TheWitness ac0c1c5c45 Switch from include to require 2025-04-03 14:37:02 -04:00
TheWitness 685d4b9357 Start addressing PHPStan Issues 2025-03-23 14:09:11 -04:00
TheWitness e5c4015e0e QA: Remove most references to $config
This removes most entries to $config in the base code.  A few new constants were defined to achieve this:

* CACTI_CONNECTION - The status of the current connection
* CACTI_CSRF_SECRET - The path to the csrf secret file
* CACTI_PHP_SNMP - True if php-snmp is installed
* CACTI_WHITELIST - The path to the Cacti Whitelist file if defined

I also moved several $config['poller_id'] to the existing POLLER_ID and move a number of $config['is_web'] to the existing CACTI_WEB constants.

There remain a few artifacts in the code.  They will be handled in a separate commit.
2025-03-22 16:48:59 -04:00
TheWitness 2c779273f9 Copyright Updates and PHP-CS-Fixer updates 2025-03-09 14:34:19 -04:00
Browniebraun d88d3acd30 reverting FontAwesome till better solution has been identified. 2025-01-15 23:04:14 +01:00
Browniebraun 5be7d7f18b Migrating icons from FontAwesome to Tabler 2025-01-05 20:58:36 +01:00
TheWitness 054e1aab5d QA: Fix: #6042 - And remove most of AUTH_METHOD_NONE
* What remains is lib/auth.php that includes some references and global_constants.php that I'm leaving in just in case of the potential use or misue in lib/auth.php
2025-01-04 16:39:32 -05:00
TheWitness 34286d1ada QA: Add additional clarity on what logout everywhere does 2024-12-22 09:48:34 -05:00
TheWitness aabe87b24f QA: Fix# 5992 - 2FA Settings Change 2024-12-22 09:23:30 -05:00
TheWitness 1f9e900e44 QA: Fix profile handling of return button 2024-12-21 09:53:06 -05:00
TheWitness c2e1840e31 QA: Fix: #5991 - Return button in Edit Profile Unreliable
* The Return button on the Edit Profile Screen is unreliable
2024-12-13 11:30:59 -05:00
TheWitness d970e69e89 QA: #5969 - Unset the wrong variable 2024-12-08 09:19:29 -05:00
TheWitness 94473565a0 Fix: #5969 - Do not show zone support if disabled at system level
* If System Level Browser TimeZone Support is disabled don't show the User Profile Option
2024-12-08 08:53:14 -05:00
TheWitness 9de57c20a7 QA: Fixing #5591 - Settings seem stuck at 'default'
* Graph item presets and saved views seem to be ignored.
* Some PSR for database calls, alignment and formatting
2024-10-13 16:29:33 -04:00
TheWitness 1aa72d24c9 QA: Update Copyright to 2024 2024-02-03 14:18:57 -05:00
TheWitness 75d704edf4 QA: Remove old stub function name documentation 2023-11-12 22:09:20 -05:00
TheWitness 0283fa9095 QA: Additional changes to #5519
Due to some issue around the menu processing, handle the return from auth_profile.php using a full page load.
2023-10-03 21:15:17 -04:00
Mark Brugnoli-Vinten db08eb09d5 User Profile Settings are not working correctly (#5412)
Closes #5412
2023-07-22 17:48:09 +01:00
TheWitness a55abadba6 Fixing #5342 and #5368 - Keyup delay on tree search
Increase keyup delay when searching the tree

For 1.3.x, also adds a setting and switches all keyup events that
make ajax calls to use delayKeyup instead of manually defining
each timer.

Closes #5368
2023-06-12 03:54:55 +01:00
Mark Brugnoli-Vinten 4c6eb05569 QA - 2FA settings cause warnings due to form buttons (#5335)
Closes #5335
2023-05-29 11:43:20 +01:00
TheWitness c7d6c958e1 QA #5171 Fixing auth_profile.php
* 1.3.0 - QA Unable to return from edit profile
* This also finishes the design intent of the form_save_buttons() function
2023-04-02 14:11:53 -04:00
Browniebraun 8c9ec6f149 avoid that registered events for theme related input fields will be dropped. 2023-04-02 01:00:42 +02:00
Mark Brugnoli-Vinten 32ba2f19f4 Update copyright year for 2023 2023-01-03 20:34:26 +00:00
Mark Brugnoli-Vinten 8b29d12cc9 Define cacti system paths as constants for better code checking (#5120)
This also provides a full run of src-fixer against all files to
ensure all code is now in alignment.

Closes #5120
2023-01-01 01:03:15 +00:00
Mark Brugnoli-Vinten c8157e3cbb Switch to constants for common session/cookie options 2022-12-21 10:53:53 +00:00
Mark Brugnoli-Vinten d60788f7d0 Fix some installation issues since recent changes 2022-12-21 00:17:11 +00:00
Mark Brugnoli-Vinten 7111414117 QA: Reduce code duplication 2022-12-11 04:24:46 +00:00
Mark Brugnoli-Vinten 06512fa933 LDAP configuration should only use 'user_domains_ldap' (#2166)
Closes #2166
2022-12-11 01:50:54 +00:00
TheWitness 86966da641 QA: Back off PHP8 only syntax calls for now 2022-11-30 09:04:33 -05:00
Mark Brugnoli-Vinten 05b8b469de Correct issues with AuthProfile 2022-11-30 09:13:37 +00:00
netniV 4ddebb6921 Add validation to GUI inputs (#1442)
This is an initial start at input validation on the client side.
Currently, this only applies to email address fields but will be
enhanced by future commits.
2022-11-29 03:14:23 +00:00
netniV ef0ed0664b Minor QA on last commit 2022-11-26 19:32:39 +00:00
netniV e8cd262bb7 Making posting work (for the most part) 2022-11-26 19:32:26 +00:00
netniV fd44f394a0 Remove the need for header=false
Update loadPage calls to be loadUrl
Update loadPageNoHeader calls to be loadUrl calls

Also includes changes to make logout adhere to new html_auth_xxx functions
2022-11-26 13:58:49 +00:00
netniV e594652bb3 Make all auth pages adhere to a common look/feel, introduce page header/footer for auth pages. 2022-11-25 17:05:10 +00:00
netniV df63b0109d Allow users to enable 2FA with Google Authenticator/Authy 2022-11-25 15:18:38 +00:00
TheWitness 757fa895c5 Fixing #4926 - Client TimeZone support
Allow the user to override Cacti auto-client time zone detection
2022-11-12 11:33:16 -05:00
TheWitness 1b06bd3b26 Fixing Issue #4634 - Logout Everywhere
When using Basic Authentication, the Logout Everywhere button should not be shown
2022-03-17 19:04:15 -04:00