Skip to content
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .omc/sessions/0ad57977-0b9b-4712-bf0c-d8591161a6c5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"session_id": "0ad57977-0b9b-4712-bf0c-d8591161a6c5",
"ended_at": "2026-04-09T20:58:25.835Z",
"reason": "other",
"agents_spawned": 0,
"agents_completed": 0,
"modes_used": []
}
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

This .omc/sessions/*.json file appears to be an editor/automation session artifact, not part of the plugin runtime. It should not be committed; please remove it from the PR and add .omc/ (or at least .omc/sessions/) to .gitignore to prevent re-adding.

Suggested change
{
"session_id": "0ad57977-0b9b-4712-bf0c-d8591161a6c5",
"ended_at": "2026-04-09T20:58:25.835Z",
"reason": "other",
"agents_spawned": 0,
"agents_completed": 0,
"modes_used": []
}

Copilot uses AI. Check for mistakes.
8 changes: 8 additions & 0 deletions .omc/sessions/426d31d2-5007-4a69-94e9-7171c89be435.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"session_id": "426d31d2-5007-4a69-94e9-7171c89be435",
"ended_at": "2026-04-09T20:39:23.599Z",
"reason": "other",
"agents_spawned": 0,
"agents_completed": 0,
"modes_used": []
}
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

This .omc/sessions/*.json file appears to be an editor/automation session artifact, not part of the plugin runtime. It should not be committed; please remove it from the PR and add .omc/ (or at least .omc/sessions/) to .gitignore to prevent re-adding.

Suggested change
{
"session_id": "426d31d2-5007-4a69-94e9-7171c89be435",
"ended_at": "2026-04-09T20:39:23.599Z",
"reason": "other",
"agents_spawned": 0,
"agents_completed": 0,
"modes_used": []
}

Copilot uses AI. Check for mistakes.
8 changes: 8 additions & 0 deletions .omc/sessions/865e7e69-4115-4c88-a9ea-8264b75b1cfc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"session_id": "865e7e69-4115-4c88-a9ea-8264b75b1cfc",
"ended_at": "2026-04-09T20:42:25.246Z",
"reason": "other",
"agents_spawned": 0,
"agents_completed": 0,
"modes_used": []
}
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

This .omc/sessions/*.json file appears to be an editor/automation session artifact, not part of the plugin runtime. It should not be committed; please remove it from the PR and add .omc/ (or at least .omc/sessions/) to .gitignore to prevent re-adding.

Suggested change
{
"session_id": "865e7e69-4115-4c88-a9ea-8264b75b1cfc",
"ended_at": "2026-04-09T20:42:25.246Z",
"reason": "other",
"agents_spawned": 0,
"agents_completed": 0,
"modes_used": []
}

Copilot uses AI. Check for mistakes.
8 changes: 8 additions & 0 deletions .omc/sessions/d67358a1-81fd-4c38-8750-7175bf018252.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"session_id": "d67358a1-81fd-4c38-8750-7175bf018252",
"ended_at": "2026-04-09T20:46:21.611Z",
"reason": "other",
"agents_spawned": 0,
"agents_completed": 0,
"modes_used": []
}
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

This .omc/sessions/*.json file appears to be an editor/automation session artifact, not part of the plugin runtime. It should not be committed; please remove it from the PR and add .omc/ (or at least .omc/sessions/) to .gitignore to prevent re-adding.

Suggested change
{
"session_id": "d67358a1-81fd-4c38-8750-7175bf018252",
"ended_at": "2026-04-09T20:46:21.611Z",
"reason": "other",
"agents_spawned": 0,
"agents_completed": 0,
"modes_used": []
}

Copilot uses AI. Check for mistakes.
8 changes: 8 additions & 0 deletions .omc/sessions/e795e842-5b52-4c4f-a301-d0c076c145ec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"session_id": "e795e842-5b52-4c4f-a301-d0c076c145ec",
"ended_at": "2026-04-09T20:40:09.532Z",
"reason": "other",
"agents_spawned": 0,
"agents_completed": 0,
"modes_used": []
}
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

This .omc/sessions/*.json file appears to be an editor/automation session artifact, not part of the plugin runtime. It should not be committed; please remove it from the PR and add .omc/ (or at least .omc/sessions/) to .gitignore to prevent re-adding.

Suggested change
{
"session_id": "e795e842-5b52-4c4f-a301-d0c076c145ec",
"ended_at": "2026-04-09T20:40:09.532Z",
"reason": "other",
"agents_spawned": 0,
"agents_completed": 0,
"modes_used": []
}

Copilot uses AI. Check for mistakes.
30 changes: 16 additions & 14 deletions audit.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2026 The Cacti Group |
Expand Down Expand Up @@ -61,7 +63,7 @@
} elseif (cacti_sizeof($data)) {
$attribs = json_decode($data['post']);

$nattribs = array();
$nattribs = [];
foreach($attribs as $field => $content) {
$nattribs[$field] = $content;
}
Expand Down Expand Up @@ -97,7 +99,7 @@
$output .= ($output != '' ? '</tr>':'') . '<tr>';
}

if (is_array($content)) {
if (is_[$content]) {
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

This condition is syntactically invalid: is_[$content] will cause a PHP parse error. It looks like this should be is_array($content) to match the previous behavior when rendering attribute values.

Suggested change
if (is_[$content]) {
if (is_array($content)) {

Copilot uses AI. Check for mistakes.
$output .= '<td style="font-weight:bold;white-space:nowrap;">' . $field . '</td><td">' . implode(',', $content) . '</td>';
} else {
$output .= '<td style="font-weight:bold;white-space:nowrap;">' . $field . '</td><td>' . $content . '</td>';
Expand Down Expand Up @@ -182,7 +184,7 @@ function audit_export_rows() {
$post = json_decode($event['post']);
$poster = '';
foreach($post as $var => $value) {
if (is_array($value)) {
if (is_[$value]) {
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

This condition is syntactically invalid: is_[$value] will cause a PHP parse error during CSV export. It appears the intent was to keep the prior is_array($value) check.

Suggested change
if (is_[$value]) {
if (is_array($value)) {

Copilot uses AI. Check for mistakes.
$poster .= ($poster != '' ? '|':'') . $var . ':' . implode('%', $value);
} else {
$poster .= ($poster != '' ? '|':'') . $var . ':' . $value;
Expand Down Expand Up @@ -211,40 +213,40 @@ function audit_csv_escape($string) {
function process_request_vars() {
/* ================= input validation and session storage ================= */
$filters = array(
'rows' => array(
'rows' => [
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => '-1'
),
'page' => array(
],
'page' => [
'filter' => FILTER_VALIDATE_INT,
'default' => '1'
),
'filter' => array(
],
'filter' => [
'filter' => FILTER_DEFAULT,
'pageset' => true,
'default' => ''
),
],
'sort_column' => array(
'filter' => FILTER_CALLBACK,
'default' => 'event_time',
'options' => array('options' => 'sanitize_search_string')
'options' => ['options' => 'sanitize_search_string']
),
'sort_direction' => array(
'filter' => FILTER_CALLBACK,
'default' => 'DESC',
'options' => array('options' => 'sanitize_search_string')
'options' => ['options' => 'sanitize_search_string']
),
'user_id' => array(
'user_id' => [
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => '-1'
),
],
'event_page' => array(
'filter' => FILTER_CALLBACK,
'pageset' => true,
'default' => '-1',
'options' => array('options' => 'sanitize_search_string')
'options' => ['options' => 'sanitize_search_string']
)
);

Expand Down
45 changes: 26 additions & 19 deletions audit_functions.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
<?php

declare(strict_types=1);

function audit_process_page_data($page, $drop_action, $selected_items) {
$objects = array();
$objects = [];

if (!is_string($page) || $page === '' || !is_[$selected_items]) {
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

The new guard clause uses !is_[$selected_items], which is syntactically invalid and will cause a PHP parse error. This should be an array check (e.g., !is_array($selected_items)) so audit_process_page_data() can safely early-return when unserialize() fails.

Suggested change
if (!is_string($page) || $page === '' || !is_[$selected_items]) {
if (!is_string($page) || $page === '' || !is_array($selected_items)) {

Copilot uses AI. Check for mistakes.
return json_encode($objects);
}

if ($drop_action !== false) {
switch ($page) {
case 'host.php':
Expand All @@ -10,23 +17,23 @@ function audit_process_page_data($page, $drop_action, $selected_items) {
$objects[] = db_fetch_assoc_prepared('SELECT id AS host_id,site_id,description,hostname,status,status_fail_date AS last_failed_date,status_rec_date AS last_recovered_date
FROM host
WHERE id IN (?)',
array($item));
[$item]);
}
break;
case 'host_templates.php':
foreach ($selected_items as $item) {
$objects[] = db_fetch_assoc_prepared('SELECT name
FROM host_template
WHERE id IN (?)',
array($item));
[$item]);
}
break;

case 'templates_export.php':
foreach ($selected_items as $item) {
$objects[] = db_fetch_assoc_prepared('SELECT name FROM graph_templates
WHERE id IN (?)',
array($item));
[$item]);
}
break;

Expand All @@ -36,7 +43,7 @@ function audit_process_page_data($page, $drop_action, $selected_items) {
$result = db_fetch_assoc_prepared('SELECT id, network_id,hostname,ip,sysName,syslocation,snmp,up
FROM automation_devices
WHERE id IN (?)',
array($item));
[$item]);

foreach ($result as &$row) {
$row['snmp'] = ($row['snmp'] == 1) ? 'UP' : 'Down';
Expand All @@ -53,7 +60,7 @@ function audit_process_page_data($page, $drop_action, $selected_items) {
$objects[] = db_fetch_assoc_prepared('SELECT name
FROM graph_templates
WHERE id IN (?)',
array($item));
[$item]);
}
break;

Expand All @@ -62,14 +69,14 @@ function audit_process_page_data($page, $drop_action, $selected_items) {
$objects[] = db_fetch_assoc_prepared('SELECT id,name_cache AS THOLD_NAME,data_source_name AS Data_Source
FROM thold_data
WHERE id IN (?)',
array($item));
[$item]);
}
break;
case 'data_sources.php':
foreach ($selected_items as $item) {
$objects[] = db_fetch_assoc_prepared('select name_cache AS Data_Source_Name,active from data_template_data
WHERE local_data_id IN (?)',
array($item));
[$item]);
}
break;

Expand All @@ -78,7 +85,7 @@ function audit_process_page_data($page, $drop_action, $selected_items) {
$objects[] = db_fetch_assoc_prepared('SELECT name
FROM data_template
WHERE id IN (?)',
array($item));
[$item]);
}
break;

Expand All @@ -87,7 +94,7 @@ function audit_process_page_data($page, $drop_action, $selected_items) {
$objects[] = db_fetch_assoc_prepared('SELECT name
FROM aggregate_graph_template
WHERE id IN (?)',
array($item));
[$item]);
}
break;

Expand All @@ -96,23 +103,23 @@ function audit_process_page_data($page, $drop_action, $selected_items) {
$objects[] = db_fetch_assoc_prepared('SELECT name
FROM thold_template
WHERE id IN (?)',
array($item));
[$item]);
}
break;
case 'user_admin.php':
foreach ($selected_items as $item) {
$objects[] = db_fetch_assoc_prepared('SELECT username
FROM user_auth
WHERE id IN (?)',
array($item));
[$item]);
}
break;
case 'user_group_admin.php':
foreach ($selected_items as $item) {
$objects[] = db_fetch_assoc_prepared('SELECT name
FROM user_auth_group
WHERE id IN (?)',
array($item));
[$item]);
}
break;
}
Expand Down Expand Up @@ -148,10 +155,10 @@ function audit_config_insert() {

/* sanitize and serialize selected items */
if (isset($post['selected_items'])) {
$selected_items = unserialize(stripslashes($post['selected_items']), array('allowed_classes' => false));
$selected_items = unserialize(stripslashes($post['selected_items']), ['allowed_classes' => false]);
$drop_action = $post['drp_action'];
} else {
$selected_items = array();
$selected_items = [];
$drop_action = false;
}

Expand Down Expand Up @@ -209,7 +216,7 @@ function audit_config_insert() {

db_execute_prepared('INSERT INTO audit_log (page, user_id, action, ip_address, user_agent, event_time, post, object_data)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
array($page, $user_id, $action, $ip_address, $user_agent, $event_time, $post, $object_data));
[$page, $user_id, $action, $ip_address, $user_agent, $event_time, $post, $object_data]);

if ($audit_log == '') {
set_config_option('audit_log_external_path', $base . '/log/audit.log');
Expand All @@ -226,7 +233,7 @@ function audit_config_insert() {
}

if (read_config_option('audit_log_external') == 'on' && $audit_log != '' && file_exists($audit_log)) {
$log_data = array(
$log_data = [
'page' => $page,
'user_id' => $user_id,
'action' => $action,
Expand All @@ -235,7 +242,7 @@ function audit_config_insert() {
'event_time' => $event_time,
'post' => $post,
'object_data' => $object_data
);
];

$log_msg = json_encode($log_data) . "\n";
$file = fopen($audit_log, 'a');
Expand Down Expand Up @@ -263,7 +270,7 @@ function audit_config_insert() {

db_execute_prepared('INSERT INTO audit_log (page, user_id, action, ip_address, user_agent, event_time, post)
VALUES (?, ?, ?, ?, ?, ?, ?)',
array($page, $user_id, $action, $ip_address, $user_agent, $event_time, $post));
[$page, $user_id, $action, $ip_address, $user_agent, $event_time, $post]);
}
}
}
2 changes: 2 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2026 The Cacti Group |
Expand Down
2 changes: 2 additions & 0 deletions locales/LC_MESSAGES/index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2026 The Cacti Group |
Expand Down
2 changes: 2 additions & 0 deletions locales/index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2026 The Cacti Group |
Expand Down
10 changes: 6 additions & 4 deletions setup.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2026 The Cacti Group |
Expand Down Expand Up @@ -67,7 +69,7 @@ function audit_check_upgrade() {
include_once($config['library_path'] . '/database.php');
include_once($config['library_path'] . '/functions.php');

$files = array('plugins.php', 'audit.php');
$files = ['plugins.php', 'audit.php'];
if (isset($_SERVER['PHP_SELF']) && !in_array(basename($_SERVER['PHP_SELF']), $files)) {
return;
}
Expand Down Expand Up @@ -228,7 +230,7 @@ function audit_log_valid_event() {
return $valid;
}

function audit_utilities_array() {
function audit_utilities_[] {
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

audit_utilities_array is registered as a hook, but the function definition here is syntactically invalid (function audit_utilities_[] {). This will cause a PHP parse error and prevent the plugin from loading. Rename/restore the function declaration to audit_utilities_array() (and keep the audit_ prefix).

Suggested change
function audit_utilities_[] {
function audit_utilities_array() {

Copilot uses AI. Check for mistakes.
global $utilities;

if (version_compare(CACTI_VERSION, '1.3.0', '<')) {
Expand All @@ -250,7 +252,7 @@ function audit_config_arrays() {
global $menu, $messages, $audit_retentions, $utilities;

if (isset($_SESSION['audit_message']) && $_SESSION['audit_message'] != '') {
$messages['audit_message'] = array('message' => $_SESSION['audit_message'], 'type' => 'info');
$messages['audit_message'] = ['message' => $_SESSION['audit_message'], 'type' => 'info'];
}

$audit_retentions = array(
Expand All @@ -269,7 +271,7 @@ function audit_config_arrays() {
$menu[__('Utilities')]['plugins/audit/audit.php'] = __('Audit Log', 'audit');

if (function_exists('auth_augment_roles')) {
auth_augment_roles(__('System Administration'), array('audit.php'));
auth_augment_roles(__('System Administration'), ['audit.php']);
}

audit_check_upgrade();
Expand Down
Loading