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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b2a98a86e37ca184e0c311ef0012973d34b659f2
4
- data.tar.gz: 020580b54cdee2229aa93be4b00858d9393420bc
3
+ metadata.gz: bbd54573fea4cce2e2de2e8db098146ca6e17b6f
4
+ data.tar.gz: 4b61569c0e93d97e27bfc61ed9c24fac1244a88a
5
5
  SHA512:
6
- metadata.gz: ebd13d377633b2b4b50bd75b45b9dab5a00baf37837d844d2d8fb657b41294003e4305615c855aed6dfc678ad97af5435104929dc1b8639e18d7a04a00d835fb
7
- data.tar.gz: ea688c7065d0456b3d0236b269a421ee2eaca27b5fa846cd3bc6fea7aee6b5a1d6b137e179cdd7b8c3808af89c7a4df946ea293feec5992c559997ff471b7f7a
6
+ metadata.gz: 702750b75c43deb925c12214538a519f6c086f1291fea8a62127dc547e1a000e7282b054d7403435be4f0db43a41c04b4e7cb10454285530dbb54b98aa78759c
7
+ data.tar.gz: d7eb5ccec49aa290d31950de33426f171ac27c3818b8c9c7c7848c33d22bf25d7d22440b4af8439cd649314f651611a29ed3a2e16f4a5f39469791cd389e0dca
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,18 +1,18 @@
1
- #### 0.0.1.alpha.1
2
- * baseline release, code is identical to the community repo
3
- * yard doc coverage
1
+ #Change Log
2
+ This project adheres to [Semantic Versioning](http://semver.org/).
4
3
 
5
- #### 0.0.1
6
- * initial stable release
4
+ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
7
5
 
8
- #### 0.0.2
9
- * add ability to read got token from file
6
+ ## Unreleased][unreleased]
10
7
 
11
- #### 0.0.3
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
@@ -1,4 +1,4 @@
1
- Copyright (c) 2015 devops@yieldbot.com
1
+ Copyright (c) 2015 Sensu-Plugins
2
2
 
3
3
  MIT License
4
4
 
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
- Add the public key (if you haven’t already) as a trusted certificate
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
@@ -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
- require 'sensu-plugins-github/auth'
33
+
34
+ # $:.unshift([File.expand_path(File.dirname(__FILE__)), '..', 'lib'].join('/'))
35
+ # require 'sensu-plugins-github'
35
36
 
36
37
  #
37
38
  # AggregateMetrics
@@ -1,15 +1,2 @@
1
-
2
1
  require 'sensu-plugins-github/version'
3
-
4
- # Load the defaults
5
-
6
- #
7
- # Default class
8
- #
9
- module SensuPluginsGithub
10
- class << self
11
- end
12
-
13
- class << self
14
- end
15
- end
2
+ require 'sensu-plugins-github/auth'
@@ -2,11 +2,11 @@
2
2
  # Acquire auth for Github
3
3
  #
4
4
  module SensuPluginsGithub
5
- def self.acquire_git_token
6
- File.readlines(File.expand_path('~/.ssh/git_token')).each do |line|
7
- @github_token = line
8
- puts line
9
- return line
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 = 3
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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
- - Yieldbot, Inc. and contributors
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-04-02 00:00:00.000000000 Z
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.17.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.17.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 working with Github
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
- post_install_message:
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.2.2
245
+ rubygems_version: 2.4.6
240
246
  signing_key:
241
247
  specification_version: 4
242
- summary: Sensu plugins for working with Github
248
+ summary: Sensu plugins for Github
243
249
  test_files: []
244
- has_rdoc:
metadata.gz.sig CHANGED
Binary file