ript 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. data/.gitignore +6 -0
  2. data/.rbenv-version +1 -0
  3. data/AUTHORS.md +16 -0
  4. data/CHANGELOG.md +93 -0
  5. data/Gemfile +4 -0
  6. data/Gemfile.lock +62 -0
  7. data/LICENCE +19 -0
  8. data/README.md +564 -0
  9. data/Rakefile +136 -0
  10. data/bin/rbenv-sudo +18 -0
  11. data/bin/ript +207 -0
  12. data/dist/init.d +48 -0
  13. data/examples/accept-multiple-from-and-to.rb +16 -0
  14. data/examples/accept-with-a-list-of-ports.rb +13 -0
  15. data/examples/accept-with-specific-port-and-interface.rb +14 -0
  16. data/examples/accept-without-specific-from.rb +11 -0
  17. data/examples/accept.rb +12 -0
  18. data/examples/basic.rb +4 -0
  19. data/examples/dash-in-partition-name.rb +2 -0
  20. data/examples/drop.rb +11 -0
  21. data/examples/duplicate-partition-names/foobar1.rb +2 -0
  22. data/examples/duplicate-partition-names/foobar2.rb +2 -0
  23. data/examples/errors-undefined-method-with-no-match.rb +12 -0
  24. data/examples/errors-undefined-method.rb +12 -0
  25. data/examples/forward-dnat-with-different-destination-port.rb +16 -0
  26. data/examples/forward-dnat-with-explicit-from-and-port-mappings.rb +11 -0
  27. data/examples/forward-dnat-with-explicit-from-and-ports.rb +11 -0
  28. data/examples/forward-dnat-with-explicit-from.rb +11 -0
  29. data/examples/forward-dnat-with-explicit-protocols.rb +15 -0
  30. data/examples/forward-dnat-with-multiple-froms.rb +13 -0
  31. data/examples/forward-dnat-with-multiple-ports.rb +10 -0
  32. data/examples/forward-dnat-with-multiple-sources.rb +15 -0
  33. data/examples/forward-dnat.rb +16 -0
  34. data/examples/forward-snat-with-explicit-from.rb +16 -0
  35. data/examples/forward-snat-with-multiple-sources.rb +13 -0
  36. data/examples/forward-snat.rb +9 -0
  37. data/examples/log-and-accept.rb +12 -0
  38. data/examples/log-and-drop.rb +11 -0
  39. data/examples/log-dnat.rb +10 -0
  40. data/examples/log-snat.rb +13 -0
  41. data/examples/log.rb +11 -0
  42. data/examples/missing-address-definition-in-destination.rb +15 -0
  43. data/examples/missing-address-definition-in-from.rb +15 -0
  44. data/examples/multiple-partitions-in-this-file.rb +14 -0
  45. data/examples/multiple-partitions/bar.rb +11 -0
  46. data/examples/multiple-partitions/foo.rb +17 -0
  47. data/examples/partition-name-exactly-20-characters.rb +2 -0
  48. data/examples/partition-name-longer-than-20-characters.rb +2 -0
  49. data/examples/postclean.rb +10 -0
  50. data/examples/preclean.rb +10 -0
  51. data/examples/raw-with-chain-deletion.rb +9 -0
  52. data/examples/raw-with-flush.rb +9 -0
  53. data/examples/raw.rb +50 -0
  54. data/examples/reject.rb +11 -0
  55. data/examples/space-in-partition-name.rb +2 -0
  56. data/features/cli.feature +115 -0
  57. data/features/dsl/errors.feature +107 -0
  58. data/features/dsl/filter.feature +187 -0
  59. data/features/dsl/logging.feature +114 -0
  60. data/features/dsl/nat.feature +271 -0
  61. data/features/dsl/raw.feature +28 -0
  62. data/features/setup.feature +58 -0
  63. data/features/step_definitions/cli_steps.rb +15 -0
  64. data/features/step_definitions/example_steps.rb +44 -0
  65. data/features/support/env.rb +25 -0
  66. data/lib/ript/bootstrap.rb +20 -0
  67. data/lib/ript/dsl.rb +14 -0
  68. data/lib/ript/dsl/primitives.rb +7 -0
  69. data/lib/ript/dsl/primitives/common.rb +78 -0
  70. data/lib/ript/dsl/primitives/filter.rb +145 -0
  71. data/lib/ript/dsl/primitives/nat.rb +206 -0
  72. data/lib/ript/dsl/primitives/raw.rb +45 -0
  73. data/lib/ript/exceptions.rb +2 -0
  74. data/lib/ript/partition.rb +162 -0
  75. data/lib/ript/patches.rb +10 -0
  76. data/lib/ript/rule.rb +70 -0
  77. data/lib/ript/version.rb +3 -0
  78. data/ript.gemspec +33 -0
  79. metadata +232 -0
@@ -0,0 +1,9 @@
1
+ partition "boilerplate" do
2
+ raw <<-RAW
3
+ # Flush everything
4
+ iptables -t filter -F
5
+ iptables -t nat -F
6
+ iptables -t mangle -F
7
+ RAW
8
+ end
9
+
@@ -0,0 +1,50 @@
1
+ partition "setup" do
2
+ raw <<-RAW
3
+ ####################
4
+ # policy #
5
+ ####################
6
+ iptables --policy INPUT DROP
7
+ iptables --policy OUTPUT DROP
8
+ iptables --policy FORWARD DROP
9
+ iptables --table mangle --policy PREROUTING ACCEPT
10
+ iptables --table mangle --policy OUTPUT ACCEPT
11
+
12
+ ####################
13
+ # before #
14
+ ####################
15
+ # Clean all traffic by sending it through a "before" chain.
16
+ iptables --new-chain before-a
17
+
18
+ iptables --insert INPUT 1 --jump before-a
19
+ iptables --insert OUTPUT 1 --jump before-a
20
+ iptables --insert FORWARD 1 --jump before-a
21
+
22
+ # ICMP cleaning
23
+ iptables --append before-a --protocol ICMP --icmp-type echo-reply --jump ACCEPT
24
+ iptables --append before-a --protocol ICMP --icmp-type destination-unreachable --jump ACCEPT
25
+ iptables --append before-a --protocol ICMP --icmp-type source-quench --jump ACCEPT
26
+ iptables --append before-a --protocol ICMP --icmp-type echo-request --jump ACCEPT
27
+ iptables --append before-a --protocol ICMP --icmp-type time-exceeded --jump ACCEPT
28
+ iptables --append before-a --protocol ICMP --icmp-type parameter-problem --jump ACCEPT
29
+ iptables --append before-a --protocol ICMP --jump LOG --log-prefix "INVALID_ICMP " --log-level debug
30
+ iptables --append before-a --protocol ICMP --jump DROP
31
+
32
+ # State cleaning
33
+ iptables --append before-a --match state --state INVALID --jump LOG --log-prefix "INVALID_STATE " --log-level debug
34
+ iptables --append before-a --match state --state INVALID --jump DROP
35
+ iptables --append before-a --protocol TCP --match state --state ESTABLISHED,RELATED --jump ACCEPT
36
+ iptables --append before-a --protocol UDP --match state --state ESTABLISHED,RELATED --jump ACCEPT
37
+
38
+ # Allow loopback
39
+ iptables --insert before-a --protocol ALL --in-interface lo --jump ACCEPT
40
+ iptables --insert before-a --protocol ALL --out-interface lo --jump ACCEPT
41
+
42
+ ####################
43
+ # after #
44
+ ####################
45
+ # Clean all traffic by sending it through an "after" chain.
46
+ iptables --new-chain after-a
47
+ iptables --append after-a --jump LOG --log-prefix "END_DROP " --log-level debug
48
+ RAW
49
+ end
50
+
@@ -0,0 +1,11 @@
1
+ partition "bar" do
2
+ label "www.bar.com", :address => "172.23.0.95"
3
+ label "barprod-web-01", :address => "192.168.19.2"
4
+ label "localhost", :address => "127.0.0.1"
5
+
6
+ reject "localhost on www.bar.com" do
7
+ from "localhost"
8
+ to "www.bar.com"
9
+ end
10
+ end
11
+
@@ -0,0 +1,2 @@
1
+ partition "space in my name" do
2
+ end
@@ -0,0 +1,115 @@
1
+ Feature: Ript cli utility
2
+
3
+ @sudo @timeout-10
4
+ Scenario: Check rules to apply
5
+ Given I have no iptables rules loaded
6
+ When I run `ript rules diff examples/basic.rb`
7
+ Then the output should match:
8
+ """
9
+ iptables --table nat --new-chain basic-d\w+
10
+ iptables --table nat --new-chain basic-s\w+
11
+ iptables --table filter --new-chain basic-a\w+
12
+ """
13
+ Then the created chain name in all tables should match
14
+
15
+ @sudo @timeout-10
16
+ Scenario: Apply rules
17
+ Given I have no iptables rules loaded
18
+ When I run `ript rules diff examples/basic.rb`
19
+ Then the output from "ript rules diff examples/basic.rb" should match:
20
+ """
21
+ iptables --table nat --new-chain basic-d\w+
22
+ iptables --table nat --new-chain basic-s\w+
23
+ iptables --table filter --new-chain basic-a\w+
24
+ """
25
+ When I run `ript rules apply examples/basic.rb`
26
+ Then the output from "ript rules diff examples/basic.rb" should match:
27
+ """
28
+ iptables --table nat --new-chain basic-d\w+
29
+ iptables --table nat --new-chain basic-s\w+
30
+ iptables --table filter --new-chain basic-a\w+
31
+ """
32
+ When I run `ript rules diff examples/basic.rb `
33
+ Then the output from "ript rules diff examples/basic.rb " should contain exactly:
34
+ """
35
+ """
36
+ Then the created chain name in all tables should match
37
+
38
+ @sudo @timeout-10
39
+ Scenario: Clean rules
40
+ Given I have no iptables rules loaded
41
+ When I run `ript rules apply examples/preclean.rb`
42
+ Then the output from "ript rules apply examples/preclean.rb" should match:
43
+ """
44
+ iptables --table filter --new-chain partition-a
45
+ iptables --table filter --insert INPUT 1 --jump partition-a
46
+ iptables --table filter --insert OUTPUT 1 --jump partition-a
47
+ iptables --table filter --insert FORWARD 1 --jump partition-a
48
+ iptables --table nat --new-chain partition-d
49
+ iptables --table nat --insert PREROUTING 1 --jump partition-d
50
+ iptables --table nat --new-chain partition-s
51
+ iptables --table nat --insert POSTROUTING 1 --jump partition-s
52
+
53
+
54
+ # supercow-\w+
55
+ iptables --table nat --new-chain supercow-d\w+
56
+ iptables --table nat --new-chain supercow-s\w+
57
+ iptables --table filter --new-chain supercow-a\w+
58
+ iptables --table filter --append supercow-a\w+ --protocol TCP --destination 172.29.2.2 --source 172.27.1.1 --jump ACCEPT
59
+ iptables --table filter --insert partition-a --destination 172.29.2.2 --jump supercow-a\w+
60
+ """
61
+ When I run `ript rules apply examples/postclean.rb`
62
+ Then the output from "ript rules apply examples/postclean.rb" should match:
63
+ """
64
+ # supercow-\w+
65
+ iptables --table nat --new-chain supercow-d\w+
66
+ iptables --table nat --new-chain supercow-s\w+
67
+ iptables --table filter --new-chain supercow-a\w+
68
+ iptables --table filter --append supercow-a\w+ --protocol TCP --destination 172.29.2.3 --source 172.27.1.2 --jump ACCEPT
69
+ iptables --table filter --insert partition-a --destination 172.29.2.3 --jump supercow-a\w+
70
+ """
71
+ When I run `ript rules diff examples/postclean.rb`
72
+ Then the output from "ript rules diff examples/postclean.rb" should contain exactly:
73
+ """
74
+ """
75
+ When I run `ript clean apply examples/postclean.rb `
76
+ Then the output from "ript clean apply examples/postclean.rb " should match:
77
+ """
78
+ iptables --table filter --delete partition-a --destination 172.29.2.2/32 --jump supercow-a\w+
79
+ iptables --table filter --flush supercow-a\w+
80
+ iptables --table filter --delete-chain supercow-a\w+
81
+ iptables --table nat --flush supercow-d\w+
82
+ iptables --table nat --delete-chain supercow-d\w+
83
+ iptables --table nat --flush supercow-s\w+
84
+ iptables --table nat --delete-chain supercow-s\w+
85
+ """
86
+ When I run `ript clean diff examples/postclean.rb`
87
+ Then the output from "ript clean diff examples/postclean.rb" should contain exactly:
88
+ """
89
+ """
90
+
91
+ @sudo @timeout-10
92
+ Scenario: raw rules should only apply once
93
+ Given I have no iptables rules loaded
94
+ When I run `ript rules apply examples/raw.rb`
95
+ Then the output from "ript rules apply examples/raw.rb" should match:
96
+ """
97
+ iptables --new-chain before-a
98
+ """
99
+ When I run `ript rules diff examples/raw.rb`
100
+ Then the output from "ript rules diff examples/raw.rb" should contain exactly:
101
+ """
102
+ """
103
+
104
+ @sudo @timeout-10
105
+ Scenario: Rule saving works
106
+ Given I have no iptables rules loaded
107
+ When I run `ript rules save`
108
+ Then the output from "ript rules save" should match:
109
+ """
110
+ \*filter
111
+ :INPUT ACCEPT \[\d+:\d+\]
112
+ :FORWARD ACCEPT \[\d+:\d+\]
113
+ :OUTPUT ACCEPT \[\d+:\d+\]
114
+ COMMIT
115
+ """
@@ -0,0 +1,107 @@
1
+ Feature: Error handling
2
+ To ensure that rules apply cleanly
3
+ Ript should validate user input
4
+ And fail gracefully
5
+
6
+ @errors @name
7
+ Scenario: Name errors - undefined method
8
+ # should verify no spaces or dashes
9
+ When I run `ript rules generate examples/errors-undefined-method.rb`
10
+ Then the output should match:
11
+ """
12
+ You tried using the '.+' method on line \d+ in .+/errors-undefined-method.rb
13
+ This method doesn't exist in the DSL. Did you mean:
14
+
15
+ - ports
16
+
17
+ Aborting.
18
+ """
19
+ When I run `ript rules generate examples/errors-undefined-method-with-no-match.rb`
20
+ Then the output should match:
21
+ """
22
+ You tried using the '.+' method on line \d+ in .+/errors-undefined-method-with-no-match.rb
23
+ This method doesn't exist in the DSL. There aren't any other methods with similar names. :-\(
24
+ Aborting.
25
+ """
26
+
27
+ @errors @parse @duplicate
28
+ Scenario: Parse errors - duplicate partition name
29
+ # should verify no spaces or dashes
30
+ When I run `ript rules generate examples/duplicate-partition-names/`
31
+ Then the output should match:
32
+ """
33
+ Error: Partition name '\w+' is already defined!
34
+ """
35
+
36
+ @errors @parse
37
+ Scenario: Parse errors - bad characters in partition name
38
+ # should verify no spaces or dashes
39
+ When I run `ript rules generate examples/space-in-partition-name.rb`
40
+ Then the output should match:
41
+ """
42
+ Error: Partition name '.+' can't contain whitespace.
43
+ """
44
+ When I run `ript rules generate examples/dash-in-partition-name.rb`
45
+ Then the output should match:
46
+ """
47
+ Error: Partition name '.+' can't contain dashes
48
+ """
49
+
50
+ @errors @parse
51
+ Scenario: Parse errors - partition name longer than characters
52
+ When I run `ript rules generate examples/partition-name-longer-than-20-characters.rb`
53
+ Then the output should match:
54
+ """
55
+ Error: Partition name '.+' cannot be longer than 20 characters.
56
+ """
57
+ When I run `ript rules generate examples/partition-name-exactly-20-characters.rb`
58
+ Then the output should match:
59
+ """
60
+ name_exactly_20_char
61
+ """
62
+
63
+
64
+ @errors @parse
65
+ Scenario: Parse errors - spaces and dashes
66
+ When I run `ript rules generate examples/space-in-partition-name.rb`
67
+ Then the output should contain:
68
+ """
69
+ Partition name 'space in my name' can't contain whitespace
70
+ """
71
+ When I run `ript rules generate examples/dash-in-partition-name.rb`
72
+ Then the output should contain:
73
+ """
74
+ Partition name 'dash-in-my-name' can't contain dashes ('-')
75
+ """
76
+
77
+ @errors @parse
78
+ Scenario: Parse errors - missing address definition
79
+ When I run `ript rules generate examples/missing-address-definition-in-destination.rb`
80
+ Then the output should contain:
81
+ """
82
+ Address 'barprod-web-02' (a destination) isn't defined
83
+ """
84
+
85
+ @errors
86
+ Scenario: Parse errors - missing address definition
87
+ When I run `ript rules generate examples/missing-address-definition-in-from.rb`
88
+ Then the output should contain:
89
+ """
90
+ Address 'bad guy' (a from) isn't defined
91
+ """
92
+
93
+ @errors
94
+ Scenario: Load errors - missing rule file
95
+ When I run `ript rules generate examples/non-existent-lalalalala.rb`
96
+ Then the output should match:
97
+ """
98
+ The specified rule file or directory 'examples/non-existent-lalalalala.rb' does not exist
99
+ """
100
+
101
+ @errors @parse
102
+ Scenario: Multiple partition definitions in the same file
103
+ When I run `ript rules generate examples/multiple-partitions-in-this-file.rb`
104
+ Then the output should match:
105
+ """
106
+ Multiple partition definitions are not permitted in the same file.
107
+ """
@@ -0,0 +1,187 @@
1
+ Feature: Ript DSL
2
+
3
+ Scenario: Basic partition
4
+ When I run `ript rules generate examples/basic.rb`
5
+ Then the output should match:
6
+ """
7
+ iptables --table nat --new-chain basic-d\w+
8
+ iptables --table nat --new-chain basic-s\w+
9
+ iptables --table filter --new-chain basic-a\w+
10
+ """
11
+ Then the created chain name in all tables should match
12
+
13
+ @filter @drop
14
+ Scenario: Drop someone
15
+ When I run `ript rules generate examples/drop.rb`
16
+ Then the output should match:
17
+ """
18
+ iptables --table nat --new-chain bar-d\w+
19
+ iptables --table nat --new-chain bar-s\w+
20
+ iptables --table filter --new-chain bar-a\w+
21
+ """
22
+ Then the output should match:
23
+ """
24
+ iptables --table filter --insert partition-a --destination 172.23.0.95 --jump bar-a\w+
25
+ """
26
+ Then the output should match:
27
+ """
28
+ iptables --table filter --append bar-a\w+ --protocol TCP --destination 172.23.0.95 --source 127.0.0.1 --jump DROP
29
+ """
30
+ Then the created chain name in all tables should match
31
+
32
+ @filter @accept
33
+ Scenario: Accept someone
34
+ When I run `ript rules generate examples/accept.rb`
35
+ Then the output should match:
36
+ """
37
+ iptables --table nat --new-chain keepalived-d\w+
38
+ iptables --table nat --new-chain keepalived-s\w+
39
+ iptables --table filter --new-chain keepalived-a\w+
40
+ """
41
+ Then the output should match:
42
+ """
43
+ iptables --table filter --insert partition-a --destination 224.0.0.0/8 --jump keepalived-a\w+
44
+ """
45
+ Then the output should match:
46
+ """
47
+ iptables --table filter --append keepalived-a\w+ --protocol vrrp --destination 224.0.0.0/8 --source 172.16.0.216 --jump ACCEPT
48
+ iptables --table filter --append keepalived-a\w+ --protocol vrrp --destination 224.0.0.0/8 --source 172.16.0.217 --jump ACCEPT
49
+ """
50
+ Then the created chain name in all tables should match
51
+
52
+ @filter @accept
53
+ Scenario: Accept someone with a specific port and interface
54
+ When I run `ript rules generate examples/accept-with-specific-port-and-interface.rb`
55
+ Then the output should match:
56
+ """
57
+ iptables --table nat --new-chain keepalived-d\w+
58
+ iptables --table nat --new-chain keepalived-s\w+
59
+ iptables --table filter --new-chain keepalived-a\w+
60
+ """
61
+ Then the output should match:
62
+ """
63
+ iptables --table filter --insert partition-a --destination 192.168.0.76 --jump keepalived-a\w+
64
+ """
65
+ Then the output should match:
66
+ """
67
+ iptables --table filter --append keepalived-a\w+ --in-interface vlan\+ --protocol tcp --dport 22 --destination 192.168.0.76 --source 192.168.0.76 --jump ACCEPT
68
+ """
69
+ Then the created chain name in all tables should match
70
+
71
+ @filter @reject
72
+ Scenario: Reject someone
73
+ When I run `ript rules generate examples/reject.rb`
74
+ Then the output should match:
75
+ """
76
+ iptables --table nat --new-chain bar-d\w+
77
+ iptables --table nat --new-chain bar-s\w+
78
+ iptables --table filter --new-chain bar-a\w+
79
+ """
80
+ Then the output should match:
81
+ """
82
+ iptables --table filter --insert partition-a --destination 172.23.0.95 --jump bar-a\w+
83
+ """
84
+ Then the output should match:
85
+ """
86
+ iptables --table filter --append bar-a\w+ --protocol TCP --destination 172.23.0.95 --source 127.0.0.1 --jump REJECT
87
+ """
88
+ Then the created chain name in all tables should match
89
+
90
+ @filter @log
91
+ Scenario: Log someone
92
+ When I run `ript rules generate examples/log.rb`
93
+ Then the output should match:
94
+ """
95
+ iptables --table nat --new-chain bar-d\w+
96
+ iptables --table nat --new-chain bar-s\w+
97
+ iptables --table filter --new-chain bar-a\w+
98
+ """
99
+ Then the output should match:
100
+ """
101
+ iptables --table filter --insert partition-a --destination 172.23.0.95 --jump bar-a\w+
102
+ """
103
+ Then the output should match:
104
+ """
105
+ iptables --table filter --append bar-a\w+ --protocol TCP --destination 172.23.0.95 --source 127.0.0.1 --jump LOG
106
+ """
107
+ Then the created chain name in all tables should match
108
+
109
+ @filter @accept @port-range
110
+ Scenario: Accept a list of ports
111
+ When I run `ript rules generate examples/accept-with-a-list-of-ports.rb`
112
+ Then the output should match:
113
+ """
114
+ iptables --table nat --new-chain keepalived-d\w+
115
+ iptables --table nat --new-chain keepalived-s\w+
116
+ iptables --table filter --new-chain keepalived-a\w+
117
+ """
118
+ Then the output should match:
119
+ """
120
+ iptables --table filter --insert partition-a --destination 224.0.0.0/8 --jump keepalived-a\w+
121
+ """
122
+ Then the output should match:
123
+ """
124
+ iptables --table filter --append keepalived-a\w+ --protocol tcp --dport 80 --destination 224.0.0.0/8 --source 172.16.0.216 --jump ACCEPT
125
+ iptables --table filter --append keepalived-a\w+ --protocol tcp --dport 8600:8900 --destination 224.0.0.0/8 --source 172.16.0.216 --jump ACCEPT
126
+ """
127
+ Then the created chain name in all tables should match
128
+
129
+ @filter @accept @multiple
130
+ Scenario: Accept multiple from and to
131
+ When I run `ript rules generate examples/accept-multiple-from-and-to.rb`
132
+ Then the output should match:
133
+ """
134
+ iptables --table nat --new-chain tootyfruity-d\w+
135
+ iptables --table nat --new-chain tootyfruity-s\w+
136
+ iptables --table filter --new-chain tootyfruity-a\w+
137
+ """
138
+ Then the output should match:
139
+ """
140
+ iptables --table filter --insert partition-a --destination 192.168.0.1 --jump tootyfruity-a\w+
141
+ iptables --table filter --insert partition-a --destination 192.168.0.2 --jump tootyfruity-a\w+
142
+ iptables --table filter --insert partition-a --destination 192.168.0.3 --jump tootyfruity-a\w+
143
+ iptables --table filter --insert partition-a --destination 192.168.0.4 --jump tootyfruity-a\w+
144
+ iptables --table filter --insert partition-a --destination 192.168.0.5 --jump tootyfruity-a\w+
145
+ iptables --table filter --insert partition-a --destination 192.168.0.6 --jump tootyfruity-a\w+
146
+ """
147
+ Then the output should match:
148
+ """
149
+ iptables --table filter --append tootyfruity-a\w+ --protocol tcp --dport 22 --destination 192.168.0.1 --source 192.168.0.1 --jump ACCEPT
150
+ iptables --table filter --append tootyfruity-a\w+ --protocol tcp --dport 22 --destination 192.168.0.2 --source 192.168.0.1 --jump ACCEPT
151
+ iptables --table filter --append tootyfruity-a\w+ --protocol tcp --dport 22 --destination 192.168.0.3 --source 192.168.0.1 --jump ACCEPT
152
+ iptables --table filter --append tootyfruity-a\w+ --protocol tcp --dport 22 --destination 192.168.0.4 --source 192.168.0.1 --jump ACCEPT
153
+ iptables --table filter --append tootyfruity-a\w+ --protocol tcp --dport 22 --destination 192.168.0.5 --source 192.168.0.1 --jump ACCEPT
154
+ iptables --table filter --append tootyfruity-a\w+ --protocol tcp --dport 22 --destination 192.168.0.6 --source 192.168.0.1 --jump ACCEPT
155
+ iptables --table filter --append tootyfruity-a\w+ --protocol tcp --dport 22 --destination 192.168.0.1 --source 192.168.0.2 --jump ACCEPT
156
+ iptables --table filter --append tootyfruity-a\w+ --protocol tcp --dport 22 --destination 192.168.0.2 --source 192.168.0.2 --jump ACCEPT
157
+ iptables --table filter --append tootyfruity-a\w+ --protocol tcp --dport 22 --destination 192.168.0.3 --source 192.168.0.2 --jump ACCEPT
158
+ iptables --table filter --append tootyfruity-a\w+ --protocol tcp --dport 22 --destination 192.168.0.4 --source 192.168.0.2 --jump ACCEPT
159
+ iptables --table filter --append tootyfruity-a\w+ --protocol tcp --dport 22 --destination 192.168.0.5 --source 192.168.0.2 --jump ACCEPT
160
+ iptables --table filter --append tootyfruity-a\w+ --protocol tcp --dport 22 --destination 192.168.0.6 --source 192.168.0.2 --jump ACCEPT
161
+ """
162
+ Then the created chain name in all tables should match
163
+
164
+ @filter @accept @regression
165
+ Scenario: Accept someone without a specific from
166
+ When I run `ript rules generate examples/accept-without-specific-from.rb`
167
+ Then the output should match:
168
+ """
169
+ iptables --table nat --new-chain joeblogsco-d\w+
170
+ iptables --table nat --new-chain joeblogsco-s\w+
171
+ iptables --table filter --new-chain joeblogsco-a\w+
172
+ """
173
+ Then the output should match:
174
+ """
175
+ iptables --table filter --append joeblogsco-a\w+ --protocol TCP --dport 80 --destination 172.22.111.99 --source 0.0.0.0/0 --jump ACCEPT
176
+ iptables --table filter --append joeblogsco-a\w+ --protocol TCP --dport 443 --destination 172.22.111.99 --source 0.0.0.0/0 --jump ACCEPT
177
+ """
178
+ Then the output should match:
179
+ """
180
+ iptables --table filter --insert partition-a --destination 172.22.111.99 --jump joeblogsco-a\w+
181
+ """
182
+ Then the created chain name in all tables should match
183
+
184
+ @filter @regression
185
+ Scenario: Always include protocol when specifying port
186
+ When I generate rules for packet filtering
187
+ Then I should see a protocol specified when a port is specified