Class: NoradBeacon::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/norad_beacon/result.rb

Constant Summary collapse

SIGNATURE_DIGEST =

I’m making this value a constant to reinforce the idea that it should never change. If it does, all ignore rules in the Norad database will be invalidated.

OpenSSL::Digest::SHA256

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nid, status, output, title, description, sir = 'unevaluated', text_to_fingerprint = nil) ⇒ Result

rubocop:disable ParameterLists



15
16
17
18
19
20
21
22
23
# File 'lib/norad_beacon/result.rb', line 15

def initialize(nid, status, output, title, description, sir = 'unevaluated', text_to_fingerprint = nil)
  @nid = nid.to_s
  @sir = cvss_to_sir(sir)
  @status = status.to_s
  @output = output.to_s
  @title = title.to_s
  @description = description.to_s
  @signature = compute_signature(text_to_fingerprint)
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



8
9
10
# File 'lib/norad_beacon/result.rb', line 8

def description
  @description
end

#nidObject (readonly)

Returns the value of attribute nid.



8
9
10
# File 'lib/norad_beacon/result.rb', line 8

def nid
  @nid
end

#outputObject (readonly)

Returns the value of attribute output.



8
9
10
# File 'lib/norad_beacon/result.rb', line 8

def output
  @output
end

#signatureObject (readonly)

Returns the value of attribute signature.



8
9
10
# File 'lib/norad_beacon/result.rb', line 8

def signature
  @signature
end

#sirObject (readonly)

Returns the value of attribute sir.



8
9
10
# File 'lib/norad_beacon/result.rb', line 8

def sir
  @sir
end

#statusObject (readonly)

Returns the value of attribute status.



8
9
10
# File 'lib/norad_beacon/result.rb', line 8

def status
  @status
end

#titleObject (readonly)

Returns the value of attribute title.



8
9
10
# File 'lib/norad_beacon/result.rb', line 8

def title
  @title
end

Instance Method Details

#to_json(*a) ⇒ Object

rubocop:enable ParameterLists



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/norad_beacon/result.rb', line 26

def to_json(*a)
  {
    nid: nid,
    sir: sir,
    status: status,
    output: output,
    title: title,
    description: description,
    signature: signature
  }.to_json(*a)
end