norad_beacon 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d13c67f1371165cae9ca885c7573faf2e1f39fa0
4
- data.tar.gz: 26752d82f9b15c9f2a8871ae4b9f412457e6d3dd
3
+ metadata.gz: defdd19d1e84401ef7c56d7ebed4e587dd05f440
4
+ data.tar.gz: fa4789a131a798d87d0cc5bad20ec14c207f8ade
5
5
  SHA512:
6
- metadata.gz: bbd5d5da22ab1905f6635b3fc893cb063b55ff3b886ffae1fa7baf557a3e63ac2eea9409116dd5f189c3b308569ef124b90b84efacf6fc75426fe3d52ccd9aa7
7
- data.tar.gz: 7e312d7ce61eb84a25440653d1a1b3d1b76cfdb5d56582fb41d939f6a37ad4279e5169b7f931141e7b17519798db7dfe45e6c129409ff135b183a053263e22bf
6
+ metadata.gz: b7307db47ad21b46594f237c3e3da64f9ac7cbadaaebc8657d81559af7e55145789407087a0363e436d136c67b0434595d1ea0edfad4831ba8b2690a9e2a53aa
7
+ data.tar.gz: 2b1516c17d15e51b904f7ad48be50ff46c8c25e6e7513fd399305bc6e6308e7438eaf1944e9c67699948ee51ca45af68955aede69c384f6170a29cf0f953c4da
@@ -6,20 +6,19 @@ module NoradBeacon
6
6
  class Result
7
7
  attr_reader :nid, :sir, :status, :output, :title, :description, :signature
8
8
 
9
- # I'm making both of these values constants to reinforce the idea that these values should
10
- # *never* change. If they do, all ignore rules in the Norad database we'll be invalidated.
11
- SIGNATURE_DIGEST = OpenSSL::Digest.new('sha256')
12
- SIGNATURE_KEY = 'n0r4dRULES'
9
+ # I'm making this value a constant to reinforce the idea that it should *never* change. If it
10
+ # does, all ignore rules in the Norad database will be invalidated.
11
+ SIGNATURE_DIGEST = OpenSSL::Digest::SHA256
13
12
 
14
13
  # rubocop:disable ParameterLists
15
- def initialize(nid, status, output, title, description, sir = 'unevaluated')
16
- @nid = nid
14
+ def initialize(nid, status, output, title, description, sir = 'unevaluated', text_to_fingerprint = nil)
15
+ @nid = nid.to_s
17
16
  @sir = cvss_to_sir(sir)
18
- @status = status
19
- @output = output
20
- @title = title
21
- @description = description
22
- @signature = compute_signature
17
+ @status = status.to_s
18
+ @output = output.to_s
19
+ @title = title.to_s
20
+ @description = description.to_s
21
+ @signature = compute_signature(text_to_fingerprint)
23
22
  end
24
23
  # rubocop:enable ParameterLists
25
24
 
@@ -49,9 +48,9 @@ module NoradBeacon
49
48
  end
50
49
  end
51
50
 
52
- def compute_signature
53
- result_for_signature = nid.to_s + title.to_s + status.to_s
54
- OpenSSL::HMAC.hexdigest(SIGNATURE_DIGEST, SIGNATURE_KEY, result_for_signature)
51
+ def compute_signature(text_to_fingerprint)
52
+ # If no specialized text to fingerprint was provided, use the raw output
53
+ SIGNATURE_DIGEST.new.update("#{nid}#{title}#{text_to_fingerprint || output}").hexdigest
55
54
  end
56
55
  end
57
56
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module NoradBeacon
3
- VERSION = '0.1.2'
3
+ VERSION = '0.1.3'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: norad_beacon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Hitchcock
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2017-01-25 00:00:00.000000000 Z
13
+ date: 2017-02-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
@@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
191
  version: '0'
192
192
  requirements: []
193
193
  rubyforge_project:
194
- rubygems_version: 2.6.9
194
+ rubygems_version: 2.6.10
195
195
  signing_key:
196
196
  specification_version: 4
197
197
  summary: Gem to help with posting blackbox results to Norad.