Language: Go
Label: safe
CWE: CWE-78 \u2014 Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.

Code:
func (f *Firewall) RichRules(rule FireInfo, operation string) error {
	if cmd.CheckIllegal(operation, rule.Address, rule.Protocol, rule.Port, rule.Strategy) {
		return buserr.New(constant.ErrCmdIllegal)
	}
	ruleStr := ""
	if strings.Contains(rule.Address, "-") {
		std, err := cmd.Execf("firewall-cmd --permanent --new-ipset=%s --type=hash:ip", rule.Address)
		if err != nil {
			return fmt.Errorf("add new ipset failed, err: %s", std)
		}
		std2, err := cmd.Execf("firewall-cmd --permanent --ipset=%s --add-entry=%s", rule.Address, rule.Address)
		if err != nil {
			return fmt.Errorf("add entry to ipset failed, err: %s", std2)
		}
		if err := f.Reload(); err != nil {
			return err
		}
		ruleStr = fmt.Sprintf("rule source ipset=%s %s", rule.Address, rule.Strategy)
	} else {
		ruleStr = "rule family=ipv4 "
		if len(rule.Address) != 0 {
			ruleStr += fmt.Sprintf("source address=%s ", rule.Address)
		}
		if len(rule.Port) != 0 {
			ruleStr += fmt.Sprintf("port port=%s ", rule.Port)
		}
		if len(rule.Protocol) != 0 {
			ruleStr += fmt.Sprintf("protocol=%s ", rule.Protocol)
		}
		ruleStr += rule.Strategy
	}
	stdout, err := cmd.Execf("firewall-cmd --zone=public --%s-rich-rule '%s' --permanent", operation, ruleStr)
	if err != nil {
		return fmt.Errorf("%s rich rules failed, err: %s", operation, stdout)
	}
	return nil
}