norad_beacon 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Rakefile +1 -0
- data/lib/norad_beacon/api.rb +25 -8
- data/lib/norad_beacon/container_options.rb +1 -0
- data/lib/norad_beacon/exceptions.rb +1 -0
- data/lib/norad_beacon/http_payload.rb +33 -0
- data/lib/norad_beacon/multi_runner.rb +1 -0
- data/lib/norad_beacon/result.rb +1 -0
- data/lib/norad_beacon/resultset.rb +8 -7
- data/lib/norad_beacon/runner.rb +1 -0
- data/lib/norad_beacon/version.rb +2 -1
- data/lib/norad_beacon.rb +2 -0
- data/norad_beacon.gemspec +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2947fc7310fe218b9a224ac924a54d8bdbf2ae1c
|
|
4
|
+
data.tar.gz: c63ab35803595c7d6ad1ef93d680e12aed830cef
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 930d9699e9537f1a92e141e243e5c9565abe47c43f3342c74d60971c3b8d3ce47fd92a0982114aa9a23123feaa2481c3ef32d1ac1a6415dd72781dd56f632540
|
|
7
|
+
data.tar.gz: 5cb41b6a56aecc5668ff55ff1db53e0f751dc80b12f7fba287726a052ae12b3976555ff06c931c7690d1e18531543782f817009a1db619ce49a80bcbef8b0209
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/lib/norad_beacon/api.rb
CHANGED
|
@@ -1,19 +1,36 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require 'httparty'
|
|
3
4
|
|
|
4
5
|
module NoradBeacon
|
|
5
|
-
# Class to post
|
|
6
|
+
# Class to post http payloads
|
|
6
7
|
class NoradAPI
|
|
7
8
|
include HTTParty
|
|
8
9
|
@norad_root = ENV.fetch('NORAD_ROOT')
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
class << self
|
|
12
|
+
def post_payload(http_payload)
|
|
13
|
+
http_req http_payload, :post
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def delete_payload(http_payload)
|
|
17
|
+
http_req http_payload, :delete
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
alias post_results post_payload
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def http_req(http_payload, verb)
|
|
25
|
+
auth_header = { 'NORAD-SIGNATURE' => http_payload.compute_signature }
|
|
26
|
+
address = @norad_root + http_payload.url
|
|
27
|
+
send(
|
|
28
|
+
verb,
|
|
29
|
+
address,
|
|
30
|
+
body: http_payload.payload,
|
|
31
|
+
headers: { 'Content-Type' => 'application/json' }.merge(auth_header)
|
|
32
|
+
)
|
|
33
|
+
end
|
|
17
34
|
end
|
|
18
35
|
end
|
|
19
36
|
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'json'
|
|
4
|
+
require 'openssl'
|
|
5
|
+
|
|
6
|
+
module NoradBeacon
|
|
7
|
+
class HttpPayload
|
|
8
|
+
attr_accessor :url
|
|
9
|
+
|
|
10
|
+
def initialize(url = nil)
|
|
11
|
+
@data = {}
|
|
12
|
+
@url = url || url_from_env
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def add(obj)
|
|
16
|
+
@data.merge!(obj.to_h)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def payload
|
|
20
|
+
@payload ||= @data.merge(timestamp: Time.now.to_i).to_json
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def compute_signature
|
|
24
|
+
OpenSSL::HMAC.hexdigest('sha256', ENV['NORAD_SECRET'], payload)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
|
|
29
|
+
def url_from_env
|
|
30
|
+
''
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
data/lib/norad_beacon/result.rb
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require 'json'
|
|
3
4
|
require 'openssl'
|
|
4
5
|
|
|
5
6
|
module NoradBeacon
|
|
6
|
-
class ResultSet
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def initialize(assessment_url = nil)
|
|
7
|
+
class ResultSet < HttpPayload
|
|
8
|
+
def initialize(url = nil)
|
|
9
|
+
super(url)
|
|
10
10
|
@results = []
|
|
11
|
-
@url = assessment_url || JSON.parse(ENV.fetch('ASSESSMENT_PATHS')).first['assessment']
|
|
12
11
|
end
|
|
13
12
|
|
|
14
13
|
def add(result)
|
|
@@ -19,8 +18,10 @@ module NoradBeacon
|
|
|
19
18
|
@payload ||= { results: @results, timestamp: Time.now.to_i }.to_json
|
|
20
19
|
end
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def url_from_env
|
|
24
|
+
JSON.parse(ENV.fetch('ASSESSMENT_PATHS')).first['assessment']
|
|
24
25
|
end
|
|
25
26
|
end
|
|
26
27
|
end
|
data/lib/norad_beacon/runner.rb
CHANGED
data/lib/norad_beacon/version.rb
CHANGED
data/lib/norad_beacon.rb
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require 'norad_beacon/version'
|
|
3
4
|
require 'norad_beacon/runner'
|
|
4
5
|
require 'norad_beacon/multi_runner'
|
|
6
|
+
require 'norad_beacon/http_payload'
|
|
5
7
|
require 'norad_beacon/result'
|
|
6
8
|
require 'norad_beacon/resultset'
|
|
7
9
|
require 'norad_beacon/exceptions'
|
data/norad_beacon.gemspec
CHANGED
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.
|
|
4
|
+
version: 0.1.4
|
|
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-
|
|
13
|
+
date: 2017-07-13 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: httparty
|
|
@@ -165,6 +165,7 @@ files:
|
|
|
165
165
|
- lib/norad_beacon/api.rb
|
|
166
166
|
- lib/norad_beacon/container_options.rb
|
|
167
167
|
- lib/norad_beacon/exceptions.rb
|
|
168
|
+
- lib/norad_beacon/http_payload.rb
|
|
168
169
|
- lib/norad_beacon/multi_runner.rb
|
|
169
170
|
- lib/norad_beacon/result.rb
|
|
170
171
|
- lib/norad_beacon/resultset.rb
|
|
@@ -191,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
191
192
|
version: '0'
|
|
192
193
|
requirements: []
|
|
193
194
|
rubyforge_project:
|
|
194
|
-
rubygems_version: 2.6.
|
|
195
|
+
rubygems_version: 2.6.11
|
|
195
196
|
signing_key:
|
|
196
197
|
specification_version: 4
|
|
197
198
|
summary: Gem to help with posting blackbox results to Norad.
|