** Copyright (C) 2001-2025 Zabbix SIA
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
** 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 Affero General Public License for more details.
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
"golang.zabbix.com/agent2/pkg/itemutil"
"golang.zabbix.com/agent2/pkg/zbxcmd"
"golang.zabbix.com/sdk/errs"
"golang.zabbix.com/sdk/plugin"
type parameterInfo struct {
type UserParameterPlugin struct {
parameters map[string]*parameterInfo
var userParameter UserParameterPlugin
func (p *UserParameterPlugin) cmd(key string, params []string) (string, error) {
parameter := p.parameters[key]
for i := 0; i < len(params); i++ {
for i := strings.IndexByte(s, '$'); i != -1; i = strings.IndexByte(s, '$') {
b.WriteString(parameter.cmd)
} else if s[i] >= '1' && s[i] <= '9' {
if int(s[i]-'0') <= len(params) {
param := params[s[i]-'0'-1]
if p.unsafeUserParameters == 0 {
if j := strings.IndexAny(param, "\\'\"`*?[]{}~$!&;()<>|#@\n"); j != -1 {
if unicode.IsPrint(rune(param[j])) {
return "", fmt.Errorf("Character \"%c\" is not allowed", param[j])
return "", fmt.Errorf("Character 0x%02x is not allowed", param[j])