redsquare 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/redsquare/app.rb +2 -0
- data/lib/redsquare/config.rb +8 -0
- data/lib/redsquare/version.rb +1 -1
- data/spec/app_spec.rb +14 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ac3a33efd6022077555a6159f9dfc6ce4e337ba
|
4
|
+
data.tar.gz: d7a4e5c17dad56350c10e88ac4dc4fb784985c9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
data/lib/redsquare/app.rb
CHANGED
@@ -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
|
data/lib/redsquare/config.rb
CHANGED
data/lib/redsquare/version.rb
CHANGED
data/spec/app_spec.rb
CHANGED
@@ -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
|