loadrunner 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/load_runner/client.rb +1 -1
- data/lib/load_runner/command_line.rb +1 -1
- data/lib/load_runner/runner.rb +12 -4
- data/lib/load_runner/server.rb +9 -2
- data/lib/load_runner/server_helper.rb +18 -14
- data/lib/load_runner/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8a007f7920f1973efc60d3795c4cd8dab52cb3d
|
4
|
+
data.tar.gz: 0baaf60bb349d17969597985c564bdb68daf1391
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd2ddfff2c1dfa0522871c2a41c84e60b36934e56d5785e52172d5cc4bccb17c99cde8e58d78b580a4181448ba252b9b99a512ee803e694e390598f38536ef23
|
7
|
+
data.tar.gz: 714bea8499b8c53e358dfca0fe09e75cd97455b97729f49bd99f71d15f6e91b51562c60b0c31386ebdb5cd954325eaa2336a5b91de7bce28f8a820dabee645f1
|
data/lib/load_runner/client.rb
CHANGED
@@ -16,7 +16,7 @@ module LoadRunner
|
|
16
16
|
send_payload event, payload
|
17
17
|
end
|
18
18
|
|
19
|
-
def send_payload(event
|
19
|
+
def send_payload(event, payload)
|
20
20
|
@payload = payload.is_a?(String) ? payload : payload.to_json
|
21
21
|
headers = headers event
|
22
22
|
self.class.post "/payload", body: @payload, headers: headers
|
data/lib/load_runner/runner.rb
CHANGED
@@ -25,6 +25,14 @@ module LoadRunner
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
def handlers_dir
|
29
|
+
@handlers_dir ||= 'handlers'
|
30
|
+
end
|
31
|
+
|
32
|
+
def handlers_dir=(path)
|
33
|
+
@handlers_dir = path
|
34
|
+
end
|
35
|
+
|
28
36
|
private
|
29
37
|
|
30
38
|
def locate_handlers
|
@@ -53,12 +61,12 @@ module LoadRunner
|
|
53
61
|
end
|
54
62
|
|
55
63
|
def matching_handlers
|
56
|
-
base = "
|
57
|
-
handlers = ["#{base}
|
64
|
+
base = "#{handlers_dir}/#{opts[:repo]}/#{opts[:event]}"
|
65
|
+
handlers = ["#{base}"]
|
58
66
|
|
59
67
|
handlers.tap do |h|
|
60
|
-
h << "#{base}
|
61
|
-
h << "#{base}
|
68
|
+
h << "#{base}@branch=#{opts[:branch]}" if opts[:branch]
|
69
|
+
h << "#{base}@tag=#{opts[:tag]}" if opts[:tag]
|
62
70
|
end
|
63
71
|
end
|
64
72
|
|
data/lib/load_runner/server.rb
CHANGED
@@ -4,16 +4,23 @@ module LoadRunner
|
|
4
4
|
class Server < ServerBase
|
5
5
|
include ServerHelper
|
6
6
|
|
7
|
+
get '/' do
|
8
|
+
"OK"
|
9
|
+
end
|
10
|
+
|
7
11
|
post '/payload' do
|
8
12
|
request.body.rewind
|
9
13
|
payload_body = request.body.read
|
10
14
|
|
11
|
-
|
15
|
+
signature = request.env['HTTP_X_HUB_SIGNATURE']
|
16
|
+
state = verify_signature payload_body, signature
|
17
|
+
|
18
|
+
halt 401, halt_messages[state] if state != :ok
|
12
19
|
|
13
20
|
push = ActiveSupport::HashWithIndifferentAccess.new JSON.parse payload_body
|
14
21
|
|
15
22
|
opts = {}
|
16
|
-
opts[:repo] = push
|
23
|
+
opts[:repo] = push.dig(:repository, :name)
|
17
24
|
opts[:event] = request.env['HTTP_X_GITHUB_EVENT']
|
18
25
|
opts[:branch] = push[:ref].sub('refs/heads/', '') if push[:ref] =~ /refs\/heads/
|
19
26
|
opts[:tag] = push[:ref].sub('refs/tags/', '') if push[:ref] =~ /refs\/tags/
|
@@ -1,25 +1,29 @@
|
|
1
1
|
module LoadRunner
|
2
2
|
module ServerHelper
|
3
|
-
def verify_signature(payload_body)
|
4
|
-
|
3
|
+
def verify_signature(payload_body, signature)
|
4
|
+
return :no_client if secret_token and !signature
|
5
|
+
return :no_server if !secret_token and signature
|
6
|
+
return :ok if !secret_token and !signature
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
if !secret_token and request_signature
|
11
|
-
return halt 401, "Server secret token is not configured"
|
12
|
-
end
|
8
|
+
expected_signature = generate_signature payload_body
|
9
|
+
signature_match = Rack::Utils.secure_compare(expected_signature, signature)
|
10
|
+
return signature_match ? :ok : :mismatch
|
11
|
+
end
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
signature_match = Rack::Utils.secure_compare(signature, request.env['HTTP_X_HUB_SIGNATURE'])
|
17
|
-
return halt 401, "Signature mismatch" unless signature_match
|
18
|
-
end
|
13
|
+
def generate_signature(payload_body)
|
14
|
+
'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), secret_token, payload_body)
|
19
15
|
end
|
20
16
|
|
21
17
|
def secret_token
|
22
18
|
ENV['GITHUB_SECRET_TOKEN']
|
23
19
|
end
|
20
|
+
|
21
|
+
def halt_messages
|
22
|
+
{
|
23
|
+
no_client: "Client did not send a signature",
|
24
|
+
no_server: "Server secret token is not configured",
|
25
|
+
mismatch: "Signature mismatch"
|
26
|
+
}
|
27
|
+
end
|
24
28
|
end
|
25
29
|
end
|
data/lib/load_runner/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loadrunner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -164,6 +164,20 @@ dependencies:
|
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '2.0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rack-test
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0.7'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0.7'
|
167
181
|
description: Run your GitHub webhook server and Send simulated github events
|
168
182
|
email: db@dannyben.com
|
169
183
|
executables:
|
@@ -196,7 +210,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
196
210
|
requirements:
|
197
211
|
- - ">="
|
198
212
|
- !ruby/object:Gem::Version
|
199
|
-
version: 2.
|
213
|
+
version: 2.3.0
|
200
214
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
201
215
|
requirements:
|
202
216
|
- - ">="
|