logstash-input-github 0.1.1
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 +7 -0
- data/Gemfile +3 -0
- data/LICENSE +13 -0
- data/README.md +35 -0
- data/Rakefile +7 -0
- data/lib/logstash/inputs/github.rb +67 -0
- data/logstash-input-github.gemspec +29 -0
- data/spec/inputs/github_spec.rb +1 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cf160ba21f59728088732f05133fb4eae72a12c7
|
4
|
+
data.tar.gz: bdf4ce1d331a87ac66c71d40c6c86e426ed17195
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7498d2b950ebc1df425e1026a299f18103e7c65036d4cb76e2885f98ced5ec5138e088b4a182609475fbd5adeb710a87590fa10852552dfb345014458dad2f3d
|
7
|
+
data.tar.gz: 4611f1b6acf3f195c3f1bd434b90a9d0f54952c6c4fb6b90038deb6675d39da259f0fc0dfd13a65fd75978c362eb95f77a95faaeb8a9438429b8f74ab2dc1374
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (c) 2012-2014 Elasticsearch <http://www.elasticsearch.org>
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
logstash-github
|
2
|
+
===================
|
3
|
+
|
4
|
+
This plugin accepts github webhook connections and passes the data into the logstash pipeline.
|
5
|
+
|
6
|
+
Usage
|
7
|
+
=====
|
8
|
+
|
9
|
+
Example config:
|
10
|
+
|
11
|
+
input {
|
12
|
+
stdin {}
|
13
|
+
github {
|
14
|
+
port => 8080
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
output {
|
19
|
+
stdout {
|
20
|
+
codec => rubydebug
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
Example Test Case using Curl:
|
25
|
+
|
26
|
+
curl -H "Content-Type: application/json" -d '{"Something":"xyz","somethingelse":"xyz"}' http://localhost:8080/api/login
|
27
|
+
|
28
|
+
Configuration
|
29
|
+
=============
|
30
|
+
|
31
|
+
* ip - The IP you want to listen on (Default: 0.0.0.0)
|
32
|
+
* port - The port you want to listen on
|
33
|
+
* secret_token - The shared secret set for github webhook
|
34
|
+
* drop_invalid - Drop events that don't match the secret_token
|
35
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/inputs/base"
|
3
|
+
require "logstash/namespace"
|
4
|
+
require "socket"
|
5
|
+
require "json"
|
6
|
+
require "rack"
|
7
|
+
|
8
|
+
|
9
|
+
# Read events from github webhooks
|
10
|
+
class LogStash::Inputs::GitHub < LogStash::Inputs::Base
|
11
|
+
config_name "github"
|
12
|
+
milestone 1
|
13
|
+
|
14
|
+
# The ip to listen on
|
15
|
+
config :ip, :validate => :string, :default => "0.0.0.0"
|
16
|
+
|
17
|
+
# The port to listen on
|
18
|
+
config :port, :validate => :number, :required => true
|
19
|
+
|
20
|
+
# Your GitHub Secret Token for the webhook
|
21
|
+
config :secret_token, :validate => :string, :required => false
|
22
|
+
|
23
|
+
# If Secret is defined, we drop the events that don't match.
|
24
|
+
# Otherwise, we'll just add a invalid tag
|
25
|
+
config :drop_invalid, :validate => :boolean
|
26
|
+
|
27
|
+
def register
|
28
|
+
require "ftw"
|
29
|
+
end # def register
|
30
|
+
|
31
|
+
public
|
32
|
+
def run(output_queue)
|
33
|
+
@server = FTW::WebServer.new(@ip, @port) do |request, response|
|
34
|
+
body = request.read_body
|
35
|
+
begin
|
36
|
+
event = LogStash::Event.new(JSON.parse(body))
|
37
|
+
rescue JSON::ParserError => e
|
38
|
+
@logger.info("JSON parse failure. Falling back to plain-text", :error => e, :data => body)
|
39
|
+
event = LogStash::Event.new("message" => body, "tags" => "_invalidjson")
|
40
|
+
end
|
41
|
+
event['headers'] = request.headers.to_hash
|
42
|
+
if defined? @secret_token and event['headers']['x-hub-signature']
|
43
|
+
event['hash'] = 'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), @secret_token, body)
|
44
|
+
if not Rack::Utils.secure_compare(event['hash'], event['headers']['x-hub-signature'])
|
45
|
+
if not @drop_invalid
|
46
|
+
event['tags'] = "_Invalid_Github_Message"
|
47
|
+
else
|
48
|
+
@logger.info("Dropping invalid Github message")
|
49
|
+
drop = true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
if not drop
|
54
|
+
decorate(event)
|
55
|
+
output_queue << event
|
56
|
+
end
|
57
|
+
response.status = 200
|
58
|
+
response.body = "Accepted!"
|
59
|
+
end
|
60
|
+
@server.run
|
61
|
+
end # def run
|
62
|
+
|
63
|
+
def teardown
|
64
|
+
@server.stop
|
65
|
+
end # def teardown
|
66
|
+
|
67
|
+
end # class LogStash::Inputs::Github
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
|
3
|
+
s.name = 'logstash-input-github'
|
4
|
+
s.version = '0.1.1'
|
5
|
+
s.licenses = ['Apache License (2.0)']
|
6
|
+
s.summary = "Accept events from github webhooks."
|
7
|
+
s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
|
8
|
+
s.authors = ["Elasticsearch"]
|
9
|
+
s.email = 'jason.kendall@elasticsearch.com'
|
10
|
+
s.homepage = "http://www.elasticsearch.org/guide/en/logstash/current/index.html"
|
11
|
+
s.require_paths = ["lib"]
|
12
|
+
|
13
|
+
# Files
|
14
|
+
s.files = `git ls-files`.split($\)+::Dir.glob('vendor/*')
|
15
|
+
|
16
|
+
# Tests
|
17
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
18
|
+
|
19
|
+
# Special flag to let us know this is actually a logstash plugin
|
20
|
+
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
|
21
|
+
|
22
|
+
# Gem dependencies
|
23
|
+
s.add_runtime_dependency 'logstash', '>= 1.4.0', '< 2.0.0'
|
24
|
+
|
25
|
+
s.add_runtime_dependency 'addressable'
|
26
|
+
|
27
|
+
s.add_development_dependency 'logstash-devutils'
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
# Empty
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logstash-input-github
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Elasticsearch
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: logstash
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.4.0
|
20
|
+
- - <
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.0.0
|
23
|
+
requirement: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 1.4.0
|
28
|
+
- - <
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 2.0.0
|
31
|
+
prerelease: false
|
32
|
+
type: :runtime
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: addressable
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirement: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
prerelease: false
|
46
|
+
type: :runtime
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: logstash-devutils
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
prerelease: false
|
60
|
+
type: :development
|
61
|
+
description: This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program
|
62
|
+
email: jason.kendall@elasticsearch.com
|
63
|
+
executables: []
|
64
|
+
extensions: []
|
65
|
+
extra_rdoc_files: []
|
66
|
+
files:
|
67
|
+
- Gemfile
|
68
|
+
- LICENSE
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- lib/logstash/inputs/github.rb
|
72
|
+
- logstash-input-github.gemspec
|
73
|
+
- spec/inputs/github_spec.rb
|
74
|
+
homepage: http://www.elasticsearch.org/guide/en/logstash/current/index.html
|
75
|
+
licenses:
|
76
|
+
- Apache License (2.0)
|
77
|
+
metadata:
|
78
|
+
logstash_plugin: 'true'
|
79
|
+
logstash_group: input
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.2.2
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: Accept events from github webhooks.
|
100
|
+
test_files:
|
101
|
+
- spec/inputs/github_spec.rb
|