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:, severity: nil, date: nil, tags: nil, tlp: nil, status: nil, type:, source:, source_ref: nil, artifacts: nil, follow: nil) ⇒ Alert
constructor
A new instance of Alert.
- #payload ⇒ Object
Constructor Details
#initialize(title:, description:, severity: nil, date: nil, tags: nil, tlp: nil, status: nil, type:, source:, source_ref: nil, artifacts: nil, follow: nil) ⇒ Alert
Returns a new instance of Alert.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/hachi/models/alert.rb', line 22 def initialize(title:, description:, severity: nil, date: nil, tags: nil, tlp: nil, status: nil, type:, source:, 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.
19 20 21 |
# File 'lib/hachi/models/alert.rb', line 19 def artifacts @artifacts end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
12 13 14 |
# File 'lib/hachi/models/alert.rb', line 12 def date @date end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
10 11 12 |
# File 'lib/hachi/models/alert.rb', line 10 def description @description end |
#follow ⇒ Object (readonly)
Returns the value of attribute follow.
20 21 22 |
# File 'lib/hachi/models/alert.rb', line 20 def follow @follow end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
11 12 13 |
# File 'lib/hachi/models/alert.rb', line 11 def severity @severity end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
17 18 19 |
# File 'lib/hachi/models/alert.rb', line 17 def source @source end |
#source_ref ⇒ Object (readonly)
Returns the value of attribute source_ref.
18 19 20 |
# File 'lib/hachi/models/alert.rb', line 18 def source_ref @source_ref end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
15 16 17 |
# File 'lib/hachi/models/alert.rb', line 15 def status @status end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
13 14 15 |
# File 'lib/hachi/models/alert.rb', line 13 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.
14 15 16 |
# File 'lib/hachi/models/alert.rb', line 14 def tlp @tlp end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
16 17 18 |
# File 'lib/hachi/models/alert.rb', line 16 def type @type end |
Instance Method Details
#payload ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/hachi/models/alert.rb', line 43 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 |