Skip to content

Commit 01464a6

Browse files
committed
suricata: T751: use key_mangling in get_config_dict()
1 parent 2af04a5 commit 01464a6

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

data/templates/ids/suricata.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
vars:
1616
# more specific is better for alert accuracy and performance
1717
address-groups:
18-
{% for (name, value) in suricata['address-group'] %}
18+
{% for (name, value) in suricata['address_group'] %}
1919
{{ name }}: "[{{ value | join(',') }}]"
2020
{% endfor %}
2121

2222
port-groups:
23-
{% for (name, value) in suricata['port-group'] %}
23+
{% for (name, value) in suricata['port_group'] %}
2424
{{ name }}: "[{{ value | join(',') }}]"
2525
{% endfor %}
2626

src/conf_mode/service_suricata.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def get_config(config=None):
3939
if not conf.exists(base):
4040
return None
4141

42-
suricata = conf.get_config_dict(base,
42+
suricata = conf.get_config_dict(base, key_mangling=('-', '_'),
4343
get_first_key=True, with_recursive_defaults=True)
4444

4545
return suricata
@@ -81,19 +81,19 @@ def verify(suricata):
8181
if 'interface' not in suricata:
8282
raise ConfigError('No interfaces configured!')
8383

84-
if 'address-group' not in suricata:
84+
if 'address_group' not in suricata:
8585
raise ConfigError('No address-group configured!')
8686

87-
if 'port-group' not in suricata:
87+
if 'port_group' not in suricata:
8888
raise ConfigError('No port-group configured!')
8989

9090
try:
91-
topological_sort(suricata['address-group'])
91+
topological_sort(suricata['address_group'])
9292
except (ConfigError,StopIteration) as e:
9393
raise ConfigError(f'Invalid address-group: {e}')
9494

9595
try:
96-
topological_sort(suricata['port-group'])
96+
topological_sort(suricata['port_group'])
9797
except (ConfigError,StopIteration) as e:
9898
raise ConfigError(f'Invalid port-group: {e}')
9999

@@ -126,12 +126,12 @@ def format_group(group):
126126
return format_group
127127

128128
# Format the address group
129-
suricata['address-group'] = map(to_config('address'),
130-
topological_sort(suricata['address-group']))
129+
suricata['address_group'] = map(to_config('address'),
130+
topological_sort(suricata['address_group']))
131131

132132
# Format the port group
133-
suricata['port-group'] = map(to_config('port'),
134-
topological_sort(suricata['port-group']))
133+
suricata['port_group'] = map(to_config('port'),
134+
topological_sort(suricata['port_group']))
135135

136136
render(config_file, 'ids/suricata.j2', {'suricata': suricata})
137137
render(rotate_file, 'ids/suricata_logrotate.j2', suricata)

0 commit comments

Comments
 (0)