Skip to content

Commit 3655c6b

Browse files
author
Simon Humbert
committed
adding iptables string matching extension
1 parent a856c39 commit 3655c6b

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

lib/puppet/provider/firewall/ip6tables.rb

+7-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
has_feature :mask
3232
has_feature :ipset
3333
has_feature :length
34+
has_feature :string_matching
3435

3536
optional_commands({
3637
:ip6tables => 'ip6tables',
@@ -127,6 +128,10 @@ def self.iptables_save(*args)
127128
:stat_packet => '--packet',
128129
:stat_probability => '--probability',
129130
:state => "-m state --state",
131+
:string => "-m string --string",
132+
:string_algo => "--algo",
133+
:string_from => "--from",
134+
:string_to => "--to",
130135
:table => "-t",
131136
:tcp_flags => "-m tcp --tcp-flags",
132137
:todest => "--to-destination",
@@ -224,7 +229,8 @@ def self.iptables_save(*args)
224229
:tcp_flags, :uid, :gid, :mac_source, :sport, :dport, :port, :src_type,
225230
:dst_type, :socket, :pkttype, :name, :ipsec_dir, :ipsec_policy, :state,
226231
:ctstate, :icmp, :hop_limit, :limit, :burst, :length, :recent, :rseconds, :reap,
227-
:rhitcount, :rttl, :rname, :mask, :rsource, :rdest, :ipset, :jump, :clamp_mss_to_pmtu, :gateway, :todest,
232+
:rhitcount, :rttl, :rname, :mask, :rsource, :rdest, :ipset, :string, :string_algo,
233+
:string_from, :string_to, :jump, :clamp_mss_to_pmtu, :gateway, :todest,
228234
:tosource, :toports, :checksum_fill, :log_level, :log_prefix, :log_uid, :reject, :set_mss, :set_dscp, :set_dscp_class, :mss,
229235
:set_mark, :match_mark, :connlimit_above, :connlimit_mask, :connmark, :time_start, :time_stop, :month_days, :week_days, :date_start, :date_stop, :time_contiguous, :kernel_timezone]
230236

lib/puppet/provider/firewall/iptables.rb

+7-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
has_feature :ipset
3636
has_feature :clusterip
3737
has_feature :length
38+
has_feature :string_matching
3839

3940
optional_commands({
4041
:iptables => 'iptables',
@@ -113,6 +114,10 @@
113114
:stat_packet => '--packet',
114115
:stat_probability => '--probability',
115116
:state => "-m state --state",
117+
:string => "-m string --string",
118+
:string_algo => "--algo",
119+
:string_from => "--from",
120+
:string_to => "--to",
116121
:table => "-t",
117122
:tcp_flags => "-m tcp --tcp-flags",
118123
:todest => "--to-destination",
@@ -258,7 +263,8 @@ def munge_resource_map_from_resource(resource_map_original, compare)
258263
:src_range, :dst_range, :tcp_flags, :uid, :gid, :mac_source, :sport, :dport, :port,
259264
:src_type, :dst_type, :socket, :pkttype, :name, :ipsec_dir, :ipsec_policy,
260265
:state, :ctstate, :icmp, :limit, :burst, :length, :recent, :rseconds, :reap,
261-
:rhitcount, :rttl, :rname, :mask, :rsource, :rdest, :ipset, :jump, :goto, :clusterip_new, :clusterip_hashmode,
266+
:rhitcount, :rttl, :rname, :mask, :rsource, :rdest, :ipset, :string, :string_algo,
267+
:string_from, :string_to, :jump, :goto, :clusterip_new, :clusterip_hashmode,
262268
:clusterip_clustermac, :clusterip_total_nodes, :clusterip_local_node, :clusterip_hash_init,
263269
:clamp_mss_to_pmtu, :gateway, :set_mss, :set_dscp, :set_dscp_class, :todest, :tosource, :toports, :to, :checksum_fill, :random, :log_prefix,
264270
:log_level, :log_uid, :reject, :set_mark, :match_mark, :mss, :connlimit_above, :connlimit_mask, :connmark, :time_start, :time_stop,

lib/puppet/type/firewall.rb

+32
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
feature :ipset, "Match against specified ipset list"
6161
feature :clusterip, "Configure a simple cluster of nodes that share a certain IP and MAC address without an explicit load balancer in front of them."
6262
feature :length, "Match the length of layer-3 payload"
63+
feature :string_matching, "String matching features"
6364

6465
# provider specific features
6566
feature :iptables, "The provider provides iptables features."
@@ -1416,6 +1417,37 @@ def insync?(is)
14161417
end
14171418
end
14181419

1420+
newproperty(:string, :required_features => :string_matching) do
1421+
desc <<-EOS
1422+
String matching feature. Matches the packet against the pattern
1423+
given as an argument.
1424+
EOS
1425+
1426+
munge do |value|
1427+
value = "'" + value + "'"
1428+
end
1429+
end
1430+
1431+
newproperty(:string_algo, :required_features => :string_matching) do
1432+
desc <<-EOS
1433+
String matching feature, pattern matching strategy.
1434+
EOS
1435+
1436+
newvalues(:bm, :kmp)
1437+
end
1438+
1439+
newproperty(:string_from, :required_features => :string_matching) do
1440+
desc <<-EOS
1441+
String matching feature, offset from which we start looking for any matching.
1442+
EOS
1443+
end
1444+
1445+
newproperty(:string_to, :required_features => :string_matching) do
1446+
desc <<-EOS
1447+
String matching feature, offset up to which we should scan.
1448+
EOS
1449+
end
1450+
14191451

14201452
autorequire(:firewallchain) do
14211453
reqs = []

0 commit comments

Comments
 (0)