Class: Dap::Filter::FilterGenericSetMatch
- Inherits:
-
Object
- Object
- Dap::Filter::FilterGenericSetMatch
- Includes:
- Base
- Defined in:
- lib/dap/filter/vulnmatch.rb
Instance Attribute Summary collapse
-
#matchset ⇒ Object
Returns the value of attribute matchset.
Attributes included from Base
Instance Method Summary collapse
-
#initialize(args) ⇒ FilterGenericSetMatch
constructor
A new instance of FilterGenericSetMatch.
- #process(doc) ⇒ Object
Constructor Details
#initialize(args) ⇒ FilterGenericSetMatch
Returns a new instance of FilterGenericSetMatch.
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/dap/filter/vulnmatch.rb', line 173 def initialize(args) self.opts = {} args.each do |arg| k,v = arg.split("=", 2) self.opts[k] = v end self.name = Dap::Factory.name_from_class(self.class) fail "Expected key and set arguments to #{self.name} but got #{self.opts}" unless self.opts.has_key?("key") and self.opts.has_key?("set") self.matchset = {} File.readlines(self.opts["set"]).each do |line| self.matchset[line.chomp] = nil end end |
Instance Attribute Details
#matchset ⇒ Object
Returns the value of attribute matchset.
171 172 173 |
# File 'lib/dap/filter/vulnmatch.rb', line 171 def matchset @matchset end |
Instance Method Details
#process(doc) ⇒ Object
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/dap/filter/vulnmatch.rb', line 189 def process(doc) if doc.has_key?(self.opts["key"]) if doc[self.opts["key"]].kind_of?(Array) doc[self.opts["key"]].each do |val| if self.matchset.has_key?(val) return [ doc ] end end else if self.matchset.has_key?(doc[self.opts["key"]]) return [ doc ] end end end [ ] end |