redsquare 0.1.2 → 0.2.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
  SHA1:
3
- metadata.gz: a033f99e75b30bf2e87811348baa30bd1004d7f8
4
- data.tar.gz: df45f16bab78413de85fca722dc830afa5b77a83
3
+ metadata.gz: 8ac3a33efd6022077555a6159f9dfc6ce4e337ba
4
+ data.tar.gz: d7a4e5c17dad56350c10e88ac4dc4fb784985c9b
5
5
  SHA512:
6
- metadata.gz: 8130f86e465fbd7d4474dd55e3bea47a37b10cff9babb458b92f676484b21ed4bbf50ff545b326ccee4e6f8610158c62ad539000838ac449cac935e083e87979
7
- data.tar.gz: 3a8af44fcc4ad34f6bc22415486e7f358460a717ae33d41ad57ae76b39f20688aabcf1b9c66c0c4f6e6da84f35ff92a1e5b647a450ec0f6d044a6936f52cb75a
6
+ metadata.gz: 76e74fecc5a12c2cff7aad2c511309ee4cf6051d1256b0225d03615f309ac2b9715ad41accfe99686800ae08522ad53cbace3cad6b6eddf2c16cb74a4f76457d
7
+ data.tar.gz: 2e7eb78d0d244e4b37bdb7b9cc9ed1df6784e0f698dea994ba32ac33fd2fcd0cafefb7fb71876bc75cd92be8215e709e628144044271dd491757cc885d312b0d
data/README.md CHANGED
@@ -35,6 +35,10 @@ Redsquare.configure do |config|
35
35
  # pass a config hash that will be passed to Redis.new
36
36
  config.redis = { :host => 'localhost', :port => 6379 }
37
37
 
38
+ # indicate redis methods that should not be supported, calls
39
+ # to these methods results in a 404
40
+ config.restricted_methods = [:keys, :dbsize]
41
+
38
42
  end
39
43
  ```
40
44
 
@@ -79,6 +79,7 @@ module Redsquare
79
79
 
80
80
  POST_COMMANDS.each do |command|
81
81
  post "/#{command}" do
82
+ return 404 if Config.restricted_methods.include?(command)
82
83
  content_type :json
83
84
  args = params[:args].map { |a| try_to_i a }
84
85
  val = Config.redis.send command, *args
@@ -88,6 +89,7 @@ module Redsquare
88
89
 
89
90
  GET_COMMANDS.each do |command|
90
91
  get "/#{command}/?*" do
92
+ return 404 if Config.restricted_methods.include?(command)
91
93
  content_type :json
92
94
  args = params[:splat][0].split("/").map { |a| try_to_i a }
93
95
  val = Config.redis.send command, *args
@@ -14,5 +14,13 @@ module Redsquare
14
14
  @redis ||= Redis.current
15
15
  end
16
16
 
17
+ def restricted_methods
18
+ @restricted_methods || []
19
+ end
20
+
21
+ def restricted_methods=(methods)
22
+ @restricted_methods = methods
23
+ end
24
+
17
25
  end
18
26
  end
@@ -1,3 +1,3 @@
1
1
  module Redsquare
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -194,4 +194,18 @@ describe Redsquare::App do
194
194
 
195
195
  end
196
196
 
197
+ describe "config" do
198
+
199
+ describe "restricted_methods" do
200
+
201
+ it "prevents the method from being exposed" do
202
+ Redsquare::Config.restricted_methods = [:keys]
203
+ post "/keys"
204
+ expect(last_response.status).to eq 404
205
+ end
206
+
207
+ end
208
+
209
+ end
210
+
197
211
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redsquare
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JC Grubbs