Repository navigation
Relocate schema into includes/database.php and standardize includes #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2e21cc8
Relocate schema into includes/database.php and standardize includes
93eb1ea
ci: allowlist web/CLI entry points for patch coverage
TheWitness 06ada9a
Add manifest.json + upgrade-time file pruning
40a4bc0
Address review: require_once in api_device_new hook; scan includes/da…
TheWitness e206c39
Prune phpunit.xml on upgrade and ignore markdown-lint configs
61cde8e
Move linux_wmi.php to includes/linux_wmi.php
06fd2f8
Harden prune against tampered-manifest path traversal
fe5af85
docs: update and align the Project Structure block
f53df50
docs/tests: standardize test header and correct manifest-contract notes
1be48cf
docs: use the full GPL v2 header in includes/database.php
e1644d5
refactor: rename prune helpers to the plugin-slug function prefix
31b72fd
Load cli_check.php from Cacti's include directory in wmi_script.php
TheWitness File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| <?php | ||
| /* | ||
| +-------------------------------------------------------------------------+ | ||
| | Copyright (C) 2004-2026 The Cacti Group | | ||
| | | | ||
| | This program is free software; you can redistribute it and/or | | ||
| | modify it under the terms of the GNU General Public License | | ||
| | as published by the Free Software Foundation; either version 2 | | ||
| | of the License, or (at your option) any later version. | | ||
| | | | ||
| | This program is distributed in the hope that it will be useful, | | ||
| | but WITHOUT ANY WARRANTY; without even the implied warranty of | | ||
| | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | ||
| | GNU General Public License for more details. | | ||
| +-------------------------------------------------------------------------+ | ||
| | Cacti: The Complete RRDTool-based Graphing Solution | | ||
| +-------------------------------------------------------------------------+ | ||
| | This code is designed, written, and maintained by the Cacti Group. See | | ||
| | about.php and/or the AUTHORS file for specific developer information. | | ||
| +-------------------------------------------------------------------------+ | ||
| | http://www.cacti.net/ | | ||
| +-------------------------------------------------------------------------+ | ||
| */ | ||
|
|
||
| /** | ||
| * Adds the 'wmi_account' column to Cacti's host table, creates this | ||
| * plugin's database tables (wmi_user_accounts, wmi_wql_queries, | ||
| * host_wmi_query, host_template_wmi_query, host_wmi_accounts, | ||
| * host_wmi_cache, wmi_processes), and registers this plugin's two Data | ||
| * Input Methods ('Get WMI Data' and 'Get WMI Data (Indexed)') along with | ||
| * their input/output fields, if not already present. Called from | ||
| * plugin_wmi_install() during plugin installation. | ||
| * | ||
| * @return void | ||
| */ | ||
| function plugin_wmi_setup_tables() { | ||
| api_plugin_db_add_column('wmi', 'host', | ||
| [ | ||
| 'name' => 'wmi_account', | ||
| 'type' => 'int(10)', | ||
| 'unsigned' => true, | ||
| 'NULL' => false, | ||
| 'default' => '0', | ||
| 'after' => 'disabled' | ||
| ] | ||
| ); | ||
|
|
||
| db_execute("CREATE TABLE IF NOT EXISTS `wmi_user_accounts` ( | ||
| `id` int(11) UNSIGNED NOT NULL auto_increment, | ||
| `name` varchar(64) NOT NULL, | ||
| `username` varchar(64) NOT NULL, | ||
| `password` varchar(256) NOT NULL, | ||
| PRIMARY KEY (`id`)) | ||
| ENGINE=InnoDB | ||
| COMMENT='Holds Account Information for WMI Queries'"); | ||
|
|
||
| db_execute("CREATE TABLE IF NOT EXISTS `wmi_wql_queries` ( | ||
| `id` int(11) UNSIGNED NOT NULL auto_increment, | ||
| `hash` varchar(32) NOT NULL default '', | ||
| `name` varchar(64) NOT NULL, | ||
| `frequency` mediumint(8) unsigned NOT NULL DEFAULT '86400', | ||
| `enabled` char(2) DEFAULT 'on', | ||
| `namespace` varchar(64) NOT NULL, | ||
| `query` varchar(1024) NOT NULL, | ||
| `primary_key` varchar(128) NOT NULL DEFAULT 'None', | ||
| PRIMARY KEY (`id`)) | ||
| ENGINE=InnoDB | ||
| COMMENT='Holds WMI Queries for Devices'"); | ||
|
|
||
| db_execute("CREATE TABLE IF NOT EXISTS `host_wmi_query` ( | ||
| `host_id` mediumint(8) unsigned NOT NULL DEFAULT '0', | ||
| `wmi_query_id` mediumint(8) unsigned NOT NULL DEFAULT '0', | ||
| `sort_field` varchar(50) NOT NULL DEFAULT '', | ||
| `title_format` varchar(50) NOT NULL DEFAULT '', | ||
| `last_started` timestamp NOT NULL DEFAULT '0000-00-00', | ||
| `last_runtime` double NOT NULL DEFAULT '0.00', | ||
| `last_failed` timestamp NOT NULL DEFAULT '0000-00-00', | ||
| PRIMARY KEY (`host_id`,`wmi_query_id`)) | ||
| ENGINE=InnoDB | ||
| COMMENT='Holds WMI Data Queries'"); | ||
|
|
||
| db_execute("CREATE TABLE IF NOT EXISTS `host_template_wmi_query` ( | ||
| `host_template_id` mediumint(8) unsigned NOT NULL DEFAULT '0', | ||
| `wmi_query_id` mediumint(8) unsigned NOT NULL DEFAULT '0', | ||
| PRIMARY KEY (`host_template_id`,`wmi_query_id`)) | ||
| ENGINE=InnoDB | ||
| COMMENT='Holds Device Template WMI Queries'"); | ||
|
|
||
| db_execute("CREATE TABLE IF NOT EXISTS `host_wmi_accounts` ( | ||
| `id` int(11) UNSIGNED NOT NULL auto_increment, | ||
| `host_id` mediumint(8) unsigned NOT NULL DEFAULT '0', | ||
| `account_id` mediumint(8) unsigned NOT NULL DEFAULT '0', | ||
| PRIMARY KEY (`id`), | ||
| KEY `host_id` (`host_id`)) | ||
| ENGINE=InnoDB | ||
| COMMENT='Holds Device WMI Accounts'"); | ||
|
|
||
| db_execute("CREATE TABLE IF NOT EXISTS `host_wmi_cache` ( | ||
| `host_id` mediumint(8) unsigned NOT NULL DEFAULT '0', | ||
| `wmi_query_id` mediumint(8) unsigned NOT NULL DEFAULT '0', | ||
| `field_name` varchar(50) NOT NULL DEFAULT '', | ||
| `field_value` varchar(4096) DEFAULT NULL, | ||
| `wmi_index` varchar(255) NOT NULL DEFAULT '', | ||
| `present` tinyint(4) NOT NULL DEFAULT '1', | ||
| `last_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
| PRIMARY KEY (`host_id`,`wmi_query_id`,`field_name`,`wmi_index`), | ||
| KEY `host_id` (`host_id`,`field_name`), | ||
| KEY `wmi_index` (`wmi_index`), | ||
| KEY `field_name` (`field_name`), | ||
| KEY `field_value` (`field_value`), | ||
| KEY `wim_query_id` (`wmi_query_id`), | ||
| KEY `present` (`present`), | ||
| KEY `last_updated` (`last_updated`)) | ||
| ENGINE=InnoDB | ||
| COMMENT='Holds Device WMI Information'"); | ||
|
|
||
| db_execute("CREATE TABLE IF NOT EXISTS `wmi_processes` ( | ||
| `pid` int(10) unsigned NOT NULL, | ||
| `taskid` int(10) unsigned NOT NULL, | ||
| `started` timestamp NOT NULL default CURRENT_TIMESTAMP, | ||
| PRIMARY KEY (`pid`)) | ||
| ENGINE=MEMORY | ||
| COMMENT='Running wmi collector processes';"); | ||
|
|
||
| $exists = db_fetch_cell('SELECT id FROM data_input WHERE hash="4af550dfe8b451579054d038ad62ba3e"'); | ||
|
|
||
| if (!$exists) { | ||
| $save = []; | ||
| $save['hash'] = '4af550dfe8b451579054d038ad62ba3e'; | ||
| $save['name'] = 'Get WMI Data'; | ||
| $save['input_string'] = ''; | ||
| $save['type_id'] = 7; | ||
| $id = sql_save($save, 'data_input'); | ||
|
|
||
| if ($id) { | ||
| db_execute("INSERT INTO `data_input_fields` | ||
| (hash, data_input_id, name, data_name, input_output, update_rra, sequence, type_code, regexp_match, allow_nulls) | ||
| VALUES ('e45cfa73589b88887725350a728d2ee9',$id,'The WMI Class Name','class','in','',0,'','','')"); | ||
|
|
||
| db_execute("INSERT INTO `data_input_fields` | ||
| (hash, data_input_id, name, data_name, input_output, update_rra, sequence, type_code, regexp_match, allow_nulls) | ||
| VALUES ('c5f782d783edec607f64bea9cccd533c',$id,'The WMI Column Name','column','in','',0,'','','')"); | ||
| } | ||
| } | ||
|
|
||
| $exists = db_fetch_cell('SELECT id | ||
| FROM data_input | ||
| WHERE hash="42e584b81075f6ad6556e62afc509179"'); | ||
|
|
||
| if (!$exists) { | ||
| $save = []; | ||
| $save['hash'] = '42e584b81075f6ad6556e62afc509179'; | ||
| $save['name'] = 'Get WMI Data (Indexed)'; | ||
| $save['input_string'] = ''; | ||
| $save['type_id'] = 8; | ||
| $id = sql_save($save, 'data_input'); | ||
|
|
||
| if ($id) { | ||
| db_execute("INSERT INTO `data_input_fields` | ||
| (hash, data_input_id, name, data_name, input_output, update_rra, sequence, type_code, regexp_match, allow_nulls) | ||
| VALUES ('fb6317f2c49e494007e968283576d5a8',$id,'The WMI Class Name','class','in','',0,'','','')"); | ||
|
|
||
| db_execute("INSERT INTO `data_input_fields` | ||
| (hash, data_input_id, name, data_name, input_output, update_rra, sequence, type_code, regexp_match, allow_nulls) | ||
| VALUES ('cfebf9aa08f98bc1bfda7de2ebe12d94',$id,'The WMI Column Name','column','in','',0,'','','')"); | ||
|
|
||
| db_execute("INSERT INTO `data_input_fields` | ||
| (hash, data_input_id, name, data_name, input_output, update_rra, sequence, type_code, regexp_match, allow_nulls) | ||
| VALUES ('41798400f48141c25bc2407b5f5b1573',$id,'Output Type ID','output_type','in','',0,'output_type','','')"); | ||
|
|
||
| db_execute("INSERT INTO `data_input_fields` | ||
| (hash, data_input_id, name, data_name, input_output, update_rra, sequence, type_code, regexp_match, allow_nulls) | ||
| VALUES ('02cd18a75a17e0a7d4ca28bc224630e0',$id,'Output Value','output','out','on',0,'','','')"); | ||
| } | ||
| } | ||
| } | ||
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
File renamed without changes.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| { | ||
| "tombstones": [ | ||
| "functions.php", | ||
| "linux_wmi.php" | ||
| ], | ||
| "expected": [ | ||
| "CHANGELOG.md", | ||
| "INFO", | ||
| "LICENSE", | ||
| "README.md", | ||
| "includes/", | ||
| "index.php", | ||
| "locales/", | ||
| "manifest.json", | ||
| "poller_wmi.php", | ||
| "script/", | ||
| "setup.php", | ||
| "templates/", | ||
| "wmi_accounts.php", | ||
| "wmi_queries.php", | ||
| "wmi_script.php", | ||
| "wmi_tools.php" | ||
| ], | ||
| "whitelist": [] | ||
| } |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.