Skip to content

Commit

Permalink
Merge pull request from GHSA-gj3f-p326-gh8r
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWitness committed Apr 7, 2024
1 parent 52a5b6b commit 8b516cb
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions lib/api_automation.php
Expand Up @@ -1136,7 +1136,7 @@ function clearFilter() {
if ($leaf_type == TREE_ITEM_TYPE_HOST) {
$sql_tables = 'FROM host AS h
LEFT JOIN host_template AS ht
ON (h.host_template_id=ht.id)';
ON (h.host_template_id = ht.id)';

$sql_where = 'WHERE h.deleted = ""';
} elseif ($leaf_type == TREE_ITEM_TYPE_GRAPH) {
Expand Down Expand Up @@ -1185,7 +1185,14 @@ function clearFilter() {
$sql_filter = build_matching_objects_filter($rule_id, AUTOMATION_RULE_TYPE_TREE_MATCH);

$templates = array();
$sql_field = $item['field'] . ' AS source ';

if (api_automation_column_exists($item['field'], array('host', 'host_template', 'graph_local', 'graph_templates_graph', 'graph_templates'))) {
$sql_field = $item['field'] . ' AS source ';
} else {
$sql_field = '"SQL Injection" AS source ';
cacti_log('Attempted SQL Injection found in Tree Automation for the field variable.', false, 'AUTOM8');
raise_message('sql_injection', __('Attempted SQL Injection found in Tree Automation for the field variable.'), MESSAGE_LEVEL_ERROR);
}

/* now we build up a new query for counting the rows */
$rows_query = "SELECT h.id AS host_id, h.hostname, h.description,
Expand Down Expand Up @@ -1271,6 +1278,20 @@ function clearFilter() {
print "</form>\n";
}

function api_automation_column_exists($column, $tables) {
$column = str_replace(array('h.', 'ht.', 'gt.', 'gl.', 'gtg.'), '', 1);

if (cacti_sizeof($tables)) {
foreach($tables as $table) {
if (db_column_exists($table, $column)) {
return true;
}
}
}

return false;
}

function display_match_rule_items($title, $rule_id, $rule_type, $module) {
global $automation_op_array, $automation_oper, $automation_tree_header_types;

Expand Down

0 comments on commit 8b516cb

Please sign in to comment.