fix: allow more empty fields on rsyslogd, NTP, IPS and USG settings (#45)

This commit is contained in:
Mateusz Filipowicz
2025-03-05 12:29:46 +01:00
committed by GitHub
parent e37bb391a2
commit 55cfe22636
5 changed files with 60 additions and 40 deletions

View File

@@ -485,6 +485,26 @@ customizations:
Expire:
fieldType: "int"
customUnmarshalType: "emptyStringInt"
SettingIps:
fields:
_all:
omitEmpty: false
SettingNtp:
fields:
_all:
omitEmpty: false
SettingRsyslogd:
fields:
Contents:
omitEmpty: false
IP:
omitEmpty: false
NetconsoleHost:
omitEmpty: false
SettingUsg:
fields:
GeoIPFilteringCountries:
omitEmpty: false
User:
fields:
Blocked:

View File

@@ -29,19 +29,19 @@ type SettingIps struct {
Key string `json:"key"`
AdBlockingConfigurations []SettingIpsAdBlockingConfigurations `json:"ad_blocking_configurations,omitempty"`
AdBlockingConfigurations []SettingIpsAdBlockingConfigurations `json:"ad_blocking_configurations"`
AdBlockingEnabled bool `json:"ad_blocking_enabled"`
AdvancedFilteringPreference string `json:"advanced_filtering_preference,omitempty" validate:"omitempty,oneof=manual disabled"` // |manual|disabled
AdvancedFilteringPreference string `json:"advanced_filtering_preference" validate:"omitempty,oneof=manual disabled"` // |manual|disabled
DNSFiltering bool `json:"dns_filtering"`
DNSFilters []SettingIpsDNSFilters `json:"dns_filters,omitempty"`
EnabledCategories []string `json:"enabled_categories,omitempty" validate:"omitempty,oneof=emerging-activex emerging-attackresponse botcc emerging-chat ciarmy compromised emerging-dns emerging-dos dshield emerging-exploit emerging-ftp emerging-games emerging-icmp emerging-icmpinfo emerging-imap emerging-inappropriate emerging-info emerging-malware emerging-misc emerging-mobile emerging-netbios emerging-p2p emerging-policy emerging-pop3 emerging-rpc emerging-scada emerging-scan emerging-shellcode emerging-smtp emerging-snmp emerging-sql emerging-telnet emerging-tftp tor emerging-useragent emerging-voip emerging-webapps emerging-webclient emerging-webserver emerging-worm exploit-kit adware-pup botcc-portgrouped phishing threatview-cs-c2 3coresec chat coinminer current-events drop hunting icmp-info inappropriate info ja3 policy scada dark-web-blocker-list malicious-hosts"` // emerging-activex|emerging-attackresponse|botcc|emerging-chat|ciarmy|compromised|emerging-dns|emerging-dos|dshield|emerging-exploit|emerging-ftp|emerging-games|emerging-icmp|emerging-icmpinfo|emerging-imap|emerging-inappropriate|emerging-info|emerging-malware|emerging-misc|emerging-mobile|emerging-netbios|emerging-p2p|emerging-policy|emerging-pop3|emerging-rpc|emerging-scada|emerging-scan|emerging-shellcode|emerging-smtp|emerging-snmp|emerging-sql|emerging-telnet|emerging-tftp|tor|emerging-useragent|emerging-voip|emerging-webapps|emerging-webclient|emerging-webserver|emerging-worm|exploit-kit|adware-pup|botcc-portgrouped|phishing|threatview-cs-c2|3coresec|chat|coinminer|current-events|drop|hunting|icmp-info|inappropriate|info|ja3|policy|scada|dark-web-blocker-list|malicious-hosts
EnabledNetworks []string `json:"enabled_networks,omitempty"`
Honeypot []SettingIpsHoneypot `json:"honeypot,omitempty"`
DNSFilters []SettingIpsDNSFilters `json:"dns_filters"`
EnabledCategories []string `json:"enabled_categories" validate:"omitempty,oneof=emerging-activex emerging-attackresponse botcc emerging-chat ciarmy compromised emerging-dns emerging-dos dshield emerging-exploit emerging-ftp emerging-games emerging-icmp emerging-icmpinfo emerging-imap emerging-inappropriate emerging-info emerging-malware emerging-misc emerging-mobile emerging-netbios emerging-p2p emerging-policy emerging-pop3 emerging-rpc emerging-scada emerging-scan emerging-shellcode emerging-smtp emerging-snmp emerging-sql emerging-telnet emerging-tftp tor emerging-useragent emerging-voip emerging-webapps emerging-webclient emerging-webserver emerging-worm exploit-kit adware-pup botcc-portgrouped phishing threatview-cs-c2 3coresec chat coinminer current-events drop hunting icmp-info inappropriate info ja3 policy scada dark-web-blocker-list malicious-hosts"` // emerging-activex|emerging-attackresponse|botcc|emerging-chat|ciarmy|compromised|emerging-dns|emerging-dos|dshield|emerging-exploit|emerging-ftp|emerging-games|emerging-icmp|emerging-icmpinfo|emerging-imap|emerging-inappropriate|emerging-info|emerging-malware|emerging-misc|emerging-mobile|emerging-netbios|emerging-p2p|emerging-policy|emerging-pop3|emerging-rpc|emerging-scada|emerging-scan|emerging-shellcode|emerging-smtp|emerging-snmp|emerging-sql|emerging-telnet|emerging-tftp|tor|emerging-useragent|emerging-voip|emerging-webapps|emerging-webclient|emerging-webserver|emerging-worm|exploit-kit|adware-pup|botcc-portgrouped|phishing|threatview-cs-c2|3coresec|chat|coinminer|current-events|drop|hunting|icmp-info|inappropriate|info|ja3|policy|scada|dark-web-blocker-list|malicious-hosts
EnabledNetworks []string `json:"enabled_networks"`
Honeypot []SettingIpsHoneypot `json:"honeypot"`
HoneypotEnabled bool `json:"honeypot_enabled"`
IPsMode string `json:"ips_mode,omitempty" validate:"omitempty,oneof=ids ips ipsInline disabled"` // ids|ips|ipsInline|disabled
IPsMode string `json:"ips_mode" validate:"omitempty,oneof=ids ips ipsInline disabled"` // ids|ips|ipsInline|disabled
MemoryOptimized bool `json:"memory_optimized"`
RestrictTorrents bool `json:"restrict_torrents"`
Suppression SettingIpsSuppression `json:"suppression,omitempty"`
Suppression SettingIpsSuppression `json:"suppression"`
}
func (dst *SettingIps) UnmarshalJSON(b []byte) error {
@@ -81,12 +81,12 @@ func (dst *SettingIpsAdBlockingConfigurations) UnmarshalJSON(b []byte) error {
}
type SettingIpsAlerts struct {
Category string `json:"category,omitempty"`
Gid int `json:"gid,omitempty"`
ID int `json:"id,omitempty"`
Signature string `json:"signature,omitempty"`
Tracking []SettingIpsTracking `json:"tracking,omitempty"`
Type string `json:"type,omitempty" validate:"omitempty,oneof=all track"` // all|track
Category string `json:"category"`
Gid int `json:"gid"`
ID int `json:"id"`
Signature string `json:"signature"`
Tracking []SettingIpsTracking `json:"tracking"`
Type string `json:"type" validate:"omitempty,oneof=all track"` // all|track
}
func (dst *SettingIpsAlerts) UnmarshalJSON(b []byte) error {
@@ -111,14 +111,14 @@ func (dst *SettingIpsAlerts) UnmarshalJSON(b []byte) error {
}
type SettingIpsDNSFilters struct {
AllowedSites []string `json:"allowed_sites,omitempty"` // ^[a-zA-Z0-9.-]+$|^$
BlockedSites []string `json:"blocked_sites,omitempty"` // ^[a-zA-Z0-9.-]+$|^$
BlockedTld []string `json:"blocked_tld,omitempty"` // ^[a-zA-Z0-9.-]+$|^$
Description string `json:"description,omitempty"`
Filter string `json:"filter,omitempty" validate:"omitempty,oneof=none work family"` // none|work|family
Name string `json:"name,omitempty"`
AllowedSites []string `json:"allowed_sites"` // ^[a-zA-Z0-9.-]+$|^$
BlockedSites []string `json:"blocked_sites"` // ^[a-zA-Z0-9.-]+$|^$
BlockedTld []string `json:"blocked_tld"` // ^[a-zA-Z0-9.-]+$|^$
Description string `json:"description"`
Filter string `json:"filter" validate:"omitempty,oneof=none work family"` // none|work|family
Name string `json:"name"`
NetworkID string `json:"network_id"`
Version string `json:"version,omitempty" validate:"omitempty,oneof=v4 v6"` // v4|v6
Version string `json:"version" validate:"omitempty,oneof=v4 v6"` // v4|v6
}
func (dst *SettingIpsDNSFilters) UnmarshalJSON(b []byte) error {
@@ -138,9 +138,9 @@ func (dst *SettingIpsDNSFilters) UnmarshalJSON(b []byte) error {
}
type SettingIpsHoneypot struct {
IPAddress string `json:"ip_address,omitempty"`
IPAddress string `json:"ip_address"`
NetworkID string `json:"network_id"`
Version string `json:"version,omitempty" validate:"omitempty,oneof=v4 v6"` // v4|v6
Version string `json:"version" validate:"omitempty,oneof=v4 v6"` // v4|v6
}
func (dst *SettingIpsHoneypot) UnmarshalJSON(b []byte) error {
@@ -160,8 +160,8 @@ func (dst *SettingIpsHoneypot) UnmarshalJSON(b []byte) error {
}
type SettingIpsSuppression struct {
Alerts []SettingIpsAlerts `json:"alerts,omitempty"`
Whitelist []SettingIpsWhitelist `json:"whitelist,omitempty"`
Alerts []SettingIpsAlerts `json:"alerts"`
Whitelist []SettingIpsWhitelist `json:"whitelist"`
}
func (dst *SettingIpsSuppression) UnmarshalJSON(b []byte) error {
@@ -181,9 +181,9 @@ func (dst *SettingIpsSuppression) UnmarshalJSON(b []byte) error {
}
type SettingIpsTracking struct {
Direction string `json:"direction,omitempty" validate:"omitempty,oneof=both src dest"` // both|src|dest
Mode string `json:"mode,omitempty" validate:"omitempty,oneof=ip subnet network"` // ip|subnet|network
Value string `json:"value,omitempty"`
Direction string `json:"direction" validate:"omitempty,oneof=both src dest"` // both|src|dest
Mode string `json:"mode" validate:"omitempty,oneof=ip subnet network"` // ip|subnet|network
Value string `json:"value"`
}
func (dst *SettingIpsTracking) UnmarshalJSON(b []byte) error {
@@ -203,9 +203,9 @@ func (dst *SettingIpsTracking) UnmarshalJSON(b []byte) error {
}
type SettingIpsWhitelist struct {
Direction string `json:"direction,omitempty" validate:"omitempty,oneof=both src dest"` // both|src|dest
Mode string `json:"mode,omitempty" validate:"omitempty,oneof=ip subnet network"` // ip|subnet|network
Value string `json:"value,omitempty"`
Direction string `json:"direction" validate:"omitempty,oneof=both src dest"` // both|src|dest
Mode string `json:"mode" validate:"omitempty,oneof=ip subnet network"` // ip|subnet|network
Value string `json:"value"`
}
func (dst *SettingIpsWhitelist) UnmarshalJSON(b []byte) error {

View File

@@ -29,11 +29,11 @@ type SettingNtp struct {
Key string `json:"key"`
NtpServer1 string `json:"ntp_server_1,omitempty"`
NtpServer2 string `json:"ntp_server_2,omitempty"`
NtpServer3 string `json:"ntp_server_3,omitempty"`
NtpServer4 string `json:"ntp_server_4,omitempty"`
SettingPreference string `json:"setting_preference,omitempty" validate:"omitempty,oneof=auto manual"` // auto|manual
NtpServer1 string `json:"ntp_server_1"`
NtpServer2 string `json:"ntp_server_2"`
NtpServer3 string `json:"ntp_server_3"`
NtpServer4 string `json:"ntp_server_4"`
SettingPreference string `json:"setting_preference" validate:"omitempty,oneof=auto manual"` // auto|manual
}
func (dst *SettingNtp) UnmarshalJSON(b []byte) error {

View File

@@ -29,13 +29,13 @@ type SettingRsyslogd struct {
Key string `json:"key"`
Contents []string `json:"contents,omitempty" validate:"omitempty,oneof=device client firewall_default_policy triggers updates admin_activity critical security_detections vpn"` // device|client|firewall_default_policy|triggers|updates|admin_activity|critical|security_detections|vpn
Contents []string `json:"contents" validate:"omitempty,oneof=device client firewall_default_policy triggers updates admin_activity critical security_detections vpn"` // device|client|firewall_default_policy|triggers|updates|admin_activity|critical|security_detections|vpn
Debug bool `json:"debug"`
Enabled bool `json:"enabled"`
IP string `json:"ip,omitempty"`
IP string `json:"ip"`
LogAllContents bool `json:"log_all_contents"`
NetconsoleEnabled bool `json:"netconsole_enabled"`
NetconsoleHost string `json:"netconsole_host,omitempty"`
NetconsoleHost string `json:"netconsole_host"`
NetconsolePort int `json:"netconsole_port,omitempty"` // [1-9][0-9]{0,3}|[1-5][0-9]{4}|[6][0-4][0-9]{3}|[6][5][0-4][0-9]{2}|[6][5][5][0-2][0-9]|[6][5][5][3][0-5]
Port int `json:"port,omitempty"` // [1-9][0-9]{0,3}|[1-5][0-9]{4}|[6][0-4][0-9]{3}|[6][5][0-4][0-9]{2}|[6][5][5][0-2][0-9]|[6][5][5][3][0-5]
ThisController bool `json:"this_controller"`

View File

@@ -48,7 +48,7 @@ type SettingUsg struct {
EchoServer string `json:"echo_server,omitempty"` // [^\"\' ]{1,255}
FtpModule bool `json:"ftp_module"`
GeoIPFilteringBlock string `json:"geo_ip_filtering_block,omitempty" validate:"omitempty,oneof=block allow"` // block|allow
GeoIPFilteringCountries string `json:"geo_ip_filtering_countries,omitempty"` // ^([A-Z]{2})?(,[A-Z]{2}){0,149}$
GeoIPFilteringCountries string `json:"geo_ip_filtering_countries"` // ^([A-Z]{2})?(,[A-Z]{2}){0,149}$
GeoIPFilteringEnabled bool `json:"geo_ip_filtering_enabled"`
GeoIPFilteringTrafficDirection string `json:"geo_ip_filtering_traffic_direction,omitempty" validate:"omitempty,oneof=both ingress egress"` // ^(both|ingress|egress)$
GreModule bool `json:"gre_module"`