Class: Threshold::Suppression

Inherits:
Object
  • Object
show all
Includes:
Comparable, Standalone
Defined in:
lib/threshold/suppression.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Standalone

#<=>, #==, #comment?, #hash, #include?

Constructor Details

#initialize(line = "") ⇒ Suppression

Returns a new instance of Suppression.



50
51
52
# File 'lib/threshold/suppression.rb', line 50

def initialize(line="")
  transform(line) unless line.empty?
end

Instance Attribute Details

#commentObject

Returns the value of attribute comment.



44
45
46
# File 'lib/threshold/suppression.rb', line 44

def comment
  @comment
end

#gidObject

Returns the value of attribute gid.



44
45
46
# File 'lib/threshold/suppression.rb', line 44

def gid
  @gid
end

#ipObject

Returns the value of attribute ip.



44
45
46
# File 'lib/threshold/suppression.rb', line 44

def ip
  @ip
end

#sidObject

Returns the value of attribute sid.



44
45
46
# File 'lib/threshold/suppression.rb', line 44

def sid
  @sid
end

#track_byObject

Returns the value of attribute track_by.



44
45
46
# File 'lib/threshold/suppression.rb', line 44

def track_by
  @track_by
end

Instance Method Details

#stateObject

State does not track comments



75
76
77
# File 'lib/threshold/suppression.rb', line 75

def state
  [@gid, @sid, @track_by, @ip]
end

#to_s(skip = false) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/threshold/suppression.rb', line 54

def to_s(skip = false)
  if self.valid?
    if track_by == nil then
      if comment?(skip)
        "suppress gen_id #{@gid}, sig_id #{@sid}#{@comment}"
      else
        "suppress gen_id #{@gid}, sig_id #{@sid}"
      end
    else
      if comment?(skip)
        "suppress gen_id #{@gid}, sig_id #{@sid}, track by_#{@track_by}, ip #{@ip} #{@comment}"
      else
        "suppress gen_id #{@gid}, sig_id #{@sid}, track by_#{@track_by}, ip #{@ip}"
      end
    end
  else
    raise InvalidSuppressionObject, 'Suppression did not validate'
  end
end