1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-07-13 01:20:24 +02:00

add line-numbers tests

This commit is contained in:
Kelly Brazil
2019-11-17 11:49:36 -08:00
parent 47410d1a95
commit 4867655eb2
6 changed files with 172 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,128 @@
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
2 ACCEPT all -- anywhere anywhere
3 INPUT_direct all -- anywhere anywhere
4 INPUT_ZONES_SOURCE all -- anywhere anywhere
5 INPUT_ZONES all -- anywhere anywhere
6 DROP all -- anywhere anywhere ctstate INVALID
7 REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
8 ACCEPT all -- anywhere anywhere
9 ACCEPT all -- anywhere anywhere
10 ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
11 DROP all -- anywhere anywhere ctstate INVALID
12 DROP all -- 15.15.15.51 anywhere
13 ACCEPT tcp -- 15.15.15.0/24 anywhere tcp dpt:ssh ctstate NEW,ESTABLISHED
Chain FORWARD (policy DROP)
num target prot opt source destination
1 DOCKER-ISOLATION all -- anywhere anywhere
2 DOCKER all -- anywhere anywhere
3 ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
4 ACCEPT all -- anywhere anywhere
5 ACCEPT all -- anywhere anywhere
6 ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
7 ACCEPT all -- anywhere anywhere
8 FORWARD_direct all -- anywhere anywhere
9 FORWARD_IN_ZONES_SOURCE all -- anywhere anywhere
10 FORWARD_IN_ZONES all -- anywhere anywhere
11 FORWARD_OUT_ZONES_SOURCE all -- anywhere anywhere
12 FORWARD_OUT_ZONES all -- anywhere anywhere
13 DROP all -- anywhere anywhere ctstate INVALID
14 REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all -- anywhere anywhere
2 OUTPUT_direct all -- anywhere anywhere
3 ACCEPT all -- anywhere anywhere
4 ACCEPT all -- anywhere anywhere ctstate ESTABLISHED
5 ACCEPT tcp -- anywhere anywhere tcp spt:ssh ctstate ESTABLISHED
Chain DOCKER (1 references)
num target prot opt source destination
Chain DOCKER-ISOLATION (1 references)
num target prot opt source destination
1 RETURN all -- anywhere anywhere
Chain FORWARD_IN_ZONES (1 references)
num target prot opt source destination
1 FWDI_public all -- anywhere anywhere [goto]
2 FWDI_public all -- anywhere anywhere [goto]
Chain FORWARD_IN_ZONES_SOURCE (1 references)
num target prot opt source destination
Chain FORWARD_OUT_ZONES (1 references)
num target prot opt source destination
1 FWDO_public all -- anywhere anywhere [goto]
2 FWDO_public all -- anywhere anywhere [goto]
Chain FORWARD_OUT_ZONES_SOURCE (1 references)
num target prot opt source destination
Chain FORWARD_direct (1 references)
num target prot opt source destination
Chain FWDI_public (2 references)
num target prot opt source destination
1 FWDI_public_log all -- anywhere anywhere
2 FWDI_public_deny all -- anywhere anywhere
3 FWDI_public_allow all -- anywhere anywhere
4 ACCEPT icmp -- anywhere anywhere
Chain FWDI_public_allow (1 references)
num target prot opt source destination
Chain FWDI_public_deny (1 references)
num target prot opt source destination
Chain FWDI_public_log (1 references)
num target prot opt source destination
Chain FWDO_public (2 references)
num target prot opt source destination
1 FWDO_public_log all -- anywhere anywhere
2 FWDO_public_deny all -- anywhere anywhere
3 FWDO_public_allow all -- anywhere anywhere
Chain FWDO_public_allow (1 references)
num target prot opt source destination
Chain FWDO_public_deny (1 references)
num target prot opt source destination
Chain FWDO_public_log (1 references)
num target prot opt source destination
Chain INPUT_ZONES (1 references)
num target prot opt source destination
1 IN_public all -- anywhere anywhere [goto]
2 IN_public all -- anywhere anywhere [goto]
Chain INPUT_ZONES_SOURCE (1 references)
num target prot opt source destination
Chain INPUT_direct (1 references)
num target prot opt source destination
Chain IN_public (2 references)
num target prot opt source destination
1 IN_public_log all -- anywhere anywhere
2 IN_public_deny all -- anywhere anywhere
3 IN_public_allow all -- anywhere anywhere
4 ACCEPT icmp -- anywhere anywhere
Chain IN_public_allow (1 references)
num target prot opt source destination
1 ACCEPT tcp -- anywhere anywhere tcp dpt:ssh ctstate NEW,UNTRACKED
Chain IN_public_deny (1 references)
num target prot opt source destination
Chain IN_public_log (1 references)
num target prot opt source destination
Chain OUTPUT_direct (1 references)
num target prot opt source destination

View File

@ -23,6 +23,7 @@ sudo iptables -A INPUT -i lo -s 15.15.15.51 -j DROP
sudo iptables -A INPUT -p tcp -s 15.15.15.0/24 --dport 22 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
sudo iptables -A OUTPUT -p tcp --sport 22 -m conntrack --ctstate ESTABLISHED -j ACCEPT
sudo iptables -L -t filter > iptables-filter.out
sudo iptables --line-numbers -L -t filter > iptables-filter-line-numbers.out
sudo iptables -L -t nat > iptables-nat.out
sudo iptables -L -t mangle > iptables-mangle.out
sudo iptables -L -t raw > iptables-raw.out

View File

@ -0,0 +1 @@
[{"chain": "INPUT", "rules": [{"num": 1, "target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"num": 2, "target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere"}, {"num": 3, "target": "ACCEPT", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "ctstate RELATED,ESTABLISHED"}, {"num": 4, "target": "DROP", "prot": "all", "opt": null, "source": "anywhere", "destination": "anywhere", "options": "ctstate INVALID"}, {"num": 5, "target": "DROP", "prot": "all", "opt": null, "source": "15.15.15.51", "destination": "anywhere"}, {"num": 6, "target": "ACCEPT", "prot": "tcp", "opt": null, "source": "15.15.15.0/24", "destination": "anywhere", "options": "tcp dpt:ssh ctstate NEW,ESTABLISHED"}]}, {"chain": "FORWARD", "rules": []}]

View File

@ -0,0 +1,17 @@
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all -- anywhere anywhere
2 ACCEPT all -- anywhere anywhere
3 ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
4 DROP all -- anywhere anywhere ctstate INVALID
5 DROP all -- 15.15.15.51 anywhere
6 ACCEPT tcp -- 15.15.15.0/24 anywhere tcp dpt:ssh ctstate NEW,ESTABLISHED
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all -- anywhere anywhere
2 ACCEPT all -- anywhere anywhere ctstate ESTABLISHED
3 ACCEPT tcp -- anywhere anywhere tcp spt:ssh ctstate ESTABLISHED

View File

@ -16,6 +16,12 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/iptables-filter.out'), 'r') as f:
self.ubuntu_18_4_iptables_filter = f.read()
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/iptables-filter-line-numbers.out'), 'r') as f:
self.centos_7_7_iptables_filter_line_numbers = f.read()
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/iptables-filter-line-numbers.out'), 'r') as f:
self.ubuntu_18_4_iptables_filter_line_numbers = f.read()
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/iptables-filter-nv.out'), 'r') as f:
self.centos_7_7_iptables_filter_nv = f.read()
@ -47,6 +53,12 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/iptables-filter.json'), 'r') as f:
self.ubuntu_18_4_iptables_filter_json = json.loads(f.read())
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/iptables-filter-line-numbers.json'), 'r') as f:
self.centos_7_7_iptables_filter_line_numbers_json = json.loads(f.read())
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/iptables-filter-line-numbers.json'), 'r') as f:
self.ubuntu_18_4_iptables_filter_line_numbers_json = json.loads(f.read())
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/iptables-filter-nv.json'), 'r') as f:
self.centos_7_7_iptables_filter_nv_json = json.loads(f.read())
@ -83,6 +95,18 @@ class MyTests(unittest.TestCase):
"""
self.assertEqual(jc.parsers.iptables.parse(self.ubuntu_18_4_iptables_filter, quiet=True), self.ubuntu_18_4_iptables_filter_json)
def test_iptables_filter_line_numbers_centos_7_7(self):
"""
Test 'sudo iptables --line-numbers -L -t filter' on Centos 7.7
"""
self.assertEqual(jc.parsers.iptables.parse(self.centos_7_7_iptables_filter_line_numbers, quiet=True), self.centos_7_7_iptables_filter_line_numbers_json)
def test_iptables_filter_line_numbers_ubuntu_18_4(self):
"""
Test 'sudo iptables --line-numbers -L -t filter' on Ubuntu 18.4
"""
self.assertEqual(jc.parsers.iptables.parse(self.ubuntu_18_4_iptables_filter_line_numbers, quiet=True), self.ubuntu_18_4_iptables_filter_line_numbers_json)
def test_iptables_filter_nv_centos_7_7(self):
"""
Test 'sudo iptables -nvL -t filter' on Centos 7.7