ipscriptables 0.0.1
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.
- checksums.yaml +15 -0
- data/.gitignore +17 -0
- data/.rubocop.yml +15 -0
- data/.travis.yml +10 -0
- data/CHANGELOG.md +6 -0
- data/CONTRIBUTING.md +43 -0
- data/Gemfile +13 -0
- data/LICENSE +20 -0
- data/README.md +54 -0
- data/Rakefile +22 -0
- data/bin/ipscriptables +6 -0
- data/cookbook/.gitignore +2 -0
- data/cookbook/.kitchen.yml +28 -0
- data/cookbook/Berksfile +6 -0
- data/cookbook/README.md +53 -0
- data/cookbook/attributes/default.rb +3 -0
- data/cookbook/chefignore +96 -0
- data/cookbook/libraries/default.rb +35 -0
- data/cookbook/metadata.rb +9 -0
- data/cookbook/providers/rules.rb +21 -0
- data/cookbook/recipes/default.rb +10 -0
- data/cookbook/recipes/load.rb +8 -0
- data/cookbook/resources/rules.rb +17 -0
- data/cookbook/test/cookbooks/ipscriptables-test/#metadata.rb# +8 -0
- data/cookbook/test/cookbooks/ipscriptables-test/metadata.rb +11 -0
- data/cookbook/test/cookbooks/ipscriptables-test/recipes/default.rb +23 -0
- data/cookbook/test/cookbooks/ipscriptables-test/recipes/prepare.rb +5 -0
- data/cookbook/test/data/.gitignore +1 -0
- data/cookbook/test/integration/default/bats/default.bats +9 -0
- data/doc/iptables-switches.txt +342 -0
- data/ipscriptables.gemspec +38 -0
- data/lib/ipscriptables.rb +14 -0
- data/lib/ipscriptables/chain.rb +83 -0
- data/lib/ipscriptables/cli.rb +19 -0
- data/lib/ipscriptables/helpers.rb +39 -0
- data/lib/ipscriptables/pretty_print.rb +58 -0
- data/lib/ipscriptables/rule.rb +95 -0
- data/lib/ipscriptables/ruleset.rb +103 -0
- data/lib/ipscriptables/ruleset/class_methods.rb +67 -0
- data/lib/ipscriptables/runtime.rb +97 -0
- data/lib/ipscriptables/table.rb +77 -0
- data/lib/ipscriptables/version.rb +5 -0
- data/spec/fixtures/clyhq.txt +40 -0
- data/spec/fixtures/docker-plus.txt +31 -0
- data/spec/fixtures/drumknott.txt +67 -0
- data/spec/fixtures/falcor.txt +39 -0
- data/spec/fixtures/ghq.txt +102 -0
- data/spec/fixtures/ip6tables-empty.txt +7 -0
- data/spec/fixtures/only-docker-c.txt +23 -0
- data/spec/fixtures/only-docker.txt +23 -0
- data/spec/fixtures/only_docker.rb +22 -0
- data/spec/fixtures/runtime.rb +7 -0
- data/spec/fixtures/runtime2.rb +16 -0
- data/spec/ipscriptables/dsl_spec.rb +74 -0
- data/spec/ipscriptables/helpers_spec.rb +58 -0
- data/spec/ipscriptables/rule_spec.rb +41 -0
- data/spec/ipscriptables/ruleset/class_methods_spec.rb +52 -0
- data/spec/ipscriptables/ruleset_spec.rb +199 -0
- data/spec/ipscriptables/runtime_spec.rb +227 -0
- data/spec/ipscriptables/table_spec.rb +32 -0
- data/spec/ipscriptables/version_spec.rb +12 -0
- data/spec/spec_helper.rb +60 -0
- metadata +350 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
def whyrun_supported?
|
4
|
+
true
|
5
|
+
end
|
6
|
+
|
7
|
+
action :apply do
|
8
|
+
converge_by('Evaluating rules') do
|
9
|
+
runtime.dsl_eval(&new_resource.block)
|
10
|
+
end
|
11
|
+
new_resource.updated_by_last_action(true)
|
12
|
+
end
|
13
|
+
|
14
|
+
def runtime
|
15
|
+
node.run_state['ipscriptables_runtime'] ||=
|
16
|
+
begin
|
17
|
+
require 'ipscriptables'
|
18
|
+
Chef::Config.report_handlers << IPScriptables::ChefHandler.new
|
19
|
+
IPScriptables::Runtime.new(apply: !whyrun_mode?)
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# rubocop:disable TrivialAccessors
|
3
|
+
|
4
|
+
actions :apply
|
5
|
+
|
6
|
+
default_action :apply
|
7
|
+
|
8
|
+
attr_accessor :block
|
9
|
+
|
10
|
+
def rules(&block)
|
11
|
+
@block = block
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(*)
|
15
|
+
super
|
16
|
+
run_context.include_recipe 'ipscriptables::load'
|
17
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
name 'ipscriptables-test'
|
4
|
+
maintainer ''
|
5
|
+
maintainer_email ''
|
6
|
+
license ''
|
7
|
+
description 'Installs/Configures ipscriptables-test'
|
8
|
+
long_description 'Installs/Configures ipscriptables-test'
|
9
|
+
version '0.1.0'
|
10
|
+
|
11
|
+
depends 'ipscriptables'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# rubocop:disable LineLength
|
3
|
+
|
4
|
+
include_recipe 'ipscriptables-test::prepare'
|
5
|
+
|
6
|
+
ipscriptables do
|
7
|
+
iptables do
|
8
|
+
table :filter do
|
9
|
+
chain :INPUT do
|
10
|
+
rule :j => :FWR
|
11
|
+
end
|
12
|
+
|
13
|
+
chain :FWR do
|
14
|
+
rule m: 'state', state: 'RELATED,ESTABLISHED', j: 'ACCEPT'
|
15
|
+
rule i: ['lo', 'docker+'], j: 'ACCEPT'
|
16
|
+
rule '-p icmp -j ACCEPT'
|
17
|
+
rule '-p tcp -m tcp --dport', 22, '-j ACCEPT'
|
18
|
+
rule '-p tcp -m tcp --tcp-flags SYN,RST,ACK SYN -j REJECT --reject-with icmp-port-unreachable'
|
19
|
+
rule '-p udp -j REJECT --reject-with icmp-port-unreachable'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
@@ -0,0 +1,342 @@
|
|
1
|
+
List of options, targets and modules from man iptables 1.4.12 IPTABLES(8)
|
2
|
+
|
3
|
+
[!] -p, --protocol protocol
|
4
|
+
[!] -s, --source address[/mask][,...]
|
5
|
+
[!] -d, --destination address[/mask][,...]
|
6
|
+
-j, --jump target
|
7
|
+
-g, --goto chain
|
8
|
+
[!] -i, --in-interface name
|
9
|
+
[!] -o, --out-interface name
|
10
|
+
[!] -f, --fragment
|
11
|
+
addrtype
|
12
|
+
[!] --src-type type
|
13
|
+
[!] --dst-type type
|
14
|
+
--limit-iface-in
|
15
|
+
--limit-iface-out
|
16
|
+
ah
|
17
|
+
[!] --ahspi spi[:spi]
|
18
|
+
cluster
|
19
|
+
--cluster-total-nodes num
|
20
|
+
[!] --cluster-local-node num
|
21
|
+
[!] --cluster-local-nodemask mask
|
22
|
+
--cluster-hash-seed value
|
23
|
+
comment
|
24
|
+
--comment comment
|
25
|
+
connbytes
|
26
|
+
[!] --connbytes from[:to]
|
27
|
+
--connbytes-dir {original|reply|both}
|
28
|
+
--connbytes-mode {packets|bytes|avgpkt}
|
29
|
+
connlimit
|
30
|
+
--connlimit-upto n
|
31
|
+
--connlimit-above n
|
32
|
+
--connlimit-mask prefix_length
|
33
|
+
--connlimit-saddr
|
34
|
+
--connlimit-daddr
|
35
|
+
connmark
|
36
|
+
[!] --mark value[/mask]
|
37
|
+
conntrack
|
38
|
+
[!] --ctstate statelist
|
39
|
+
[!] --ctproto l4proto
|
40
|
+
[!] --ctorigsrc address[/mask]
|
41
|
+
[!] --ctorigdst address[/mask]
|
42
|
+
[!] --ctreplsrc address[/mask]
|
43
|
+
[!] --ctrepldst address[/mask]
|
44
|
+
[!] --ctorigsrcport port[:port]
|
45
|
+
[!] --ctorigdstport port[:port]
|
46
|
+
[!] --ctreplsrcport port[:port]
|
47
|
+
[!] --ctrepldstport port[:port]
|
48
|
+
[!] --ctstatus statelist
|
49
|
+
[!] --ctexpire time[:time]
|
50
|
+
--ctdir {ORIGINAL|REPLY}
|
51
|
+
cpu
|
52
|
+
[!] --cpu number
|
53
|
+
dccp
|
54
|
+
[!] --source-port,--sport port[:port]
|
55
|
+
[!] --destination-port,--dport port[:port]
|
56
|
+
[!] --dccp-types mask
|
57
|
+
[!] --dccp-option number
|
58
|
+
dscp
|
59
|
+
[!] --dscp value
|
60
|
+
[!] --dscp-class class
|
61
|
+
ecn
|
62
|
+
[!] --ecn-tcp-cwr
|
63
|
+
[!] --ecn-tcp-ece
|
64
|
+
[!] --ecn-ip-ect num
|
65
|
+
esp
|
66
|
+
[!] --espspi spi[:spi]
|
67
|
+
hashlimit
|
68
|
+
--hashlimit-upto amount[/second|/minute|/hour|/day]
|
69
|
+
--hashlimit-above amount[/second|/minute|/hour|/day]
|
70
|
+
--hashlimit-burst amount
|
71
|
+
--hashlimit-mode {srcip|srcport|dstip|dstport},...
|
72
|
+
--hashlimit-srcmask prefix
|
73
|
+
--hashlimit-dstmask prefix
|
74
|
+
--hashlimit-name foo
|
75
|
+
--hashlimit-htable-size buckets
|
76
|
+
--hashlimit-htable-max entries
|
77
|
+
--hashlimit-htable-expire msec
|
78
|
+
--hashlimit-htable-gcinterval msec
|
79
|
+
helper
|
80
|
+
[!] --helper string
|
81
|
+
icmp
|
82
|
+
[!] --icmp-type {type[/code]|typename}
|
83
|
+
iprange
|
84
|
+
[!] --src-range from[-to]
|
85
|
+
[!] --dst-range from[-to]
|
86
|
+
ipvs
|
87
|
+
[!] --ipvs
|
88
|
+
[!] --vproto protocol
|
89
|
+
[!] --vaddr address[/mask]
|
90
|
+
[!] --vport port
|
91
|
+
--vdir {ORIGINAL|REPLY}
|
92
|
+
[!] --vmethod {GATE|IPIP|MASQ}
|
93
|
+
[!] --vportctl port
|
94
|
+
length
|
95
|
+
[!] --length length[:length]
|
96
|
+
limit
|
97
|
+
--limit rate[/second|/minute|/hour|/day]
|
98
|
+
--limit-burst number
|
99
|
+
mac
|
100
|
+
[!] --mac-source address
|
101
|
+
mark
|
102
|
+
[!] --mark value[/mask]
|
103
|
+
multiport
|
104
|
+
[!] --source-ports,--sports port[,port|,port:port]...
|
105
|
+
[!] --destination-ports,--dports port[,port|,port:port]...
|
106
|
+
[!] --ports port[,port|,port:port]...
|
107
|
+
osf
|
108
|
+
[!] --genre string
|
109
|
+
--ttl level
|
110
|
+
--log level
|
111
|
+
owner
|
112
|
+
[!] --uid-owner username
|
113
|
+
[!] --uid-owner userid[-userid]
|
114
|
+
[!] --gid-owner groupname
|
115
|
+
[!] --gid-owner groupid[-groupid]
|
116
|
+
[!] --socket-exists
|
117
|
+
physdev
|
118
|
+
[!] --physdev-in name
|
119
|
+
[!] --physdev-out name
|
120
|
+
[!] --physdev-is-in
|
121
|
+
[!] --physdev-is-out
|
122
|
+
[!] --physdev-is-bridged
|
123
|
+
pkttype
|
124
|
+
[!] --pkt-type {unicast|broadcast|multicast}
|
125
|
+
policy
|
126
|
+
--dir {in|out}
|
127
|
+
--pol {none|ipsec}
|
128
|
+
--strict
|
129
|
+
[!] --reqid id
|
130
|
+
[!] --spi spi
|
131
|
+
[!] --proto {ah|esp|ipcomp}
|
132
|
+
[!] --mode {tunnel|transport}
|
133
|
+
[!] --tunnel-src addr[/mask]
|
134
|
+
[!] --tunnel-dst addr[/mask]
|
135
|
+
--next Start the next element in the policy specification. Can only be
|
136
|
+
quota
|
137
|
+
[!] --quota bytes
|
138
|
+
rateest
|
139
|
+
--rateest-delta
|
140
|
+
[!] --rateest-lt
|
141
|
+
[!] --rateest-gt
|
142
|
+
[!] --rateest-eq
|
143
|
+
--rateest name
|
144
|
+
--rateest1 name
|
145
|
+
--rateest2 name
|
146
|
+
--rateest-bps [value]
|
147
|
+
--rateest-pps [value]
|
148
|
+
--rateest-bps1 [value]
|
149
|
+
--rateest-bps2 [value]
|
150
|
+
--rateest-pps1 [value]
|
151
|
+
--rateest-pps2 [value]
|
152
|
+
realm
|
153
|
+
[!] --realm value[/mask]
|
154
|
+
recent
|
155
|
+
--name name
|
156
|
+
[!] --set
|
157
|
+
--rsource
|
158
|
+
--rdest
|
159
|
+
[!] --rcheck
|
160
|
+
[!] --update
|
161
|
+
[!] --remove
|
162
|
+
--seconds seconds
|
163
|
+
--reap reap
|
164
|
+
--hitcount hits
|
165
|
+
--rttl This option may only be used in conjunction with one of --rcheck
|
166
|
+
sctp
|
167
|
+
[!] --source-port,--sport port[:port]
|
168
|
+
[!] --destination-port,--dport port[:port]
|
169
|
+
[!] --chunk-types {all|any|only} chunktype[:flags] [...]
|
170
|
+
set
|
171
|
+
[!] --match-set setname flag[,flag]...
|
172
|
+
socket
|
173
|
+
--transparent
|
174
|
+
state
|
175
|
+
[!] --state state
|
176
|
+
statistic
|
177
|
+
--mode mode
|
178
|
+
[!] --probability p
|
179
|
+
[!] --every n
|
180
|
+
--packet p
|
181
|
+
string
|
182
|
+
--algo {bm|kmp}
|
183
|
+
--from offset
|
184
|
+
--to offset
|
185
|
+
[!] --string pattern
|
186
|
+
[!] --hex-string pattern
|
187
|
+
tcp
|
188
|
+
[!] --source-port,--sport port[:port]
|
189
|
+
[!] --destination-port,--dport port[:port]
|
190
|
+
[!] --tcp-flags mask comp
|
191
|
+
[!] --syn
|
192
|
+
[!] --tcp-option number
|
193
|
+
tcpmss
|
194
|
+
[!] --mss value[:value]
|
195
|
+
time
|
196
|
+
--datestart YYYY[-MM[-DD[Thh[:mm[:ss]]]]]
|
197
|
+
--datestop YYYY[-MM[-DD[Thh[:mm[:ss]]]]]
|
198
|
+
--timestart hh:mm[:ss]
|
199
|
+
--timestop hh:mm[:ss]
|
200
|
+
[!] --monthdays day[,day...]
|
201
|
+
[!] --weekdays day[,day...]
|
202
|
+
--kerneltz
|
203
|
+
tos
|
204
|
+
[!] --tos value[/mask]
|
205
|
+
[!] --tos symbol
|
206
|
+
ttl
|
207
|
+
--ttl-eq ttl
|
208
|
+
--ttl-gt ttl
|
209
|
+
--ttl-lt ttl
|
210
|
+
u32
|
211
|
+
[!] --u32 tests
|
212
|
+
udp
|
213
|
+
[!] --source-port,--sport port[:port]
|
214
|
+
[!] --destination-port,--dport port[:port]
|
215
|
+
unclean
|
216
|
+
malformed or unusual. This is regarded as experimental.
|
217
|
+
TARGET EXTENSIONS
|
218
|
+
AUDIT
|
219
|
+
--type {accept|drop|reject}
|
220
|
+
CHECKSUM
|
221
|
+
--checksum-fill
|
222
|
+
CLASSIFY
|
223
|
+
--set-class major:minor
|
224
|
+
CLUSTERIP
|
225
|
+
--new Create a new ClusterIP. You always have to set this on the
|
226
|
+
--hashmode mode
|
227
|
+
--clustermac mac
|
228
|
+
--total-nodes num
|
229
|
+
--local-node num
|
230
|
+
--hash-init rnd
|
231
|
+
CONNMARK
|
232
|
+
--set-xmark value[/mask]
|
233
|
+
--save-mark [--nfmask nfmask] [--ctmask ctmask]
|
234
|
+
--restore-mark [--nfmask nfmask] [--ctmask ctmask]
|
235
|
+
--and-mark bits
|
236
|
+
--or-mark bits
|
237
|
+
--xor-mark bits
|
238
|
+
--set-mark value[/mask]
|
239
|
+
--save-mark [--mask mask]
|
240
|
+
--restore-mark [--mask mask]
|
241
|
+
CONNSECMARK
|
242
|
+
--save If the packet has a security marking, copy it to the connection
|
243
|
+
--restore
|
244
|
+
CT
|
245
|
+
--notrack
|
246
|
+
--helper name
|
247
|
+
--ctevents event[,...]
|
248
|
+
--expevents event[,...]
|
249
|
+
--zone id
|
250
|
+
DNAT
|
251
|
+
--to-destination [ipaddr[-ipaddr]][:port[-port]]
|
252
|
+
--random
|
253
|
+
--persistent
|
254
|
+
DSCP
|
255
|
+
--set-dscp value
|
256
|
+
--set-dscp-class class
|
257
|
+
ECN
|
258
|
+
--ecn-tcp-remove
|
259
|
+
IDLETIMER
|
260
|
+
--timeout amount
|
261
|
+
--label string
|
262
|
+
LOG
|
263
|
+
--log-level level
|
264
|
+
--log-prefix prefix
|
265
|
+
--log-tcp-sequence
|
266
|
+
--log-tcp-options
|
267
|
+
--log-ip-options
|
268
|
+
--log-uid
|
269
|
+
MARK
|
270
|
+
--set-xmark value[/mask]
|
271
|
+
--set-mark value[/mask]
|
272
|
+
--and-mark bits
|
273
|
+
--or-mark bits
|
274
|
+
--xor-mark bits
|
275
|
+
MASQUERADE
|
276
|
+
--to-ports port[-port]
|
277
|
+
--random
|
278
|
+
MIRROR
|
279
|
+
NETMAP
|
280
|
+
--to address[/mask]
|
281
|
+
NFLOG
|
282
|
+
--nflog-group nlgroup
|
283
|
+
--nflog-prefix prefix
|
284
|
+
--nflog-range size
|
285
|
+
--nflog-threshold size
|
286
|
+
NFQUEUE
|
287
|
+
--queue-num value
|
288
|
+
--queue-balance value:value
|
289
|
+
--queue-bypass
|
290
|
+
NOTRACK
|
291
|
+
RATEEST
|
292
|
+
--rateest-name name
|
293
|
+
--rateest-interval amount{s|ms|us}
|
294
|
+
--rateest-ewmalog value
|
295
|
+
REDIRECT
|
296
|
+
--to-ports port[-port]
|
297
|
+
--random
|
298
|
+
REJECT
|
299
|
+
--reject-with type
|
300
|
+
SAME
|
301
|
+
--to ipaddr[-ipaddr]
|
302
|
+
--nodst
|
303
|
+
--random
|
304
|
+
SECMARK
|
305
|
+
--selctx security_context
|
306
|
+
SET
|
307
|
+
--add-set setname flag[,flag...]
|
308
|
+
--del-set setname flag[,flag...]
|
309
|
+
--timeout value
|
310
|
+
--exist
|
311
|
+
SNAT
|
312
|
+
--to-source [ipaddr[-ipaddr]][:port[-port]]
|
313
|
+
--random
|
314
|
+
--persistent
|
315
|
+
TCPMSS
|
316
|
+
--set-mss value
|
317
|
+
--clamp-mss-to-pmtu
|
318
|
+
TCPOPTSTRIP
|
319
|
+
--strip-options option[,option...]
|
320
|
+
TEE
|
321
|
+
--gateway ipaddr
|
322
|
+
TOS
|
323
|
+
--set-tos value[/mask]
|
324
|
+
--set-tos symbol
|
325
|
+
--and-tos bits
|
326
|
+
--or-tos bits
|
327
|
+
--xor-tos bits
|
328
|
+
TPROXY
|
329
|
+
--on-port port
|
330
|
+
--on-ip address
|
331
|
+
--tproxy-mark value[/mask]
|
332
|
+
TRACE
|
333
|
+
TTL
|
334
|
+
--ttl-set value
|
335
|
+
--ttl-dec value
|
336
|
+
--ttl-inc value
|
337
|
+
ULOG
|
338
|
+
--ulog-nlgroup nlgroup
|
339
|
+
--ulog-prefix prefix
|
340
|
+
--ulog-cprange size
|
341
|
+
--ulog-qthreshold size
|
342
|
+
|