Class: Hachi::Models::Alert
Instance Attribute Summary collapse
-
#artifacts ⇒ Object
readonly
Returns the value of attribute artifacts.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#follow ⇒ Object
readonly
Returns the value of attribute follow.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#source_ref ⇒ Object
readonly
Returns the value of attribute source_ref.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#tlp ⇒ Object
readonly
Returns the value of attribute tlp.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(title:, description:, type:, source:, severity: nil, date: nil, tags: nil, tlp: nil, status: nil, source_ref: nil, artifacts: nil, follow: nil) ⇒ Alert
constructor
A new instance of Alert.
- #payload ⇒ Object
Constructor Details
#initialize(title:, description:, type:, source:, severity: nil, date: nil, tags: nil, tlp: nil, status: nil, source_ref: nil, artifacts: nil, follow: nil) ⇒ Alert
Returns a new instance of Alert.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/hachi/models/alert.rb', line 11 def initialize(title:, description:, type:, source:, severity: nil, date: nil, tags: nil, tlp: nil, status: nil, source_ref: nil, artifacts: nil, follow: nil) @title = title @description = description @severity = severity @date = date @tags = @tlp = tlp @status = status @type = type @source = source @source_ref = source_ref || SecureRandom.hex(10) @artifacts = artifacts.nil? ? nil : artifacts.map { |a| Artifact.new(**a) } @follow = follow validate_date if date validate_severity if severity validate_status if status validate_tlp if tlp validate_artifacts if artifacts end |
Instance Attribute Details
#artifacts ⇒ Object (readonly)
Returns the value of attribute artifacts.
9 10 11 |
# File 'lib/hachi/models/alert.rb', line 9 def artifacts @artifacts end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
9 10 11 |
# File 'lib/hachi/models/alert.rb', line 9 def date @date end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
9 10 11 |
# File 'lib/hachi/models/alert.rb', line 9 def description @description end |
#follow ⇒ Object (readonly)
Returns the value of attribute follow.
9 10 11 |
# File 'lib/hachi/models/alert.rb', line 9 def follow @follow end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
9 10 11 |
# File 'lib/hachi/models/alert.rb', line 9 def severity @severity end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
9 10 11 |
# File 'lib/hachi/models/alert.rb', line 9 def source @source end |
#source_ref ⇒ Object (readonly)
Returns the value of attribute source_ref.
9 10 11 |
# File 'lib/hachi/models/alert.rb', line 9 def source_ref @source_ref end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
9 10 11 |
# File 'lib/hachi/models/alert.rb', line 9 def status @status end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
9 10 11 |
# File 'lib/hachi/models/alert.rb', line 9 def @tags end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
9 10 11 |
# File 'lib/hachi/models/alert.rb', line 9 def title @title end |
#tlp ⇒ Object (readonly)
Returns the value of attribute tlp.
9 10 11 |
# File 'lib/hachi/models/alert.rb', line 9 def tlp @tlp end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/hachi/models/alert.rb', line 9 def type @type end |
Instance Method Details
#payload ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/hachi/models/alert.rb', line 32 def payload { title: title, description: description, severity: severity, date: date, tags: , tlp: tlp, status: status, type: type, source: source, sourceRef: source_ref, artifacts: artifacts&.map(&:payload), follow: follow }.compact end |