monitor_page 0.1.3 → 0.2

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: 451326ea22afa5c979768540e1c19176f3ac239a
4
- data.tar.gz: c0e8f5b62db50491978e5cb1171dc808f04a2e33
3
+ metadata.gz: 611be1f377905d73941412872c95effe32a05a4a
4
+ data.tar.gz: e0e4606e7e9ce28b9db4622262431d9230c954dd
5
5
  SHA512:
6
- metadata.gz: be490ed8025440a848e662fb3c2ec6f85297a1603fff314ca9303c30570485b3412215eb3b1d0abf2becc1865048aca4da7a14403cf9f3ceefa1ccd4f79549ab
7
- data.tar.gz: 91dcd03dac22decfae551db5fd3d094f3bbda4fb6baab0f1a85623bdf8fa827a91a5354d068736f4bac9fd0561bc170975ae2e1a492e4d0c7163b3049c67e12e
6
+ metadata.gz: '097960b0e14a984c162298b0a9a84b2200c9edbc0b3c01f85ddc3137d44420917a8cd8b291d62101f02e16c380f27500ee69ed1c34e6f708d6b1eac920463576'
7
+ data.tar.gz: 529a0d559385d2c0e896597d90c6aaf0522b30010c558f59addb4ead743764554aae7e83bef5d38469a63315dd7edc753957550b3b5fd05358029178bf69e3c4
data/README.md CHANGED
@@ -6,7 +6,9 @@ Create an initializer and setup your checks. Each check should have a `pass` and
6
6
 
7
7
  ```ruby
8
8
  MonitorPage.configure do
9
- permit '1.1.1.1', '1.1.2.2' # optional, will be available everywhere if left out
9
+ # Whitelist IPs that have access to the status page. Can be a single IP or of CIDR notation.
10
+ # Optional: if left out it will be publically available
11
+ permit '1.1.1.1', '1.1.2.0/24'
10
12
 
11
13
  check 'Sidekiq' do
12
14
  if Sidekiq::Queue.all.select{ |q| q.size > 50 }.any?
@@ -5,7 +5,7 @@ module MonitorPage
5
5
  layout 'monitor_page/application'
6
6
 
7
7
  def index
8
- if MonitorPage.allowed_ips && !MonitorPage.allowed_ips.include?(request.remote_ip)
8
+ unless MonitorPage.ip_whitelisted?(request.remote_ip)
9
9
  render html: 'Forbidden' and return
10
10
  end
11
11
 
@@ -1,13 +1,12 @@
1
- module MonitorPage
1
+ require "ipaddr"
2
2
 
3
+ module MonitorPage
3
4
  class Engine < ::Rails::Engine
4
5
  isolate_namespace MonitorPage
5
-
6
6
  end
7
7
 
8
-
9
8
  class << self
10
- attr_accessor :checks, :allowed_ips
9
+ attr_accessor :checks, :whitelisted_ips
11
10
 
12
11
  def checks
13
12
  @checks || []
@@ -22,7 +21,13 @@ module MonitorPage
22
21
  end
23
22
 
24
23
  def permit(ips)
25
- self.allowed_ips = ips.is_a?(String) ? ips.split(/,\s?/) : ips
24
+ ip_ranges = ips.is_a?(String) ? ips.split(/,\s?/) : ips
25
+
26
+ self.whitelisted_ips = ip_ranges.map{|ip| IPAddr.new(ip) }
27
+ end
28
+
29
+ def ip_whitelisted?(request_ip)
30
+ @whitelisted_ips.inject(false){|res,ip| ip.include?(IPAddr.new(request_ip)) or res }
26
31
  end
27
32
  end
28
33
 
@@ -1,3 +1,3 @@
1
1
  module MonitorPage
2
- VERSION = '0.1.3'
2
+ VERSION = '0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monitor_page
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Gooley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-17 00:00:00.000000000 Z
11
+ date: 2019-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails