mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-21 00:19:42 +02:00
fix for scenarios where the default port range didn't always display, or overrode existing port ranges.
This commit is contained in:
BIN
jc/man/jc.1.gz
BIN
jc/man/jc.1.gz
Binary file not shown.
@ -301,6 +301,8 @@ def _parse_to_from(linedata, direction, rule_obj=None):
|
||||
if linedata_list[1].strip() in ['tcp', 'udp', 'ah', 'esp', 'gre', 'ipv6', 'igmp']:
|
||||
rule_obj[direction + '_transport'] = linedata_list[1].strip()
|
||||
linedata = linedata_list[0]
|
||||
else:
|
||||
rule_obj[direction + '_transport'] = 'any'
|
||||
else:
|
||||
rule_obj[direction + '_transport'] = 'any'
|
||||
|
||||
@ -364,24 +366,16 @@ def _parse_to_from(linedata, direction, rule_obj=None):
|
||||
rule_obj[direction + '_ip_prefix'] = '0'
|
||||
|
||||
# finally set default ports if no ports exist and there should be some
|
||||
set_default = False
|
||||
if direction + '_transport' in rule_obj:
|
||||
if rule_obj[direction + '_transport'] in ['tcp', 'udp', 'any']:
|
||||
if not port_list and not port_ranges:
|
||||
set_default = True
|
||||
|
||||
else:
|
||||
rule_obj[direction + '_transport'] = 'any'
|
||||
set_default = True
|
||||
|
||||
if set_default:
|
||||
rule_obj[direction + '_port_ranges'] = [
|
||||
{
|
||||
'start': '0',
|
||||
'end': '65535'
|
||||
}
|
||||
]
|
||||
rule_obj[direction + '_service'] = None
|
||||
rule_obj[direction + '_port_ranges'] = [
|
||||
{
|
||||
'start': '0',
|
||||
'end': '65535'
|
||||
}
|
||||
]
|
||||
rule_obj[direction + '_service'] = None
|
||||
|
||||
return rule_obj
|
||||
|
||||
|
BIN
man/jc.1.gz
BIN
man/jc.1.gz
Binary file not shown.
2
tests/fixtures/generic/ufw-numbered.json
vendored
2
tests/fixtures/generic/ufw-numbered.json
vendored
File diff suppressed because one or more lines are too long
2
tests/fixtures/generic/ufw.json
vendored
2
tests/fixtures/generic/ufw.json
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user