sensu-plugins-aws 11.0.0 → 11.1.0

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
  SHA256:
3
- metadata.gz: cf38e747e9eacaf74e5266c61fb6425729e033b72258e95a97c2c2c3bfafaa6e
4
- data.tar.gz: ac749130f70447fc122f00613424793ea1f699184bccc1bee71de020a75c0c84
3
+ metadata.gz: 52c7355c7f130cafcc95d18c1156cac80d9792cb241098c61f9068443c3a11fd
4
+ data.tar.gz: b6e0d9e624ccf1e0069df968c1a75d6a328f7f92e3163957c92f01189124e7c0
5
5
  SHA512:
6
- metadata.gz: 88e750cb8957949dcf0d9d235f182e5327841b9dac8aa0fe53689012a2a7dbd6c49d4f5591d95284175d45aaff0a66115b7569ba4e7bcd05841937a348598447
7
- data.tar.gz: b923084b699ebb9a26ac5e11632573a79d9ff432b6de1b5434d2ca027283d017ae611517981b6656435bf5a5f7d83232c39e4fc44dfc1fdac63db71b185c1854
6
+ metadata.gz: 580a14d2aa95d515887acff5bd11bd22db1b5af2aa26afcd335cfb04509e48fd3c83c5596f83b718319370a56f2ef39f9f314f811a7d58a6d8c81a9e1f3a6a58
7
+ data.tar.gz: e680f5379849fcba56dd0864bb8bac02f0c29d6eae2723315cbb246ee4e4fc8553162c5d86916cb9bf5d2d29c7a2a971a88e5326a56d714c16e25acec0522ed6
data/CHANGELOG.md CHANGED
@@ -5,6 +5,14 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [11.0.0] - 2018-11-21
9
+ ### Added
10
+ - check-s3-bucket-visibility.rb: added option `--all-buckets` to check for all buckets in the region specified for insecure buckets (@majormoses)
11
+ - check-s3-bucket-visibility.rb: added option `--excluded-buckets` to ignore specific buckets that are expected to be loose such as s3 buckets for static website hosting (@majormoses)
12
+
13
+ ### Changed
14
+ - check-s3-bucket-visibility.rb: now uses `aws-sdk-s3` while keeping other plugins locked at their respective versions (@majormoses)
15
+
8
16
  ## [11.0.0] - 2018-02-09
9
17
  ### Breaking Changes
10
18
  - metrics-elb-full.rb: removed in favor of metrics-elb.rb, which is slightly more configurable and uses the AWS-SDK v2 already. Compared to metrics-elb-full.rb, metrics-elb.rb no longer takes --aws-access-key, --aws-secret-access-key flags, Authentication should be configured per [here](https://github.com/sensu-plugins/sensu-plugins-aws/blob/master/README.md#authentication). --scheme has a default value of `elb` now (@multani)
@@ -436,7 +444,8 @@ WARNING: This release contains major breaking changes that will impact all user
436
444
  ### Added
437
445
  - initial release
438
446
 
439
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/11.0.0...HEAD
447
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/11.1.0...HEAD
448
+ [11.1.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/11.0.0...11.1.0
440
449
  [11.0.0]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/10.2.0...11.0.0
441
450
  [10.2.0]:https://github.com/sensu-plugins/sensu-plugins-aws/compare/10.1.2...10.2.0
442
451
  [10.1.2]: https://github.com/sensu-plugins/sensu-plugins-aws/compare/10.1.1...10.1.2
@@ -29,7 +29,7 @@
29
29
  # for details.
30
30
  #
31
31
 
32
- require 'aws-sdk'
32
+ require 'aws-sdk-s3'
33
33
  require 'sensu-plugin/check/cli'
34
34
  require 'sensu-plugins-aws'
35
35
 
@@ -44,7 +44,21 @@ class CheckS3Bucket < Sensu::Plugin::Check::CLI
44
44
  option :bucket_names,
45
45
  short: '-b BUCKET_NAMES',
46
46
  long: '--bucket-names',
47
- description: 'A comma seperated list of S3 buckets to check'
47
+ description: 'A comma seperated list of S3 buckets to check',
48
+ proc: proc { |b| b.split(',') }
49
+
50
+ option :all_buckets,
51
+ short: '-a BOOL',
52
+ long: '--all-buckets BOOL',
53
+ description: 'If all buckets are true it will look at any buckets that we have access to in the region',
54
+ boolean: true,
55
+ default: false
56
+
57
+ option :exclude_buckets,
58
+ short: '-e EXCLUDED_BUCKETS_COMMA_SEPERATED',
59
+ long: '--excluded-buckets EXCLUDED_BUCKETS_COMMA_SEPERATED',
60
+ description: 'A comma seperated list of buckets to ignore that are expected to have loose permissions',
61
+ proc: proc { |b| b.split(',') }
48
62
 
49
63
  option :critical_on_missing,
50
64
  short: '-m ',
@@ -60,6 +74,26 @@ class CheckS3Bucket < Sensu::Plugin::Check::CLI
60
74
  @s3_client ||= Aws::S3::Client.new
61
75
  end
62
76
 
77
+ def s3_resource
78
+ @s3_resource || Aws::S3::Resource.new
79
+ end
80
+
81
+ def list_buckets
82
+ buckets = []
83
+ s3_resource.buckets.each do |bucket|
84
+ if s3_resource.client.get_bucket_location(bucket: bucket.name).location_constraint == config[:aws_region]
85
+ buckets << bucket.name
86
+ else
87
+ p "skipping bucket: #{bucket.name} as is not in the region specified: #{config[:aws_region]}"
88
+ end
89
+ end
90
+ buckets
91
+ end
92
+
93
+ def excluded_bucket?(bucket_name)
94
+ config[:exclude_buckets].include?(bucket_name)
95
+ end
96
+
63
97
  def website_configuration?(bucket_name)
64
98
  s3_client.get_bucket_website(bucket: bucket_name)
65
99
  true
@@ -88,9 +122,19 @@ class CheckS3Bucket < Sensu::Plugin::Check::CLI
88
122
  def run
89
123
  errors = []
90
124
  warnings = []
91
- buckets = config[:bucket_names].split ','
125
+ buckets = if config[:all_buckets]
126
+ list_buckets
127
+ elsif config[:bucket_names] && !config[:bucket_names].empty?
128
+ config[:bucket_names]
129
+ else
130
+ unknown 'you must specify either all buckets or provide list of buckets'
131
+ end
92
132
 
93
133
  buckets.each do |bucket_name|
134
+ if excluded_bucket?(bucket_name)
135
+ p "bucket_name: #{bucket_name} was ignored as it matched excluded_buckets"
136
+ next
137
+ end
94
138
  begin
95
139
  if website_configuration?(bucket_name)
96
140
  errors.push "#{bucket_name}: website configuration found"
@@ -98,7 +142,7 @@ class CheckS3Bucket < Sensu::Plugin::Check::CLI
98
142
  if policy_too_permissive?(get_bucket_policy(bucket_name))
99
143
  errors.push "#{bucket_name}: bucket policy too permissive"
100
144
  end
101
- rescue Aws::S3::Errors::NoSuchBucket => _
145
+ rescue Aws::S3::Errors::NoSuchBucket
102
146
  mesg = "Bucket #{bucket_name} not found"
103
147
  true?(config[:critical_on_missing]) ? errors.push(mesg) : warnings.push(mesg)
104
148
  end
@@ -1,7 +1,7 @@
1
1
  module SensuPluginsAWS
2
2
  module Version
3
3
  MAJOR = 11
4
- MINOR = 0
4
+ MINOR = 1
5
5
  PATCH = 0
6
6
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 11.0.0
4
+ version: 11.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Plugins and contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-09 00:00:00.000000000 Z
11
+ date: 2018-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.10'
33
+ version: '3.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.10'
40
+ version: '3.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: aws-sdk-v1
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -445,7 +445,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
445
445
  version: '0'
446
446
  requirements: []
447
447
  rubyforge_project:
448
- rubygems_version: 2.7.5
448
+ rubygems_version: 2.7.6
449
449
  signing_key:
450
450
  specification_version: 4
451
451
  summary: Sensu plugins for working with an AWS environment