Class: FIDIUS::EvasionDB::Knowledge::EnabledRules

Inherits:
Connection
  • Object
show all
Defined in:
lib/evasion-db/knowledge/enabled_rules.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.table_nameObject



7
8
9
# File 'lib/evasion-db/knowledge/enabled_rules.rb', line 7

def self.table_name
  "enabled_rules"
end

Instance Method Details

#bitvectorObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/evasion-db/knowledge/enabled_rules.rb', line 11

def bitvector
  return @bitvector if @bitvector
  res = BitField.new(self.bitstring.size)
  i = 0
  self.bitstring.each_char do |bit|
    res[i] = bit.to_i
    i += 1
  end
  @bitvector = res
  return @bitvector
end

#count(h) ⇒ Object

count rules :active or :inactive or :all



25
26
27
28
29
30
31
32
33
34
# File 'lib/evasion-db/knowledge/enabled_rules.rb', line 25

def count(h)
  if h == :all
    return bitvector.size
  elsif h == :active
    return bitvector.total_set
  elsif h == :inactive
    return (bitvector.size - bitvector.total_set)
  end
  raise "use count(:active) or count(:inactive)"
end