diff --git a/tests/fixtures/generic/ufw-numbered.json b/tests/fixtures/generic/ufw-numbered.json index cf8ab6cf..76d14a27 100644 --- a/tests/fixtures/generic/ufw-numbered.json +++ b/tests/fixtures/generic/ufw-numbered.json @@ -1 +1 @@ -{"status":"active","logging":"on","logging_level":"low","default":"deny (incoming), allow (outgoing), deny (routed)","new_profiles":"skip","rules":[{"action":"ALLOW","action_direction":"IN","index":1,"network_protocol":"ipv4","to_interface":"any","to_transport":"tcp","to_start_port":22,"to_end_port":22,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":"0","comment":null,"from_ip":"0.0.0.0","from_ip_prefix":"0","from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"OUT","index":2,"network_protocol":"ipv6","to_interface":"any","to_transport":"tcp","to_start_port":22,"to_end_port":22,"to_service":null,"to_ip":"::","to_ip_prefix":"0","comment":null,"from_ip":"::","from_ip_prefix":"0","from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"DENY","action_direction":null,"index":3,"network_protocol":"ipv4","to_interface":"any","to_transport":"tcp","to_start_port":443,"to_end_port":443,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":"0","comment":null,"from_interface":"any","from_ip":"192.168.0.1","from_ip_prefix":"32","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"DENY","action_direction":"OUT","index":4,"network_protocol":"ipv4","to_interface":"any","to_transport":"udp","to_start_port":443,"to_end_port":443,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":"0","comment":null,"from_interface":"any","from_ip":"192.168.0.7","from_ip_prefix":"32","from_transport":"any","from_start_port":8080,"from_end_port":8081,"from_service":null},{"action":"ALLOW","action_direction":null,"index":5,"network_protocol":"ipv4","to_interface":"any","to_transport":"tcp","to_start_port":22,"to_end_port":22,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":"0","comment":null,"from_interface":"any","from_ip":"192.168.0.0","from_ip_prefix":"24","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":null,"index":6,"network_protocol":"ipv4","to_interface":"any","to_transport":"udp","to_start_port":22,"to_end_port":22,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":"0","comment":null,"from_interface":"en0","from_ip":"192.168.0.0","from_ip_prefix":"24","from_transport":"any","from_start_port":8080,"from_end_port":8081,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":7,"network_protocol":"ipv6","to_interface":"any","to_transport":"tcp","to_start_port":22,"to_end_port":22,"to_service":null,"to_ip":"::","to_ip_prefix":"0","comment":null,"from_interface":"en1","from_ip":"2405:204:7449:49fc:f09a:6f4a:bc93:1955","from_ip_prefix":"64","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":8,"network_protocol":"ipv4","to_interface":"any","to_transport":"any","to_start_port":80,"to_end_port":80,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":"0","comment":null,"from_ip":"0.0.0.0","from_ip_prefix":"0","from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":9,"network_protocol":"ipv6","to_interface":"any","to_transport":"any","to_start_port":8080,"to_end_port":8080,"to_service":null,"to_ip":"::","to_ip_prefix":"0","comment":null,"from_ip":"::","from_ip_prefix":"0","from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":10,"network_protocol":"ipv4","to_interface":"any","to_transport":null,"to_service":"Apache Full","to_start_port":null,"to_end_port":null,"to_ip":"0.0.0.0","to_ip_prefix":"0","comment":null,"from_ip":"0.0.0.0","from_ip_prefix":"0","from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":11,"network_protocol":"ipv6","to_interface":"any","to_transport":null,"to_service":"Apache Full","to_start_port":null,"to_end_port":null,"to_ip":"::","to_ip_prefix":"0","comment":null,"from_ip":"::","from_ip_prefix":"0","from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"DENY","action_direction":"IN","index":12,"network_protocol":"ipv6","to_interface":"any","to_transport":null,"to_service":"OpenSSH","to_start_port":null,"to_end_port":null,"to_ip":"::","to_ip_prefix":"0","comment":null,"from_ip":"::","from_ip_prefix":"0","from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":null,"index":13,"network_protocol":"ipv4","to_interface":"enp34s0","to_ip":"10.10.10.10","to_ip_prefix":"32","to_transport":"any","to_start_port":8080,"to_end_port":8080,"to_service":null,"comment":null,"from_interface":"any","from_ip":"127.0.0.1","from_ip_prefix":"32","from_transport":"any","from_start_port":8000,"from_end_port":8000,"from_service":null},{"action":"ALLOW","action_direction":null,"index":14,"network_protocol":"ipv6","to_interface":"any","to_transport":"tcp","to_start_port":50200,"to_end_port":50300,"to_service":null,"to_ip":"::","to_ip_prefix":"0","comment":null,"from_ip":"::","from_ip_prefix":"0","from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":15,"network_protocol":"ipv6","to_ip":"::","to_ip_prefix":"0","to_interface":"any","to_transport":"any","to_start_port":0,"to_end_port":65535,"to_service":null,"comment":null,"from_interface":"any","from_ip":"2405:204:7449:49fc:f09a:6f4a:bc93:1955","from_ip_prefix":"128","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null}]} +{"status":"active","logging":"on","logging_level":"low","default":"deny (incoming), allow (outgoing), deny (routed)","new_profiles":"skip","rules":[{"action":"ALLOW","action_direction":"IN","index":1,"network_protocol":"ipv4","to_interface":"any","to_transport":"tcp","to_start_port":22,"to_end_port":22,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":0,"comment":null,"from_ip":"0.0.0.0","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"OUT","index":2,"network_protocol":"ipv6","to_interface":"any","to_transport":"tcp","to_start_port":22,"to_end_port":22,"to_service":null,"to_ip":"::","to_ip_prefix":0,"comment":null,"from_ip":"::","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"DENY","action_direction":null,"index":3,"network_protocol":"ipv4","to_interface":"any","to_transport":"tcp","to_start_port":443,"to_end_port":443,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":0,"comment":null,"from_interface":"any","from_ip":"192.168.0.1","from_ip_prefix":32,"from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"DENY","action_direction":"OUT","index":4,"network_protocol":"ipv4","to_interface":"any","to_transport":"udp","to_start_port":443,"to_end_port":443,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":0,"comment":null,"from_interface":"any","from_ip":"192.168.0.7","from_ip_prefix":32,"from_transport":"any","from_start_port":8080,"from_end_port":8081,"from_service":null},{"action":"ALLOW","action_direction":null,"index":5,"network_protocol":"ipv4","to_interface":"any","to_transport":"tcp","to_start_port":22,"to_end_port":22,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":0,"comment":null,"from_interface":"any","from_ip":"192.168.0.0","from_ip_prefix":24,"from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":null,"index":6,"network_protocol":"ipv4","to_interface":"any","to_transport":"udp","to_start_port":22,"to_end_port":22,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":0,"comment":null,"from_interface":"en0","from_ip":"192.168.0.0","from_ip_prefix":24,"from_transport":"any","from_start_port":8080,"from_end_port":8081,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":7,"network_protocol":"ipv6","to_interface":"any","to_transport":"tcp","to_start_port":22,"to_end_port":22,"to_service":null,"to_ip":"::","to_ip_prefix":0,"comment":null,"from_interface":"en1","from_ip":"2405:204:7449:49fc:f09a:6f4a:bc93:1955","from_ip_prefix":64,"from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":8,"network_protocol":"ipv4","to_interface":"any","to_transport":"any","to_start_port":80,"to_end_port":80,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":0,"comment":null,"from_ip":"0.0.0.0","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":9,"network_protocol":"ipv6","to_interface":"any","to_transport":"any","to_start_port":8080,"to_end_port":8080,"to_service":null,"to_ip":"::","to_ip_prefix":0,"comment":null,"from_ip":"::","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":10,"network_protocol":"ipv4","to_interface":"any","to_transport":null,"to_service":"Apache Full","to_start_port":null,"to_end_port":null,"to_ip":"0.0.0.0","to_ip_prefix":0,"comment":null,"from_ip":"0.0.0.0","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":11,"network_protocol":"ipv6","to_interface":"any","to_transport":null,"to_service":"Apache Full","to_start_port":null,"to_end_port":null,"to_ip":"::","to_ip_prefix":0,"comment":null,"from_ip":"::","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"DENY","action_direction":"IN","index":12,"network_protocol":"ipv6","to_interface":"any","to_transport":null,"to_service":"OpenSSH","to_start_port":null,"to_end_port":null,"to_ip":"::","to_ip_prefix":0,"comment":null,"from_ip":"::","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":null,"index":13,"network_protocol":"ipv4","to_interface":"enp34s0","to_ip":"10.10.10.10","to_ip_prefix":32,"to_transport":"any","to_start_port":8080,"to_end_port":8080,"to_service":null,"comment":null,"from_interface":"any","from_ip":"127.0.0.1","from_ip_prefix":32,"from_transport":"any","from_start_port":8000,"from_end_port":8000,"from_service":null},{"action":"ALLOW","action_direction":null,"index":14,"network_protocol":"ipv6","to_interface":"any","to_transport":"tcp","to_start_port":50200,"to_end_port":50300,"to_service":null,"to_ip":"::","to_ip_prefix":0,"comment":null,"from_ip":"::","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":15,"network_protocol":"ipv6","to_ip":"::","to_ip_prefix":0,"to_interface":"any","to_transport":"any","to_start_port":0,"to_end_port":65535,"to_service":null,"comment":null,"from_interface":"any","from_ip":"2405:204:7449:49fc:f09a:6f4a:bc93:1955","from_ip_prefix":128,"from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null}]} diff --git a/tests/fixtures/generic/ufw.json b/tests/fixtures/generic/ufw.json index 44f6edc5..0238ff7b 100644 --- a/tests/fixtures/generic/ufw.json +++ b/tests/fixtures/generic/ufw.json @@ -1 +1 @@ -{"status":"active","logging":"on","logging_level":"low","default":"deny (incoming), allow (outgoing), deny (routed)","new_profiles":"skip","rules":[{"action":"ALLOW","action_direction":"IN","index":null,"network_protocol":"ipv4","to_interface":"any","to_transport":"tcp","to_start_port":22,"to_end_port":22,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":"0","comment":null,"from_ip":"0.0.0.0","from_ip_prefix":"0","from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"OUT","index":null,"network_protocol":"ipv6","to_interface":"any","to_transport":"tcp","to_start_port":22,"to_end_port":22,"to_service":null,"to_ip":"::","to_ip_prefix":"0","comment":null,"from_ip":"::","from_ip_prefix":"0","from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"DENY","action_direction":null,"index":null,"network_protocol":"ipv4","to_interface":"any","to_transport":"tcp","to_start_port":443,"to_end_port":443,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":"0","comment":"nice comment","from_interface":"any","from_ip":"192.168.0.1","from_ip_prefix":"32","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"DENY","action_direction":"OUT","index":null,"network_protocol":"ipv4","to_interface":"any","to_transport":"udp","to_start_port":443,"to_end_port":443,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":"0","comment":null,"from_interface":"any","from_ip":"192.168.0.7","from_ip_prefix":"32","from_transport":"any","from_start_port":8080,"from_end_port":8081,"from_service":null},{"action":"ALLOW","action_direction":null,"index":null,"network_protocol":"ipv4","to_interface":"any","to_transport":"tcp","to_start_port":22,"to_end_port":22,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":"0","comment":null,"from_interface":"any","from_ip":"192.168.0.0","from_ip_prefix":"24","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":null,"index":null,"network_protocol":"ipv4","to_interface":"any","to_transport":"udp","to_start_port":22,"to_end_port":22,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":"0","comment":null,"from_interface":"en0","from_ip":"192.168.0.0","from_ip_prefix":"24","from_transport":"any","from_start_port":8080,"from_end_port":8081,"from_service":null},{"action":"ALLOW","action_direction":"FWD","index":null,"network_protocol":"ipv6","to_interface":"any","to_transport":"tcp","to_start_port":22,"to_end_port":22,"to_service":null,"to_ip":"::","to_ip_prefix":"0","comment":"commenting this rule","from_interface":"en1","from_ip":"2405:204:7449:49fc:f09a:6f4a:bc93:1955","from_ip_prefix":"64","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":null,"network_protocol":"ipv4","to_interface":"any","to_transport":"any","to_start_port":80,"to_end_port":80,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":"0","comment":null,"from_ip":"0.0.0.0","from_ip_prefix":"0","from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"REJECT","action_direction":"IN","index":null,"network_protocol":"ipv6","to_interface":"any","to_transport":"any","to_start_port":8080,"to_end_port":8080,"to_service":null,"to_ip":"::","to_ip_prefix":"0","comment":null,"from_ip":"::","from_ip_prefix":"0","from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":null,"network_protocol":"ipv4","to_interface":"any","to_transport":null,"to_service":"Apache Full","to_start_port":null,"to_end_port":null,"to_ip":"0.0.0.0","to_ip_prefix":"0","comment":"a comment","from_ip":"0.0.0.0","from_ip_prefix":"0","from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":null,"network_protocol":"ipv6","to_interface":"any","to_transport":null,"to_service":"Apache Full","to_start_port":null,"to_end_port":null,"to_ip":"::","to_ip_prefix":"0","comment":null,"from_ip":"::","from_ip_prefix":"0","from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"DENY","action_direction":"IN","index":null,"network_protocol":"ipv6","to_interface":"any","to_transport":null,"to_service":"OpenSSH","to_start_port":null,"to_end_port":null,"to_ip":"::","to_ip_prefix":"0","comment":null,"from_ip":"::","from_ip_prefix":"0","from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":null,"index":null,"network_protocol":"ipv4","to_interface":"enp34s0","to_ip":"10.10.10.10","to_ip_prefix":"32","to_transport":"any","to_start_port":8080,"to_end_port":8080,"to_service":null,"comment":null,"from_interface":"any","from_ip":"127.0.0.1","from_ip_prefix":"32","from_transport":"any","from_start_port":8000,"from_end_port":8000,"from_service":null},{"action":"DENY","action_direction":"FWD","index":null,"network_protocol":"ipv6","to_interface":"any","to_transport":"tcp","to_start_port":50200,"to_end_port":50300,"to_service":null,"to_ip":"::","to_ip_prefix":"0","comment":null,"from_ip":"::","from_ip_prefix":"0","from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"LIMIT","action_direction":null,"index":null,"network_protocol":"ipv6","to_ip":"::","to_ip_prefix":"0","to_interface":"any","to_transport":"any","to_start_port":0,"to_end_port":65535,"to_service":null,"comment":"this is a comment","from_interface":"any","from_ip":"2405:204:7449:49fc:f09a:6f4a:bc93:1955","from_ip_prefix":"128","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null}]} +{"status":"active","logging":"on","logging_level":"low","default":"deny (incoming), allow (outgoing), deny (routed)","new_profiles":"skip","rules":[{"action":"ALLOW","action_direction":"IN","index":null,"network_protocol":"ipv4","to_interface":"any","to_transport":"tcp","to_start_port":22,"to_end_port":22,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":0,"comment":null,"from_ip":"0.0.0.0","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"OUT","index":null,"network_protocol":"ipv6","to_interface":"any","to_transport":"tcp","to_start_port":22,"to_end_port":22,"to_service":null,"to_ip":"::","to_ip_prefix":0,"comment":null,"from_ip":"::","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"DENY","action_direction":null,"index":null,"network_protocol":"ipv4","to_interface":"any","to_transport":"tcp","to_start_port":443,"to_end_port":443,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":0,"comment":"nice comment","from_interface":"any","from_ip":"192.168.0.1","from_ip_prefix":32,"from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"DENY","action_direction":"OUT","index":null,"network_protocol":"ipv4","to_interface":"any","to_transport":"udp","to_start_port":443,"to_end_port":443,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":0,"comment":null,"from_interface":"any","from_ip":"192.168.0.7","from_ip_prefix":32,"from_transport":"any","from_start_port":8080,"from_end_port":8081,"from_service":null},{"action":"ALLOW","action_direction":null,"index":null,"network_protocol":"ipv4","to_interface":"any","to_transport":"tcp","to_start_port":22,"to_end_port":22,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":0,"comment":null,"from_interface":"any","from_ip":"192.168.0.0","from_ip_prefix":24,"from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":null,"index":null,"network_protocol":"ipv4","to_interface":"any","to_transport":"udp","to_start_port":22,"to_end_port":22,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":0,"comment":null,"from_interface":"en0","from_ip":"192.168.0.0","from_ip_prefix":24,"from_transport":"any","from_start_port":8080,"from_end_port":8081,"from_service":null},{"action":"ALLOW","action_direction":"FWD","index":null,"network_protocol":"ipv6","to_interface":"any","to_transport":"tcp","to_start_port":22,"to_end_port":22,"to_service":null,"to_ip":"::","to_ip_prefix":0,"comment":"commenting this rule","from_interface":"en1","from_ip":"2405:204:7449:49fc:f09a:6f4a:bc93:1955","from_ip_prefix":64,"from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":null,"network_protocol":"ipv4","to_interface":"any","to_transport":"any","to_start_port":80,"to_end_port":80,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":0,"comment":null,"from_ip":"0.0.0.0","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"REJECT","action_direction":"IN","index":null,"network_protocol":"ipv6","to_interface":"any","to_transport":"any","to_start_port":8080,"to_end_port":8080,"to_service":null,"to_ip":"::","to_ip_prefix":0,"comment":null,"from_ip":"::","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":null,"network_protocol":"ipv4","to_interface":"any","to_transport":null,"to_service":"Apache Full","to_start_port":null,"to_end_port":null,"to_ip":"0.0.0.0","to_ip_prefix":0,"comment":"a comment","from_ip":"0.0.0.0","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":null,"network_protocol":"ipv6","to_interface":"any","to_transport":null,"to_service":"Apache Full","to_start_port":null,"to_end_port":null,"to_ip":"::","to_ip_prefix":0,"comment":null,"from_ip":"::","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"DENY","action_direction":"IN","index":null,"network_protocol":"ipv6","to_interface":"any","to_transport":null,"to_service":"OpenSSH","to_start_port":null,"to_end_port":null,"to_ip":"::","to_ip_prefix":0,"comment":null,"from_ip":"::","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":null,"index":null,"network_protocol":"ipv4","to_interface":"enp34s0","to_ip":"10.10.10.10","to_ip_prefix":32,"to_transport":"any","to_start_port":8080,"to_end_port":8080,"to_service":null,"comment":null,"from_interface":"any","from_ip":"127.0.0.1","from_ip_prefix":32,"from_transport":"any","from_start_port":8000,"from_end_port":8000,"from_service":null},{"action":"DENY","action_direction":"FWD","index":null,"network_protocol":"ipv6","to_interface":"any","to_transport":"tcp","to_start_port":50200,"to_end_port":50300,"to_service":null,"to_ip":"::","to_ip_prefix":0,"comment":null,"from_ip":"::","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"LIMIT","action_direction":null,"index":null,"network_protocol":"ipv6","to_ip":"::","to_ip_prefix":0,"to_interface":"any","to_transport":"any","to_start_port":0,"to_end_port":65535,"to_service":null,"comment":"this is a comment","from_interface":"any","from_ip":"2405:204:7449:49fc:f09a:6f4a:bc93:1955","from_ip_prefix":128,"from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null}]} diff --git a/tests/fixtures/ubuntu-18.04/ufw-numbered.json b/tests/fixtures/ubuntu-18.04/ufw-numbered.json new file mode 100644 index 00000000..16383d39 --- /dev/null +++ b/tests/fixtures/ubuntu-18.04/ufw-numbered.json @@ -0,0 +1 @@ +{"status":"active","rules":[{"action":"ALLOW","action_direction":"IN","index":1,"network_protocol":"ipv4","to_interface":"any","to_transport":"any","to_start_port":22,"to_end_port":22,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":0,"comment":null,"from_ip":"0.0.0.0","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":2,"network_protocol":"ipv4","to_interface":"any","to_transport":"tcp","to_service":"80,443","to_start_port":null,"to_end_port":null,"to_ip":"0.0.0.0","to_ip_prefix":0,"comment":null,"from_ip":"0.0.0.0","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":3,"network_protocol":"ipv4","to_interface":"eth0","to_transport":"any","to_start_port":80,"to_end_port":80,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":0,"comment":"test","from_ip":"0.0.0.0","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":4,"network_protocol":"ipv6","to_interface":"any","to_transport":"any","to_start_port":22,"to_end_port":22,"to_service":null,"to_ip":"::","to_ip_prefix":0,"comment":null,"from_ip":"::","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":5,"network_protocol":"ipv6","to_interface":"any","to_transport":"tcp","to_service":"80,443","to_start_port":null,"to_end_port":null,"to_ip":"::","to_ip_prefix":0,"comment":null,"from_ip":"::","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":6,"network_protocol":"ipv6","to_interface":"eth0","to_transport":"any","to_start_port":80,"to_end_port":80,"to_service":null,"to_ip":"::","to_ip_prefix":0,"comment":"test","from_ip":"::","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null}]} diff --git a/tests/fixtures/ubuntu-18.04/ufw-verbose.json b/tests/fixtures/ubuntu-18.04/ufw-verbose.json new file mode 100644 index 00000000..83384f3d --- /dev/null +++ b/tests/fixtures/ubuntu-18.04/ufw-verbose.json @@ -0,0 +1 @@ +{"status":"active","logging":"on","logging_level":"low","default":"deny (incoming), allow (outgoing), disabled (routed)","new_profiles":"skip","rules":[{"action":"ALLOW","action_direction":"IN","index":null,"network_protocol":"ipv4","to_interface":"any","to_transport":"any","to_start_port":22,"to_end_port":22,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":0,"comment":null,"from_ip":"0.0.0.0","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":null,"network_protocol":"ipv4","to_interface":"any","to_transport":"tcp","to_service":"80,443","to_start_port":null,"to_end_port":null,"to_ip":"0.0.0.0","to_ip_prefix":0,"comment":null,"from_ip":"0.0.0.0","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":null,"network_protocol":"ipv4","to_interface":"eth0","to_transport":"any","to_start_port":80,"to_end_port":80,"to_service":null,"to_ip":"0.0.0.0","to_ip_prefix":0,"comment":"test","from_ip":"0.0.0.0","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":null,"network_protocol":"ipv6","to_interface":"any","to_transport":"any","to_start_port":22,"to_end_port":22,"to_service":null,"to_ip":"::","to_ip_prefix":0,"comment":null,"from_ip":"::","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":null,"network_protocol":"ipv6","to_interface":"any","to_transport":"tcp","to_service":"80,443","to_start_port":null,"to_end_port":null,"to_ip":"::","to_ip_prefix":0,"comment":null,"from_ip":"::","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null},{"action":"ALLOW","action_direction":"IN","index":null,"network_protocol":"ipv6","to_interface":"eth0","to_transport":"any","to_start_port":80,"to_end_port":80,"to_service":null,"to_ip":"::","to_ip_prefix":0,"comment":"test","from_ip":"::","from_ip_prefix":0,"from_interface":"any","from_transport":"any","from_start_port":0,"from_end_port":65535,"from_service":null}]} diff --git a/tests/test_ufw.py b/tests/test_ufw.py index 4b53eaeb..3dbe8370 100644 --- a/tests/test_ufw.py +++ b/tests/test_ufw.py @@ -10,6 +10,12 @@ class MyTests(unittest.TestCase): def setUp(self): # input + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/ufw-verbose.out'), 'r', encoding='utf-8') as f: + self.ubuntu_18_04_ufw_verbose = f.read() + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/ufw-numbered.out'), 'r', encoding='utf-8') as f: + self.ubuntu_18_04_ufw_numbered = f.read() + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/ufw.out'), 'r', encoding='utf-8') as f: self.generic_ufw = f.read() @@ -20,6 +26,12 @@ class MyTests(unittest.TestCase): self.generic_ufw_inactive = f.read() # output + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/ufw-verbose.json'), 'r', encoding='utf-8') as f: + self.ubuntu_18_04_ufw_verbose_json = json.loads(f.read()) + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/ufw-numbered.json'), 'r', encoding='utf-8') as f: + self.ubuntu_18_04_ufw_numbered_json = json.loads(f.read()) + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/ufw.json'), 'r', encoding='utf-8') as f: self.generic_ufw_json = json.loads(f.read()) @@ -35,19 +47,31 @@ class MyTests(unittest.TestCase): """ self.assertEqual(jc.parsers.ufw.parse('', quiet=True), {}) - def test_ufw_verbose(self): + def test_ufw_ubuntu_18_04_verbose(self): + """ + Test 'ufw status verbose' on Ubuntu 18.04 + """ + self.assertEqual(jc.parsers.ufw.parse(self.ubuntu_18_04_ufw_verbose, quiet=True), self.ubuntu_18_04_ufw_verbose_json) + + def test_ufw_ubuntu_18_04_numbered(self): + """ + Test 'ufw status numbered' on Ubuntu 18.04 + """ + self.assertEqual(jc.parsers.ufw.parse(self.ubuntu_18_04_ufw_numbered, quiet=True), self.ubuntu_18_04_ufw_numbered_json) + + def test_ufw_generic_verbose(self): """ Test 'ufw status verbose' sample """ self.assertEqual(jc.parsers.ufw.parse(self.generic_ufw, quiet=True), self.generic_ufw_json) - def test_ufw_verbose_numbered(self): + def test_ufw_generic_verbose_numbered(self): """ Test 'ufw status verbose numbered' sample """ self.assertEqual(jc.parsers.ufw.parse(self.generic_ufw_numbered, quiet=True), self.generic_ufw_numbered_json) - def test_ufw_inactive(self): + def test_ufw_generic_inactive(self): """ Test 'ufw status' when firewall is inactive """