Class: Hachi::Models::Alert

Inherits:
Base
  • Object
show all
Defined in:
lib/hachi/models/alert.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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 = 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

#artifactsObject (readonly)

Returns the value of attribute artifacts.



9
10
11
# File 'lib/hachi/models/alert.rb', line 9

def artifacts
  @artifacts
end

#dateObject (readonly)

Returns the value of attribute date.



9
10
11
# File 'lib/hachi/models/alert.rb', line 9

def date
  @date
end

#descriptionObject (readonly)

Returns the value of attribute description.



9
10
11
# File 'lib/hachi/models/alert.rb', line 9

def description
  @description
end

#followObject (readonly)

Returns the value of attribute follow.



9
10
11
# File 'lib/hachi/models/alert.rb', line 9

def follow
  @follow
end

#severityObject (readonly)

Returns the value of attribute severity.



9
10
11
# File 'lib/hachi/models/alert.rb', line 9

def severity
  @severity
end

#sourceObject (readonly)

Returns the value of attribute source.



9
10
11
# File 'lib/hachi/models/alert.rb', line 9

def source
  @source
end

#source_refObject (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

#statusObject (readonly)

Returns the value of attribute status.



9
10
11
# File 'lib/hachi/models/alert.rb', line 9

def status
  @status
end

#tagsObject (readonly)

Returns the value of attribute tags.



9
10
11
# File 'lib/hachi/models/alert.rb', line 9

def tags
  @tags
end

#titleObject (readonly)

Returns the value of attribute title.



9
10
11
# File 'lib/hachi/models/alert.rb', line 9

def title
  @title
end

#tlpObject (readonly)

Returns the value of attribute tlp.



9
10
11
# File 'lib/hachi/models/alert.rb', line 9

def tlp
  @tlp
end

#typeObject (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

#payloadObject



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: tags,
    tlp: tlp,
    status: status,
    type: type,
    source: source,
    sourceRef: source_ref,
    artifacts: artifacts&.map(&:payload),
    follow: follow
  }.compact
end