cisco_acl_intp 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.rubocop.yml +2 -2
  4. data/.travis.yml +4 -2
  5. data/Gemfile +7 -6
  6. data/README.md +23 -18
  7. data/Rakefile +11 -13
  8. data/cisco_acl_intp.gemspec +7 -7
  9. data/lib/cisco_acl_intp/acc.rb +111 -0
  10. data/lib/cisco_acl_intp/{ace.rb → ace_base.rb} +9 -8
  11. data/lib/cisco_acl_intp/{extended_ace.rb → ace_extended.rb} +8 -10
  12. data/lib/cisco_acl_intp/{standard_ace.rb → ace_standard.rb} +5 -5
  13. data/lib/cisco_acl_intp/acespec_base.rb +15 -0
  14. data/lib/cisco_acl_intp/{ace_ip.rb → acespec_ip.rb} +14 -22
  15. data/lib/cisco_acl_intp/{ace_other_qualifiers.rb → acespec_other_qualifiers.rb} +7 -7
  16. data/lib/cisco_acl_intp/{ace_port.rb → acespec_port.rb} +10 -13
  17. data/lib/cisco_acl_intp/{ace_port_opr.rb → acespec_port_opr.rb} +75 -73
  18. data/lib/cisco_acl_intp/{ace_port_opr_base.rb → acespec_port_opr_base.rb} +49 -34
  19. data/lib/cisco_acl_intp/{ace_proto.rb → acespec_proto.rb} +4 -4
  20. data/lib/cisco_acl_intp/{ace_proto_base.rb → acespec_proto_base.rb} +8 -8
  21. data/lib/cisco_acl_intp/{ace_srcdst.rb → acespec_srcdst.rb} +9 -8
  22. data/lib/cisco_acl_intp/{ace_tcp_flags.rb → acespec_tcp_flags.rb} +4 -4
  23. data/lib/cisco_acl_intp/acl.rb +1 -1
  24. data/lib/cisco_acl_intp/acl_base.rb +108 -80
  25. data/lib/cisco_acl_intp/{mono_function_acl.rb → acl_category_base.rb} +5 -5
  26. data/lib/cisco_acl_intp/acl_utils.rb +1 -1
  27. data/lib/cisco_acl_intp/parser.rb +388 -406
  28. data/lib/cisco_acl_intp/parser.ry +8 -3
  29. data/lib/cisco_acl_intp/parser_api.rb +4 -4
  30. data/lib/cisco_acl_intp/scanner.rb +8 -10
  31. data/lib/cisco_acl_intp/scanner_special_token_handler.rb +3 -3
  32. data/lib/cisco_acl_intp/version.rb +1 -1
  33. data/spec/cisco_acl_intp/{extended_ace_spec.rb → ace_extended_spec.rb} +157 -128
  34. data/spec/cisco_acl_intp/ace_spec.rb +21 -19
  35. data/spec/cisco_acl_intp/{standard_ace_spec.rb → ace_standard_spec.rb} +7 -11
  36. data/spec/cisco_acl_intp/{ace_ip_spec.rb → acespec_ip_spec.rb} +34 -34
  37. data/spec/cisco_acl_intp/{ace_other_qualifier_spec.rb → acespec_other_qualifier_spec.rb} +18 -18
  38. data/spec/cisco_acl_intp/acespec_port_operator_spec.rb +331 -0
  39. data/spec/cisco_acl_intp/{ace_port_spec.rb → acespec_port_spec.rb} +33 -33
  40. data/spec/cisco_acl_intp/{ace_proto_spec.rb → acespec_proto_spec.rb} +61 -61
  41. data/spec/cisco_acl_intp/{ace_srcdst_spec.rb → acespec_srcdst_spec.rb} +113 -54
  42. data/spec/cisco_acl_intp/{ace_tcp_flags_spec.rb → acespec_tcp_flags_spec.rb} +10 -10
  43. data/spec/cisco_acl_intp/acl_base_spec.rb +14 -12
  44. data/spec/cisco_acl_intp/{extended_acl_spec.rb → acl_extended_spec.rb} +28 -28
  45. data/spec/cisco_acl_intp/{standard_acl_spec.rb → acl_standard_spec.rb} +24 -23
  46. data/spec/cisco_acl_intp/cisco_acl_intp_spec.rb +1 -1
  47. data/spec/cisco_acl_intp/parser_spec.rb +12 -12
  48. data/spec/cisco_acl_intp/scanner_spec.rb +31 -36
  49. data/spec/parser_fullfill_patterns.rb +6 -7
  50. data/spec/spec_helper.rb +6 -6
  51. data/tools/check_acl.rb +1 -1
  52. metadata +60 -59
  53. data/lib/cisco_acl_intp/single_acl_base.rb +0 -137
  54. data/spec/cisco_acl_intp/ace_port_operator_spec.rb +0 -340
@@ -1,9 +1,9 @@
1
1
  # -*- coding: utf-8 -*-
2
- require 'cisco_acl_intp/acl_base'
2
+ require 'cisco_acl_intp/acc'
3
3
 
4
4
  module CiscoAclIntp
5
5
  # TCP/UDP Port Set Operator Class
6
- class AcePortOperatorBase < AclContainerBase
6
+ class AcePortOperatorBase < AceSpecBase
7
7
  # @return
8
8
  attr_reader :operator
9
9
 
@@ -11,7 +11,7 @@ module CiscoAclIntp
11
11
  # @return [AceProtoSpecBase]
12
12
  attr_reader :begin_port
13
13
  # alias for unary operator
14
- alias_method :port, :begin_port
14
+ alias port begin_port
15
15
 
16
16
  # @param [AceProtoSpecBase] value Port No. (higher)
17
17
  # @return [AceProtoSpecBase]
@@ -52,70 +52,85 @@ module CiscoAclIntp
52
52
  def contains?(other)
53
53
  case other
54
54
  when AcePortOpEq
55
- compare_eq(other)
55
+ contains_eq?(other)
56
56
  when AcePortOpNeq
57
- compare_neq(other)
57
+ contains_neq?(other)
58
58
  when AcePortOpLt
59
- compare_lt(other)
59
+ contains_lt?(other)
60
60
  when AcePortOpGt
61
- compare_gt(other)
61
+ contains_gt?(other)
62
62
  when AcePortOpRange
63
- compare_range(other)
63
+ contains_range?(other)
64
64
  else
65
- contains_default(other)
65
+ check_any_operator(other)
66
66
  end
67
67
  end
68
68
 
69
69
  private
70
70
 
71
+ # ANY operator check
72
+ # @param [AcePortOpAny] other Another operator
73
+ # @return [Boolean]
74
+ def check_any_operator(other)
75
+ case other
76
+ when AcePortOpStrictAny
77
+ # must match before AcePortOpAny (Base Class)
78
+ contains_strict_any?(other)
79
+ when AcePortOpAny
80
+ contains_any?(other)
81
+ else
82
+ false # unknown operator
83
+ end
84
+ end
85
+
86
+ # Operate ANY containing check
87
+ # @param [AcePortOpAny] _other Another operator
88
+ # @return [Boolean]
89
+ def contains_any?(_other)
90
+ false
91
+ end
92
+
93
+ # Operate STRICT_ANY containing check
94
+ # @param [AcePortOpStrictAny] _other Another operator
95
+ # @return [Boolean]
96
+ def contains_strict_any?(_other)
97
+ false
98
+ end
99
+
71
100
  # Operate EQUAL containing check
72
- # @param [AcePortOperator] other Another operator
101
+ # @param [AcePortOpEq] _other Another operator
73
102
  # @return [Boolean]
74
- def compare_eq(other)
103
+ def contains_eq?(_other)
75
104
  false
76
105
  end
77
106
 
78
107
  # Operate NOT_EQUAL containing check
79
- # @param [AcePortOperator] other Another operator
108
+ # @param [AcePortOpNeq] _other Another operator
80
109
  # @return [Boolean]
81
- def compare_neq(other)
110
+ def contains_neq?(_other)
82
111
  false
83
112
  end
84
113
 
85
114
  # Operate LOWER_THAN containing check
86
- # @param [AcePortOperator] other Another operator
115
+ # @param [AcePortOpLt] _other Another operator
87
116
  # @return [Boolean]
88
- def compare_lt(other)
117
+ def contains_lt?(_other)
89
118
  false
90
119
  end
91
120
 
92
121
  # Operate GREATER_THAN containing check
93
- # @param [AcePortOperator] other Another operator
122
+ # @param [AcePortOpGt] _other Another operator
94
123
  # @return [Boolean]
95
- def compare_gt(other)
124
+ def contains_gt?(_other)
96
125
  false
97
126
  end
98
127
 
99
128
  # Operate RANGE containing check
100
- # @param [AcePortOperator] other Another operator
129
+ # @param [AcePortOpRange] _other Another operator
101
130
  # @return [Boolean]
102
- def compare_range(other)
131
+ def contains_range?(_other)
103
132
  false
104
133
  end
105
-
106
- # Operate *ANY containing check
107
- # @param [AcePortOperator] other Another operator
108
- # @return [Boolean]
109
- def contains_default(other)
110
- case other
111
- when AcePortOpAny
112
- true
113
- when AcePortOpStrictAny
114
- false
115
- else
116
- false
117
- end
118
- end
119
134
  end
120
135
 
121
136
  # Unary operator base class
@@ -124,7 +139,7 @@ module CiscoAclIntp
124
139
  def initialize(*args)
125
140
  super
126
141
  if @begin_port.nil?
127
- fail AclArgumentError, 'Port did not specified in unary operator'
142
+ raise AclArgumentError, 'Port did not specified in unary operator'
128
143
  end
129
144
  @end_port = nil
130
145
  end
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- require 'cisco_acl_intp/ace_proto_base'
2
+ require 'cisco_acl_intp/acespec_proto_base'
3
3
 
4
4
  module CiscoAclIntp
5
5
  # IP protocol number/name container
@@ -24,7 +24,7 @@ module CiscoAclIntp
24
24
  'tcp' => 6,
25
25
  'udp' => 17,
26
26
  'ip' => -1 # dummy
27
- }
27
+ }.freeze
28
28
 
29
29
  # Constructor
30
30
  # @param [String, Integer] proto_id L3 Protocol ID (No. or Name)
@@ -124,7 +124,7 @@ module CiscoAclIntp
124
124
  'uucp' => 540,
125
125
  'whois' => 43,
126
126
  'www' => 80
127
- }
127
+ }.freeze
128
128
 
129
129
  # Constructor
130
130
  # @param [String, Integer] proto_id Protocol ID (No. or Name)
@@ -179,7 +179,7 @@ module CiscoAclIntp
179
179
  'time' => 37,
180
180
  'who' => 513,
181
181
  'xdmcp' => 177
182
- }
182
+ }.freeze
183
183
 
184
184
  # Constructor
185
185
  # @param [String, Integer] proto_id Protocol ID (No. or Name)
@@ -1,9 +1,9 @@
1
1
  # -*- coding: utf-8 -*-
2
- require 'cisco_acl_intp/acl_base'
2
+ require 'cisco_acl_intp/acespec_base'
3
3
 
4
4
  module CiscoAclIntp
5
5
  # IP/TCP/UDP protocol number and protocol name container base
6
- class AceProtoSpecBase < AclContainerBase
6
+ class AceProtoSpecBase < AceSpecBase
7
7
  include Comparable
8
8
 
9
9
  # @return [String] Protocol name
@@ -23,7 +23,7 @@ module CiscoAclIntp
23
23
  # because there are keys exists including '-'.
24
24
  DUMMY_PROTO_TABLE = {
25
25
  'any' => -1 # dummy
26
- }
26
+ }.freeze
27
27
 
28
28
  # Protocol Table
29
29
  # @return [Hash] Protocol table
@@ -52,14 +52,14 @@ module CiscoAclIntp
52
52
  when Integer
53
53
  define_param_by_integer(proto_id)
54
54
  else
55
- fail AclArgumentError, "invalid protocol id #{proto_id}"
55
+ raise AclArgumentError, "invalid protocol id #{proto_id}"
56
56
  end
57
57
  end
58
58
 
59
59
  # Check the port number in valid range of port number
60
60
  # @return [Boolean]
61
61
  def valid_range?
62
- (0 .. @max_num).include?(@number)
62
+ (0..@max_num).cover?(@number)
63
63
  end
64
64
 
65
65
  # Check the port name is known or not.
@@ -128,7 +128,7 @@ module CiscoAclIntp
128
128
  if proto_table.key?(@name)
129
129
  proto_table[@name]
130
130
  else
131
- fail AclArgumentError, "Unknown protocol name: #{@name}"
131
+ raise AclArgumentError, "Unknown protocol name: #{@name}"
132
132
  end
133
133
  end
134
134
 
@@ -139,7 +139,7 @@ module CiscoAclIntp
139
139
  if valid_name?
140
140
  @number = name_to_number
141
141
  else
142
- fail AclArgumentError, "Unknown protocol name: #{@name}"
142
+ raise AclArgumentError, "Unknown protocol name: #{@name}"
143
143
  end
144
144
  end
145
145
 
@@ -150,7 +150,7 @@ module CiscoAclIntp
150
150
  if valid_range?
151
151
  @name = number_to_name
152
152
  else
153
- fail AclArgumentError, "Invalid protocol number: #{@number}"
153
+ raise AclArgumentError, "Invalid protocol number: #{@number}"
154
154
  end
155
155
  end
156
156
  end
@@ -1,15 +1,15 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require 'netaddr'
3
- require 'cisco_acl_intp/ace_ip'
4
- require 'cisco_acl_intp/ace_port'
5
- require 'cisco_acl_intp/ace_other_qualifiers'
6
- require 'cisco_acl_intp/ace_tcp_flags'
3
+ require 'cisco_acl_intp/acespec_ip'
4
+ require 'cisco_acl_intp/acespec_port'
5
+ require 'cisco_acl_intp/acespec_other_qualifiers'
6
+ require 'cisco_acl_intp/acespec_tcp_flags'
7
7
 
8
8
  module CiscoAclIntp
9
9
  # IP Address and TCP/UDP Port Info
10
10
  # @todo Src/Dst takes Network Object Group or IP/wildcard.
11
11
  # "object-group" is not implemented yet.
12
- class AceSrcDstSpec < AclContainerBase
12
+ class AceSrcDstSpec < AceSpecBase
13
13
  # @param [AceIpSpec] value IP address and Wildcard-mask
14
14
  # @return [AceIpSpec]
15
15
  attr_accessor :ip_spec
@@ -103,7 +103,7 @@ module CiscoAclIntp
103
103
  elsif @options.key?(:ipaddr)
104
104
  AceIpSpec.new(@options)
105
105
  else
106
- fail AclArgumentError, 'Not specified: ip spec'
106
+ raise AclArgumentError, 'Not specified: ip spec'
107
107
  end
108
108
  end
109
109
 
@@ -112,7 +112,7 @@ module CiscoAclIntp
112
112
  # @see #initialize
113
113
  def define_portspec
114
114
  if @options.key?(:port_spec) &&
115
- @options[:port_spec].kind_of?(AcePortSpec)
115
+ @options[:port_spec].is_a?(AcePortSpec)
116
116
  @options[:port_spec]
117
117
  elsif @options.key?(:operator)
118
118
  AcePortSpec.new(
@@ -122,7 +122,8 @@ module CiscoAclIntp
122
122
  )
123
123
  else
124
124
  # in standard acl, not used port_spec
125
- # if not specified port spec: default: any port
125
+ # if not specified port spec: default: any port.
126
+ # port spec should be ignored except tcp/udp protocol.
126
127
  AcePortSpec.new(operator: 'any')
127
128
  end
128
129
  end
@@ -1,11 +1,11 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  require 'forwardable'
4
- require 'cisco_acl_intp/acl_base'
4
+ require 'cisco_acl_intp/acespec_base'
5
5
 
6
6
  module CiscoAclIntp
7
7
  # TCP flag container
8
- class AceTcpFlag < AclContainerBase
8
+ class AceTcpFlag < AceSpecBase
9
9
  # @param [String] value TCP flag name
10
10
  # @return [String]
11
11
  attr_accessor :flag
@@ -31,7 +31,7 @@ module CiscoAclIntp
31
31
  end
32
32
 
33
33
  # TCP flag list container
34
- class AceTcpFlagList < AclContainerBase
34
+ class AceTcpFlagList < AceSpecBase
35
35
  extend Forwardable
36
36
 
37
37
  # @param [Array] value TCP Flags
@@ -50,7 +50,7 @@ module CiscoAclIntp
50
50
  # Generate string for Cisco IOS access list
51
51
  # @return [String]
52
52
  def to_s
53
- tag_port(@list.map { |each| each.to_s }.join(' '))
53
+ tag_port(@list.map(&:to_s).join(' '))
54
54
  end
55
55
 
56
56
  # @param [AceTcpFlagList] other RHS Object
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  require 'forwardable'
4
- require 'cisco_acl_intp/mono_function_acl'
4
+ require 'cisco_acl_intp/acl_category_base'
5
5
 
6
6
  module CiscoAclIntp
7
7
  # Named extended ACL container
@@ -1,107 +1,135 @@
1
1
  # -*- coding: utf-8 -*-
2
-
3
- require 'term/ansicolor'
2
+ require 'forwardable'
3
+ require 'cisco_acl_intp/ace_extended'
4
+ require 'cisco_acl_intp/acl_utils'
5
+ require 'cisco_acl_intp/acc'
4
6
 
5
7
  module CiscoAclIntp
6
- # Standard Error Handler of CiscoAclParser
7
- class AclError < StandardError; end
8
+ # ACL (access-list) container.
9
+ # ACL is composed of ACL-Header and ACE-List.
10
+ # ACL has list(set) of ACE and functions to operate ACE list.
11
+ class AclBase < AccessControlContainer
12
+ extend Forwardable
13
+ include Enumerable
14
+ include AceSearchUtility
15
+
16
+ # @return [String] name ACL name,
17
+ # when numbered acl, /\d+/ string
18
+ attr_reader :name
19
+ # Some Enumerable included methods returns Array of ACE objects
20
+ # (e.g. sort),the returned Array was used as ACE object by
21
+ # overwrite accessor 'list'.
22
+ # @return [Array<AceBase>] list ACE object Array
23
+ attr_accessor :list
24
+ # @return [String, Symbol] acl_type ACL type
25
+ attr_reader :acl_type
26
+ # @return [String, Symbol] name_type ACL name type
27
+ attr_reader :name_type
28
+
29
+ def_delegators :@list, :each # for Enumerable
30
+ def_delegators :@list, :push, :pop, :shift, :unshift
31
+ def_delegators :@list, :size, :length
32
+
33
+ # Increment number of ACL sequence number
34
+ SEQ_NUM_DIV = 10
8
35
 
9
- # Argument Error Handler of CiscoAclParser
10
- class AclArgumentError < AclError; end
36
+ # Constructor
37
+ # @param [String] name ACL name
38
+ # @return [AclBase]
39
+ def initialize(name)
40
+ @name = name # ACL name
41
+ @list = [] # List of ACE
42
+ @seq_number = 0 # Sequence Number of ACE
11
43
 
12
- # Acl container common utility and status management
13
- class AclContainerBase
14
- class << self
15
- # Color mode: defined as a class instance variable
16
- attr_accessor :color_mode
44
+ @acl_type = nil # :standard or :extended
45
+ @name_type = nil # :named or :numbered
17
46
  end
18
47
 
19
- # Disables coloring
20
- def self.disable_color
21
- @color_mode = :none
48
+ # duplicate ACE list
49
+ # @param [Array<AceBase>] list List of ACE
50
+ # @return [AclBase]
51
+ def dup_with_list(list)
52
+ acl = dup
53
+ acl.list = list.dup
54
+ acl
22
55
  end
23
56
 
24
- # Generate string for Cisco IOS access list
25
- # @abstract
26
- # @return [String]
27
- def to_s
28
- fail AclError, 'Not overridden AclContainerBase::to_s'
57
+ # Add ACE to ACL (push with sequence number)
58
+ # @param [AceBase] ace ACE object
59
+ def add_entry(ace)
60
+ # 'ace' is AceBase Object
61
+ # it will be ExtendedAce/StandardAce/RemarkAce/EvaluateAce
62
+ ace.seq_number = (@list.length + 1) * SEQ_NUM_DIV unless ace.seq_number?
63
+ @list.push ace
29
64
  end
30
65
 
31
- private
66
+ # Renumber ACL by list sequence
67
+ def renumber
68
+ # re-numbering seq_number of each entry
69
+ @list.reduce(SEQ_NUM_DIV) do |number, each|
70
+ each.seq_number = number
71
+ number + SEQ_NUM_DIV
72
+ end
73
+ end
32
74
 
33
- # Table of ACL Tag color codes for terminal
34
- TERM_COLOR_TABLE = {
35
- header: Term::ANSIColor.on_blue,
36
- type: Term::ANSIColor.underline,
37
- action: Term::ANSIColor.intense_magenta,
38
- name: Term::ANSIColor.bold,
39
- remark: Term::ANSIColor.blink,
40
- ip: [Term::ANSIColor.green, Term::ANSIColor.underline].join,
41
- mask: Term::ANSIColor.yellow,
42
- protocol: Term::ANSIColor.cyan,
43
- port: Term::ANSIColor.cyan,
44
- other_qualifier: Term::ANSIColor.green,
45
- error: [Term::ANSIColor.red, Term::ANSIColor.bold].join
46
- }
75
+ # Check equality
76
+ # @return [Boolean]
77
+ def ==(other)
78
+ @acl_type &&
79
+ @name_type &&
80
+ @acl_type == other.acl_type &&
81
+ @name_type == other.name_type &&
82
+ @list == other.list
83
+ end
47
84
 
48
- # Generate header of ACL tag
49
- # @param [Symbol] tag Tag symbol.
50
- # @return [String] Tagged string.
51
- def generate_tag_header(tag)
52
- case AclContainerBase.color_mode
53
- when :term
54
- TERM_COLOR_TABLE[tag]
55
- when :html
56
- %Q(<span class="acltag_#{tag}">)
57
- else
58
- ''
59
- end
85
+ # Find lists of ACEs that contains flow by options
86
+ # @param [Hash] opts Options (target packet info)
87
+ # options are same as #find_aces_with
88
+ # @see #find_aces_with
89
+ # @return [Array<AceBase>] List of ACEs or nil(not found)
90
+ def find_aces_contains(opts)
91
+ find_aces_with(opts) { |ace, target_ace| ace.contains?(target_ace) }
60
92
  end
61
93
 
62
- # Generate footer of ACL tag
63
- # @return [String] Tagged string.
64
- def generate_tag_footer
65
- case AclContainerBase.color_mode
66
- when :term
67
- Term::ANSIColor.clear
68
- when :html
69
- '</span>'
70
- else
71
- ''
72
- end
94
+ # Find lists of ACEs that is contained flow by options
95
+ # @param [Hash] opts Options (target packet info)
96
+ # options are same as #find_aces_with
97
+ # @see #find_aces_with
98
+ # @return [Array<AceBase>] List of ACEs or nil(not found)
99
+ def find_aces_contained(opts)
100
+ find_aces_with(opts) { |ace, target_ace| target_ace.contains?(ace) }
73
101
  end
74
102
 
75
- # Generate tagged ACL string.
76
- # @param [Symbol] tag Tag symbol.
77
- # @param [Array] args Array of argments.
78
- # @return [String] Tagged string.
79
- def generate_tagged_str(tag, *args)
80
- tag_head = generate_tag_header(tag)
81
- tag_body = args.join
82
- tag_foot = generate_tag_footer
83
- [tag_head, tag_body, tag_foot].join
103
+ # Find lists of ACEs
104
+ # @note In Standard ACL, only src_ip option is used and another
105
+ # conditions are ignored (if specified).
106
+ # @param [Hash] opts Options (target flow info),
107
+ # @option opts [Integer,String] protocol L3 protocol No./Name
108
+ # @option opts [String] src_ip Source IP Address
109
+ # @option opts [String] src_operator Source port operator.
110
+ # @option opts [Integer,String] src_begin_port Source Port No./Name
111
+ # @option opts [Integer,String] src_end_port Source Port No./Name
112
+ # @option opts [String] dst_ip Destination IP Address
113
+ # @option opts [Integer,String] dst_begin_port Destination Port No./Name
114
+ # @option opts [Integer,String] dst_end_port Destination Port No./Name
115
+ # @yield Find lists of ACEs
116
+ # @yieldparam [ExtendedAce] ace ACE
117
+ # @yieldparam [ExtendedAce] target_ace Target ACE
118
+ # @yieldreturn [Boolean] Condition to find
119
+ # @return [Array<AceBase>] List of ACEs or nil(not found)
120
+ def find_aces_with(opts)
121
+ target_ace = target_ace(opts)
122
+ @list.find { |ace| yield(ace, target_ace) }
84
123
  end
85
124
 
86
- # acl string clean-up
125
+ # acl string clean-up (override)
87
126
  # @param [String] str ACL string.
88
127
  # @return [String]
89
128
  def clean_acl_string(str)
90
- str.strip.gsub(/\s+/, ' ')
91
- end
92
-
93
- # Generate tagging method dynamically.
94
- # @raise [NoMethodError]
95
- def method_missing(name, *args)
96
- name.to_s =~ /^tag_(.+)$/ && tag = Regexp.last_match(1).intern
97
- if TERM_COLOR_TABLE.key?(tag)
98
- generate_tagged_str(tag, *args)
99
- else
100
- super
101
- end
129
+ str =~ /remark/ ? str : super
102
130
  end
103
131
  end
104
- end
132
+ end # module
105
133
 
106
134
  ### Local variables:
107
135
  ### mode: Ruby