40 Commits
Author SHA1 Message Date
Thomas VincentandTheWitness a515cea185 fix(scripts): return 'U' on error in ss_webseer, ss_gexport, query_host_cpu (#6941)
* fix(scripts): return 'U' on error in ss_webseer, ss_gexport, query_host_cpu

Data source scripts must return 'U' (RRDtool unknown) on error rather than
'0', which is a valid data value and silently poisons graphs.

- ss_webseer.php: replace empty() guard with strict $value === '' comparison
  (empty('0') is true in PHP, corrupting a valid zero reading); return 'U'
  on fallthrough instead of false
- ss_gexport.php: return 'U' on fallthrough instead of null
- query_host_cpu.php: print 'U' when requested index absent in get handler

Adds DatasourceScriptErrorReturnTest.php with source-scan tests for each
corrected return path including regression guards for the empty() trap.
Uses tab indentation to match repo conventions.

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

* fix(ss_webseer): catch false/null returns from db_fetch_cell_prepared

db_fetch_cell_prepared() returns false when the query finds no row or
fails. The previous check ($value === '') passed false and null through
as-is, returning a non-'U' value to rrdtool and causing NaN spikes.
Extend the guard to treat false and null the same as empty string.

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

* test(scripts): add GPL header to DatasourceScriptErrorReturnTest

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

* test(scripts): add false/null guard tests for ss_gexport and ss_webseer

Adds source-scan assertions verifying both scripts handle false and null
returns from db_fetch_cell_prepared, and a behavioural dataset confirming
the guard expression maps all three sentinel values to 'U'.

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

---------

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Co-authored-by: TheWitness <thewitness@cacti.net>
2026-04-04 12:43:03 -04:00
TheWitnessandCopilot fb1d7ea006 Put the Scripts Directory in Scope for Quality Checks (#6584)
* Allow form_selectable_cell to more easily port

* Removing exclusion for scripts directory

* More fixes for scripts

* Some issues with ss_host_disk.php that passed locally

* More issues not detected locally

* Issues with typing in cacti_snmp_walk

* Adding base files for non-savy composer users

* One more try on ss_host_disk.php

* Aparantly I have to add the lock file

* More changes to lib/snmp.php after testing

* More changes to lib/snmp.php after testing

* Fix number script from Copilot review

* More Composer reviews

* Update scripts/ss_apache_stats.php

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

* Update scripts/motorola_surfboard_SB6141.py

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

* Update scripts/motorola_surfboard_SB6141.py

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

* Changing syntax of PHP requirement

* Updating composer

* Attempt to quiet some warnings

* Add Syntax Check

* Wrong file name

* Wrong file name

* Better to report before and after

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-30 08:04:27 -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
TheWitness b9334a15d9 QA: Updates for files for php-cs-fixer and some php-doc changes 2025-11-18 21:01:15 -05:00
TheWitness 2c779273f9 Copyright Updates and PHP-CS-Fixer updates 2025-03-09 14:34:19 -04:00
Jimmy ConnerandTheWitness 65ab16f5cf Start converting to newer PHP Syntax and Functions (#6103)
* Add Rector

* Add Rector

* Fix "Cashed" misspelling

Also harmonize the phrase with the one below it

* Fix implode error in db_table_create

Only relevant when multiple primary keys

* Fix auth issue, parentheses in the wrong location

Was causing too many arguments to be sent to cacti_sizeof which only take 1, instead of get_allowed_devices.

* Fix issue with session_var not properly using class variable

* Fix pass by reference error in get_allowed_devices

get_allowed_devices has a pass by reference on the "total_rows" field.  It is used in several places to pass the total_rows back to a counter.  Here though, we are passing a number directly to the function, which errors out with "Uncaught Error: get_allowed_devices(): Argument #4 ($total_rows) cannot be passed by reference".  So we will just place a dummy variable in front to catch the pass.

This wasn't caught before because the previous parentheses issue.

* Fix undefined variable "field_array" in html_filter

* Fix undefined function 'get_nfilter_filter_request_var'

* Fix undefined variable 'resizable'

I corrected the function parameter, as that was technically the incorrect spelling

* Fix invalid variable $user_id

* Fix undefined vars in spikekill class

* Fix copy and paste error

Oops

* Forgot to use the dummy variables

* Add missing $

Oops

* Start converting to newer PHP Syntax and Functions

* Test fixing the workflow by install composer

* Lets not valid the composer file right now
Seems we have a few things to fix it in

* Validate composer

* Lite formating changes

* lite formatting

* lite formatting

* lite format changes

* lite format changes

* lite format changes

* lite format changes

* lite format changes

* lite format changes

* lite format changes

* lite format changes

---------

Co-authored-by: TheWitness <thewitness@cacti.net>
2025-02-23 15:14:54 -05:00
TheWitness afcd847639 Revert "QA: Don't use CRLF. Use LF"
This reverts commit 60d42af89c.
2024-12-11 22:47:42 -05:00
TheWitness 60d42af89c QA: Don't use CRLF. Use LF 2024-12-11 22:42:45 -05:00
TheWitness 22b85e1622 Fix: #5966 - Add snmp retries at the device level
* This covers all the built in scripts.  Several packages will need rebuild
2024-12-06 23:07:32 -05:00
TheWitness 1aa72d24c9 QA: Update Copyright to 2024 2024-02-03 14:18:57 -05:00
Mark Brugnoli-Vinten e4d60297fd Update copyright year for 2023 2023-01-04 13:36:25 +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 b6ff8d9360 Update more copyrights 2022-12-01 02:27:49 +00:00
cigamit 33d99b73ff Update scripts to be more consistent 2019-02-18 07:57:04 -06:00
netniV 89f0a06216 Resolving issue #2304 and #2311
This commit corrects a previous unseen issue where the PHP environment at command line level is being populated with environment variables normally only seen when called from a web server.

issue#2304: Installation progress stays at 0%
issue#2311: Unable to update PHP location during installation due to incorrect CLI environment

The new check uses the php_sapi_name() function to verify that we are indeed at 'cli' level.  All other values returned by php_sapi_name are considered non-cli including 'cli-server' which is for client/server scenarios.

Most checks have now been replaced by a single defintion ('CACTI_CLI') to define whether in CLI mode.  If a script is only to be called from CLI it must either defined 'CACTI_CLI_ONLY' or include include/cli_check.php instead of include/global.php.
2019-01-15 13:57:50 +00:00
Mark Brugnoli-Vinten 1ca32862a9 Resolving issue #1920 (#1922)
* Resolving issue #1920

* Minor QA issue
2018-09-14 20:59:52 -05:00
cigamit e64f3582a0 Audit of PHP Data Collection Scripts
- Double to Single Quotes
- Prepared Statements
- "\n" to PHP_EOL
2018-04-07 10:42:07 -05:00
Tony Roman 8a179d7d7f Fix up to move if elseif else blocks to PSR 2017-05-07 19:57:36 -04:00
cigamit a352a0e227 clean up scripts
Be consistent on error_reporting() and $no_http_headers.
2015-11-14 11:03:15 -06:00
Jimmy Conner ac6d6929cc Remove some unnecessary ending PHP closing tags
git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/cacti/branches/0.8.8@7571 860744bd-22fc-0310-8c96-e9fe5004b5ca
2014-12-17 03:02:03 +00:00
Reinhard Scheck 9d2a164909 -bug#0001568: Cacti currently gives a lot of warnings of deprecated functions on PHP 5.3
git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/cacti/branches/0.8.7@6200 860744bd-22fc-0310-8c96-e9fe5004b5ca
2011-01-06 21:03:25 +00:00
Jeff Pasnak 256a0a584f #0001504 - fix no newline errors
git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/cacti/branches/0.8.7@6102 860744bd-22fc-0310-8c96-e9fe5004b5ca
2010-08-21 15:03:22 +00:00
Reinhard Scheck 969e131295 -bug#0001771: "index count changed" not implemented for query_cpu_partitions.pl
git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/cacti/branches/0.8.7@5964 860744bd-22fc-0310-8c96-e9fe5004b5ca
2010-05-29 14:35:08 +00:00
Reinhard Scheck 0ced77aa71 0001374: ss_host_disk.php etc. fail on SNMP V3 (index off by 1)
git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/cacti/branches/0.8.7@4894 860744bd-22fc-0310-8c96-e9fe5004b5ca
2009-01-31 15:14:56 +00:00
Reinhard Scheck 5819879dd7 patch #4424 now for 087 as well
Special care will have to be taken on users of "cacti_snmp_walk". This function now has the additional parameter "max_oids".

git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/cacti/branches/0.8.7@4602 860744bd-22fc-0310-8c96-e9fe5004b5ca
2008-06-14 09:46:07 +00:00
Larry Adams d2914a2bb6 Two missed scripts.
git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/cacti/branches/0.8.7@4281 860744bd-22fc-0310-8c96-e9fe5004b5ca
2007-10-26 16:14:08 +00:00
Larry Adams 64efe41d43 Add support for snmpV3 context's.
git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/cacti/branches/main@4152 860744bd-22fc-0310-8c96-e9fe5004b5ca
2007-09-16 01:17:39 +00:00
Tony Roman 4fe05b968b Altered config.php, and include/config_* to include/global_*
git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/branches/BRANCH_0_8_6/cacti@4007 860744bd-22fc-0310-8c96-e9fe5004b5ca
2007-07-05 04:45:43 +00:00
Larry Adams b11bf9946e additional exploit targets
git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/branches/BRANCH_0_8_6/cacti@3850 860744bd-22fc-0310-8c96-e9fe5004b5ca
2007-01-02 17:00:24 +00:00
Larry Adams 7248cc5fd7 -bug: Add snmp retries to cacti's snmp functions
git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/branches/BRANCH_0_8_6/cacti@3653 860744bd-22fc-0310-8c96-e9fe5004b5ca
2006-07-15 20:05:21 +00:00
Ian Berry 7543684c3f add snmp_version to basic script queries
git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/trunk/cacti@1371 860744bd-22fc-0310-8c96-e9fe5004b5ca
2003-11-13 04:17:36 +00:00
Ian Berry 4d5fe8f3d7 fixed include path problems with php cli; removed http headers
git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/trunk/cacti@1323 860744bd-22fc-0310-8c96-e9fe5004b5ca
2003-11-06 01:48:33 +00:00
Ian Berry 72f2cea5b7 add snmp timeout
git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/trunk/cacti@1261 860744bd-22fc-0310-8c96-e9fe5004b5ca
2003-10-10 03:55:07 +00:00
Ian Berry 0ff3bc7702 replace the management_ip field with hostname
git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/trunk/cacti@1252 860744bd-22fc-0310-8c96-e9fe5004b5ca
2003-10-09 07:13:53 +00:00
Ian Berry 39866609d3 unified all edit form code; updated references to the new 'lib/' directory
git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/trunk/cacti@1228 860744bd-22fc-0310-8c96-e9fe5004b5ca
2003-09-22 04:31:58 +00:00
Ian Berry 18bebae114 include proper directory names when making includes
git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/trunk/cacti@1223 860744bd-22fc-0310-8c96-e9fe5004b5ca
2003-09-16 03:15:00 +00:00
Ian Berry ef3786397f fixed problem monitoring more than one cpu
git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/trunk/cacti@1131 860744bd-22fc-0310-8c96-e9fe5004b5ca
2003-08-15 01:16:28 +00:00
Ian Berry dcfff0fd75 fix for >1 cpus
git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/trunk/cacti@969 860744bd-22fc-0310-8c96-e9fe5004b5ca
2003-05-27 06:17:06 +00:00
Ian Berry 24ba7f0480 two new script queries for win32
git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/trunk/cacti@950 860744bd-22fc-0310-8c96-e9fe5004b5ca
2003-05-23 07:13:58 +00:00