Class: Nessana::Filter

Inherits:
Hash
  • Object
show all
Defined in:
lib/nessana/filter.rb

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Filter

Returns a new instance of Filter.



7
8
9
10
11
12
13
14
15
# File 'lib/nessana/filter.rb', line 7

def initialize(hash)
	super

	fixed_hash = hash.map do |key, value|
		[key.to_sym, value]
	end.to_h

	merge!(fixed_hash)
end

Instance Method Details

#applies_to?(vulnerability) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/nessana/filter.rb', line 17

def applies_to?(vulnerability)
	each do |key, value|
		method = key.to_sym

		return false unless vulnerability.respond_to?(method)

		case value
		when Regexp
			return true if vulnerability.send(method).to_s =~ value
		else
			return true if vulnerability.send(method).to_s == value
		end
	end

	false
end