|
51 | 51 |
|
52 | 52 | rules = ip6tables.retrieve_rules
|
53 | 53 |
|
54 |
| - describe.one do |
55 |
| - rules.each do |rule| |
56 |
| - describe rule do |
57 |
| - it { should match(/(?=.*-A INPUT)(?=.*-i lo)(?=.*-j ACCEPT)/) } |
58 |
| - end |
59 |
| - end |
60 |
| - end |
61 |
| - |
62 |
| - describe.one do |
63 |
| - rules.each do |rule| |
64 |
| - describe rule do |
65 |
| - it { should match(/(?=.*-A OUTPUT)(?=.*-o lo)(?=.*-j ACCEPT)/) } |
66 |
| - end |
67 |
| - end |
68 |
| - end |
69 |
| - |
70 |
| - describe.one do |
71 |
| - rules.each do |rule| |
72 |
| - describe rule do |
73 |
| - it { should match(/(?=.*-A INPUT)(?=.*-s ::1)(?=.*-j DROP)/) } |
74 |
| - end |
75 |
| - end |
| 54 | + describe "Check for IPv6 local loopback rules" do |
| 55 | + subject { rules.join("\n") } |
| 56 | + it { should match(/(?=.*-A INPUT)(?=.*-i lo)(?=.*-j ACCEPT)/) } |
| 57 | + it { should match(/(?=.*-A OUTPUT)(?=.*-o lo)(?=.*-j ACCEPT)/) } |
| 58 | + it { should match(/(?=.*-A INPUT)(?=.*-s ::1)(?=.*-j DROP)/) } |
76 | 59 | end
|
77 | 60 |
|
78 | 61 | only_if { ipv6.zero? }
|
|
89 | 72 | rules = ip6tables.retrieve_rules
|
90 | 73 |
|
91 | 74 | %w(tcp udp icmp).each do |proto|
|
92 |
| - describe.one do |
93 |
| - rules.each do |rule| |
94 |
| - describe rule do |
95 |
| - it { should match(/(?=.*-A OUTPUT)(?=.*-p #{proto})(?=.*-m state --state NEW,ESTABLISHED)(?=.*-j ACCEPT)/) } |
96 |
| - end |
97 |
| - end |
98 |
| - end |
99 |
| - |
100 |
| - describe.one do |
101 |
| - rules.each do |rule| |
102 |
| - describe rule do |
103 |
| - it { should match(/(?=.*-A INPUT)(?=.*-p #{proto})(?=.*-m state --state ESTABLISHED)(?=.*-j ACCEPT)/) } |
104 |
| - end |
105 |
| - end |
| 75 | + describe "Check for IPv6 rules on established and new outbound connections" do |
| 76 | + subject { rules.join("\n") } |
| 77 | + it { should match(/(?=.*-A OUTPUT)(?=.*-p #{proto})(?=.*-m state --state NEW,ESTABLISHED)(?=.*-j ACCEPT)/) } |
| 78 | + it { should match(/(?=.*-A INPUT)(?=.*-p #{proto})(?=.*-m state --state ESTABLISHED)(?=.*-j ACCEPT)/) } |
106 | 79 | end
|
107 | 80 | end
|
108 | 81 |
|
|
152 | 125 |
|
153 | 126 | rules = iptables.retrieve_rules
|
154 | 127 |
|
155 |
| - describe.one do |
156 |
| - rules.each do |rule| |
157 |
| - describe rule do |
158 |
| - it { should match /(?=.*-A INPUT)(?=.*-i lo)(?=.*-j ACCEPT)/ } |
159 |
| - end |
160 |
| - end |
161 |
| - end |
162 |
| - |
163 |
| - describe.one do |
164 |
| - rules.each do |rule| |
165 |
| - describe rule do |
166 |
| - it { should match /(?=.*-A OUTPUT)(?=.*-o lo)(?=.*-j ACCEPT)/ } |
167 |
| - end |
168 |
| - end |
169 |
| - end |
170 |
| - |
171 |
| - describe.one do |
172 |
| - rules.each do |rule| |
173 |
| - describe rule do |
174 |
| - it { should match %r{(?=.*-A INPUT)(?=.*-s 127\.0\.0\.0/8)(?=.*-j DROP)} } |
175 |
| - end |
176 |
| - end |
| 128 | + describe "Check for local loopback rules" do |
| 129 | + subject { rules.join("\n") } |
| 130 | + it { should match /(?=.*-A INPUT)(?=.*-i lo)(?=.*-j ACCEPT)/ } |
| 131 | + it { should match /(?=.*-A OUTPUT)(?=.*-o lo)(?=.*-j ACCEPT)/ } |
| 132 | + it { should match %r{(?=.*-A INPUT)(?=.*-s 127\.0\.0\.0/8)(?=.*-j DROP)} } |
177 | 133 | end
|
178 | 134 | end
|
179 | 135 |
|
|
188 | 144 | rules = iptables.retrieve_rules
|
189 | 145 |
|
190 | 146 | %w(tcp udp icmp).each do |proto|
|
191 |
| - describe.one do |
192 |
| - rules.each do |rule| |
193 |
| - describe rule do |
194 |
| - it { should match /(?=.*-A OUTPUT)(?=.*-p #{proto})(?=.*-m state --state NEW,ESTABLISHED)(?=.*-j ACCEPT)/ } |
195 |
| - end |
196 |
| - end |
197 |
| - end |
198 |
| - |
199 |
| - describe.one do |
200 |
| - rules.each do |rule| |
201 |
| - describe rule do |
202 |
| - it { should match /(?=.*-A INPUT)(?=.*-p #{proto})(?=.*-m state --state ESTABLISHED)(?=.*-j ACCEPT)/ } |
203 |
| - end |
204 |
| - end |
| 147 | + describe "Check for rules on established and new outbound connections" do |
| 148 | + subject { rules.join("\n") } |
| 149 | + it { should match /(?=.*-A OUTPUT)(?=.*-p #{proto})(?=.*-m state --state NEW,ESTABLISHED)(?=.*-j ACCEPT)/ } |
| 150 | + it { should match /(?=.*-A INPUT)(?=.*-p #{proto})(?=.*-m state --state ESTABLISHED)(?=.*-j ACCEPT)/ } |
205 | 151 | end
|
206 | 152 | end
|
207 | 153 | end
|
|
0 commit comments