sensu-plugins-github 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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +14 -14
- data/LICENSE +1 -1
- data/README.md +2 -34
- data/bin/check-user-2fa.rb +104 -0
- data/bin/github-repo-metrics.rb +3 -2
- data/lib/sensu-plugins-github.rb +1 -14
- data/lib/sensu-plugins-github/auth.rb +5 -5
- data/lib/sensu-plugins-github/version.rb +1 -18
- metadata +18 -13
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbd54573fea4cce2e2de2e8db098146ca6e17b6f
|
4
|
+
data.tar.gz: 4b61569c0e93d97e27bfc61ed9c24fac1244a88a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 702750b75c43deb925c12214538a519f6c086f1291fea8a62127dc547e1a000e7282b054d7403435be4f0db43a41c04b4e7cb10454285530dbb54b98aa78759c
|
7
|
+
data.tar.gz: d7eb5ccec49aa290d31950de33426f171ac27c3818b8c9c7c7848c33d22bf25d7d22440b4af8439cd649314f651611a29ed3a2e16f4a5f39469791cd389e0dca
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
* yard doc coverage
|
1
|
+
#Change Log
|
2
|
+
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
3
|
|
5
|
-
|
6
|
-
* initial stable release
|
4
|
+
This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
|
7
5
|
|
8
|
-
|
9
|
-
* add ability to read got token from file
|
6
|
+
## Unreleased][unreleased]
|
10
7
|
|
11
|
-
|
8
|
+
## [0.0.4] - 2015-06-02
|
9
|
+
|
10
|
+
### Added
|
11
|
+
- check-user-2fa.rb
|
12
|
+
- Check to alert upon org users that do not have 2FA enabled
|
13
|
+
### Fixed
|
14
|
+
- added binstubs
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
- removed cruft from /lib
|
12
18
|
|
13
|
-
* add metadata to gems
|
14
|
-
* pin all dev and runtime dependencies
|
15
|
-
* add chef provisioner to Vagrantfile
|
16
|
-
* fix rubocop issues
|
17
|
-
* add new version module
|
18
|
-
* add new version and bump tasks
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
[![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-github/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-github)
|
6
6
|
[![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-github/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-github)
|
7
7
|
[![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-github.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-github)
|
8
|
+
[ ![Codeship Status for sensu-plugins/sensu-plugins-github](https://codeship.com/projects/107b69f0-cabf-0132-6fa6-22c60209e864/status?branch=master)](https://codeship.com/projects/75587)
|
8
9
|
|
9
10
|
## Functionality
|
10
11
|
|
@@ -21,39 +22,6 @@ Your github token must be placed in *~/.ssh/git_token*, you should not be entrin
|
|
21
22
|
|
22
23
|
## Installation
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
```
|
27
|
-
gem cert --add <(curl -Ls https://raw.githubusercontent.com/sensu-plugins/sensu-plugins.github.io/master/certs/sensu-plugins.pem)
|
28
|
-
gem install sensu-plugins-github -P MediumSecurity
|
29
|
-
```
|
30
|
-
|
31
|
-
You can also download the key from /certs/ within each repository.
|
32
|
-
|
33
|
-
#### Rubygems
|
34
|
-
|
35
|
-
`gem install sensu-plugins-github`
|
36
|
-
|
37
|
-
#### Bundler
|
38
|
-
|
39
|
-
Add *sensu-plugins-github* to your Gemfile and run `bundle install` or `bundle update`
|
40
|
-
|
41
|
-
#### Chef
|
42
|
-
|
43
|
-
Using the Sensu **sensu_gem** LWRP
|
44
|
-
```
|
45
|
-
sensu_gem 'sensu-plugins-github' do
|
46
|
-
options('--prerelease')
|
47
|
-
version '0.0.1.alpha.1'
|
48
|
-
end
|
49
|
-
```
|
50
|
-
|
51
|
-
Using the Chef **gem_package** resource
|
52
|
-
```
|
53
|
-
gem_package 'sensu-plugins-github' do
|
54
|
-
options('--prerelease')
|
55
|
-
version '0.0.1.alpha.1'
|
56
|
-
end
|
57
|
-
```
|
25
|
+
[Installation and Setup](https://github.com/sensu-plugins/documentation/blob/master/user_docs/installation_instructions.md)
|
58
26
|
|
59
27
|
## Notes
|
@@ -0,0 +1,104 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-user-2fa.rb
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# Interacts with Github API to generate metrics about repo.
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
#
|
10
|
+
# PLATFORMS:
|
11
|
+
# All
|
12
|
+
#
|
13
|
+
# DEPENDENCIES:
|
14
|
+
# gem: sensu-plugin
|
15
|
+
# gem: rest-client
|
16
|
+
# gem: json
|
17
|
+
#
|
18
|
+
# USAGE:
|
19
|
+
#
|
20
|
+
#
|
21
|
+
# NOTES:
|
22
|
+
#
|
23
|
+
#
|
24
|
+
# LICENSE:
|
25
|
+
# Copyright 2015 Yieldbot, devops@yieldbot.com
|
26
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
27
|
+
# for details.
|
28
|
+
#
|
29
|
+
|
30
|
+
require 'sensu-plugin/check/cli'
|
31
|
+
require 'rest-client'
|
32
|
+
require 'json'
|
33
|
+
|
34
|
+
# $LOAD_PATH.unshift([File.expand_path(File.dirname(__FILE__)), '..', 'lib'].join('/'))
|
35
|
+
# require 'sensu-plugins-github'
|
36
|
+
|
37
|
+
class CheckUser2FA < Sensu::Plugin::Check::CLI
|
38
|
+
option :api,
|
39
|
+
short: '-a URL',
|
40
|
+
long: '--api URL',
|
41
|
+
description: 'Github API URL'
|
42
|
+
|
43
|
+
option :token,
|
44
|
+
short: '-t TOKEN',
|
45
|
+
long: '--token TOKEN',
|
46
|
+
description: 'Github OAuth Token'
|
47
|
+
|
48
|
+
option :org,
|
49
|
+
short: '-o ORG',
|
50
|
+
long: '--org ORG',
|
51
|
+
description: 'Github Org',
|
52
|
+
required: true
|
53
|
+
|
54
|
+
option :exclude,
|
55
|
+
short: '-x E',
|
56
|
+
long: '--exclude-list EXCLUDE_LIST',
|
57
|
+
proc: proc { |a| a.split(/[,;]\s*/) },
|
58
|
+
description: 'List of users to exclude'
|
59
|
+
|
60
|
+
def api_request(resource, api, token) #rubocop:disable all
|
61
|
+
endpoint = api + resource
|
62
|
+
request = RestClient::Resource.new(endpoint, timeout: 30)
|
63
|
+
headers = {}
|
64
|
+
headers[:Authorization] = "token #{ token }"
|
65
|
+
JSON.parse(request.get(headers), symbolize_names: true)
|
66
|
+
rescue RestClient::ResourceNotFound
|
67
|
+
warning "Resource not found (or not accessible): #{resource}"
|
68
|
+
rescue Errno::ECONNREFUSED
|
69
|
+
warning 'Connection refused'
|
70
|
+
rescue RestClient::RequestFailed => e
|
71
|
+
# #YELLOW Better handle github rate limiting case
|
72
|
+
# (with data from e.response.headers)
|
73
|
+
warning "Request failed: #{e.inspect}"
|
74
|
+
rescue RestClient::RequestTimeout
|
75
|
+
warning 'Connection timed out'
|
76
|
+
rescue RestClient::Unauthorized
|
77
|
+
warning 'Missing or incorrect Github API credentials'
|
78
|
+
rescue JSON::ParserError
|
79
|
+
warning 'Github API returned invalid JSON'
|
80
|
+
end
|
81
|
+
|
82
|
+
def run
|
83
|
+
# Set the token from the commandline or read it in from a file. Preference
|
84
|
+
# is given towards the later and at some point it may be enforced.
|
85
|
+
token = config[:token] || SensuPluginsGithub::Auth.acquire_git_token
|
86
|
+
|
87
|
+
# This is the default url and will be fine for most people,
|
88
|
+
# github enterprise customers will have a url based upon the org name and
|
89
|
+
# will need to set it at the commandline.
|
90
|
+
api_url = config[:api] || 'https://api.github.com'
|
91
|
+
|
92
|
+
# List to hold users who do not have 2FA
|
93
|
+
user_list = []
|
94
|
+
|
95
|
+
exclude_list = config[:exclude] || ''
|
96
|
+
|
97
|
+
data = api_request("/orgs/#{config[:org]}/members?filter=2fa_disabled", api_url, token)
|
98
|
+
data.each do |d|
|
99
|
+
user_list << d[:login] unless exclude_list.include?(d[:login])
|
100
|
+
end
|
101
|
+
critical("The following users don't have 2FA enabled: #{ user_list }") unless user_list == []
|
102
|
+
ok
|
103
|
+
end
|
104
|
+
end
|
data/bin/github-repo-metrics.rb
CHANGED
@@ -14,7 +14,6 @@
|
|
14
14
|
# DEPENDENCIES:
|
15
15
|
# gem: sensu-plugin
|
16
16
|
# gem: rest-client
|
17
|
-
# gem: json
|
18
17
|
#
|
19
18
|
# USAGE:
|
20
19
|
#
|
@@ -31,7 +30,9 @@
|
|
31
30
|
require 'sensu-plugin/metric/cli'
|
32
31
|
require 'rest-client'
|
33
32
|
require 'json'
|
34
|
-
|
33
|
+
|
34
|
+
# $:.unshift([File.expand_path(File.dirname(__FILE__)), '..', 'lib'].join('/'))
|
35
|
+
# require 'sensu-plugins-github'
|
35
36
|
|
36
37
|
#
|
37
38
|
# AggregateMetrics
|
data/lib/sensu-plugins-github.rb
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# Acquire auth for Github
|
3
3
|
#
|
4
4
|
module SensuPluginsGithub
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
module Auth
|
6
|
+
def self.acquire_git_token
|
7
|
+
File.readlines(File.expand_path('~/.ssh/git_token')).each do |line|
|
8
|
+
@github_token = line
|
9
|
+
end
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -1,28 +1,11 @@
|
|
1
1
|
require 'json'
|
2
2
|
|
3
|
-
# encoding: utf-8
|
4
3
|
module SensuPluginsGithub
|
5
|
-
# This defines the version of the gem
|
6
4
|
module Version
|
7
5
|
MAJOR = 0
|
8
6
|
MINOR = 0
|
9
|
-
PATCH =
|
7
|
+
PATCH = 4
|
10
8
|
|
11
9
|
VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
|
12
|
-
|
13
|
-
NAME = 'sensu-plugins-github'
|
14
|
-
BANNER = "#{NAME} v%s"
|
15
|
-
|
16
|
-
module_function
|
17
|
-
|
18
|
-
def version
|
19
|
-
format(BANNER, VER_STRING)
|
20
|
-
end
|
21
|
-
|
22
|
-
def json_version
|
23
|
-
{
|
24
|
-
'version' => VER_STRING
|
25
|
-
}.to_json
|
26
|
-
end
|
27
10
|
end
|
28
11
|
end
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-github
|
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
|
+
- Sensu Plugins and contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain:
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
|
31
31
|
HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2015-
|
33
|
+
date: 2015-06-03 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: json
|
@@ -92,16 +92,16 @@ dependencies:
|
|
92
92
|
name: rubocop
|
93
93
|
requirement: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- -
|
95
|
+
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: 0.
|
97
|
+
version: '0.30'
|
98
98
|
type: :development
|
99
99
|
prerelease: false
|
100
100
|
version_requirements: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- -
|
102
|
+
- - "~>"
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: 0.
|
104
|
+
version: '0.30'
|
105
105
|
- !ruby/object:Gem::Dependency
|
106
106
|
name: rspec
|
107
107
|
requirement: !ruby/object:Gem::Requirement
|
@@ -200,15 +200,18 @@ dependencies:
|
|
200
200
|
- - "~>"
|
201
201
|
- !ruby/object:Gem::Version
|
202
202
|
version: '0.10'
|
203
|
-
description: Sensu plugins for
|
203
|
+
description: Sensu plugins for Github
|
204
204
|
email: "<sensu-users@googlegroups.com>"
|
205
|
-
executables:
|
205
|
+
executables:
|
206
|
+
- github-repo-metrics.rb
|
207
|
+
- check-user-2fa.rb
|
206
208
|
extensions: []
|
207
209
|
extra_rdoc_files: []
|
208
210
|
files:
|
209
211
|
- CHANGELOG.md
|
210
212
|
- LICENSE
|
211
213
|
- README.md
|
214
|
+
- bin/check-user-2fa.rb
|
212
215
|
- bin/github-repo-metrics.rb
|
213
216
|
- lib/sensu-plugins-github.rb
|
214
217
|
- lib/sensu-plugins-github/auth.rb
|
@@ -220,7 +223,10 @@ metadata:
|
|
220
223
|
maintainer: "@mattyjones"
|
221
224
|
development_status: active
|
222
225
|
production_status: unstable - testing recommended
|
223
|
-
|
226
|
+
release_draft: 'false'
|
227
|
+
release_prerelease: 'false'
|
228
|
+
post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
|
229
|
+
in /etc/default/sensu
|
224
230
|
rdoc_options: []
|
225
231
|
require_paths:
|
226
232
|
- lib
|
@@ -236,9 +242,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
236
242
|
version: '0'
|
237
243
|
requirements: []
|
238
244
|
rubyforge_project:
|
239
|
-
rubygems_version: 2.
|
245
|
+
rubygems_version: 2.4.6
|
240
246
|
signing_key:
|
241
247
|
specification_version: 4
|
242
|
-
summary: Sensu plugins for
|
248
|
+
summary: Sensu plugins for Github
|
243
249
|
test_files: []
|
244
|
-
has_rdoc:
|
metadata.gz.sig
CHANGED
Binary file
|