redis_object 1.2.9 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/redis_object/ext/sanitization.rb +59 -0
- data/lib/redis_object/ext/view_caching.rb +2 -1
- data/lib/redis_object/version.rb +1 -1
- data/spec/sanitization_spec.rb +43 -0
- data/spec/timestamp_spec.rb +1 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWYwNDNkM2UyZWQxZTI0ZjA5MzhlNDlhNjhmMWQxNTY4NGJiYzhmNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDQ1ZGQ4MTVkYjI2NmExYWY5Yzk0ZGE4ZTQ0M2RkNzMxZGRjYTNkOA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODY4MGU5YmQwMDhjMTRjNzEzNmE0NjBhMjhlZDQwMTcyNDc1YTdiZDk0YzJh
|
10
|
+
ZDEyOGJiMGE3NWQwNmU5ZTZmYzU0NGU3ZmUxNTdhYjAzNzM1MjkyN2ZjODRi
|
11
|
+
MmMzM2VhMWY1NTQ5ODBkNzFmNTc2NDZmZjMxYTA0YmVhNGU4MGQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTU5OTE4ODYyMDU1ZDE5Zjg0NGYxOGI1ZmE0NjUwMjU2ZDk3MWZkYjAxOGI3
|
14
|
+
Y2M3ZWEwZDcwODc2ODExMDY1MjQxMWQxOGQxZjZmNTZkZmE1ZTU2NDlhNDc3
|
15
|
+
MjI2MmQ1ZTQxZjFlOGZkOWZiOGZiNzY0NDUxOWU4NWUxODcwNmM=
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Seabright
|
2
|
+
module Sanitization
|
3
|
+
|
4
|
+
module ClassMethods
|
5
|
+
|
6
|
+
def named_sanitization(name,*flds)
|
7
|
+
named_sanitizations[name.to_sym] = flds
|
8
|
+
add_sanitization_methods!
|
9
|
+
end
|
10
|
+
|
11
|
+
def add_sanitization_methods!
|
12
|
+
return if @add_sanitization_methods
|
13
|
+
self.class_eval do
|
14
|
+
|
15
|
+
def sanitize_by_name!(name)
|
16
|
+
if flds = self.class.named_sanitizations[name.to_sym]
|
17
|
+
flog = Set.new
|
18
|
+
flds.each do |fld|
|
19
|
+
if is_set?(fld)
|
20
|
+
unset(fld)
|
21
|
+
flog << fld
|
22
|
+
end
|
23
|
+
end
|
24
|
+
sanitize_log(:one_time,*flog)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
@add_sanitization_methods = true
|
30
|
+
end
|
31
|
+
|
32
|
+
def named_sanitizations
|
33
|
+
@named_sanitizations ||= {}
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
def sanitize!(*flds)
|
39
|
+
flog = Set.new
|
40
|
+
flds.each do |fld|
|
41
|
+
if is_set?(fld)
|
42
|
+
unset(fld)
|
43
|
+
flog << fld
|
44
|
+
end
|
45
|
+
end
|
46
|
+
sanitize_log(:one_time,*flog)
|
47
|
+
end
|
48
|
+
|
49
|
+
def sanitize_log(name,*flds)
|
50
|
+
set(:last_sanitized, Time.now)
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.included(base)
|
54
|
+
base.send(:date, :last_sanitized)
|
55
|
+
base.extend(ClassMethods)
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
@@ -139,6 +139,7 @@ module Seabright
|
|
139
139
|
return unless invalidations(:up).size > 0
|
140
140
|
puts "Invalidating upstream: #{invalidations(:up).inspect}" if Debug.verbose?
|
141
141
|
backreferences.each do |obj|
|
142
|
+
obj = Object.const_get(obj) if obj.is_a?(String) or obj.is_a?(Symbol)
|
142
143
|
if invalidations(:up).include?(obj.class) and obj.respond_to?(:invalidated_by_other)
|
143
144
|
obj.invalidated_by_other(self,invalidation_chain + [self.hkey])
|
144
145
|
end
|
@@ -250,7 +251,7 @@ module Seabright
|
|
250
251
|
when RedisObject
|
251
252
|
name.collection_name
|
252
253
|
when String, Symbol
|
253
|
-
name.to_s.pluralize
|
254
|
+
name.to_s.pluralize.underscore.to_sym
|
254
255
|
else
|
255
256
|
name
|
256
257
|
end
|
data/lib/redis_object/version.rb
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
require 'redis_object/ext/sanitization'
|
4
|
+
|
5
|
+
module TriggerSpec
|
6
|
+
|
7
|
+
class SensitiveObject < RedisObject
|
8
|
+
|
9
|
+
include Seabright::Sanitization
|
10
|
+
|
11
|
+
date :test
|
12
|
+
bool :yay
|
13
|
+
json :stuff
|
14
|
+
|
15
|
+
named_sanitization :burn, :test, :yay
|
16
|
+
end
|
17
|
+
|
18
|
+
describe Seabright::Triggers do
|
19
|
+
before do
|
20
|
+
RedisObject.store.flushdb
|
21
|
+
@secret = SensitiveObject.create(test: Time.now, yay: true, stuff: {test: "1"}, worthless: "yup", sup: "dawg")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "can sanitize a field or two willy nilly" do
|
25
|
+
|
26
|
+
@secret.stuff.should be_a(Hash)
|
27
|
+
@secret.sanitize! :stuff, :sup
|
28
|
+
@secret.stuff.should eq(nil)
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
it "can sanitize by name" do
|
33
|
+
|
34
|
+
@secret.test.should_not eq(nil)
|
35
|
+
@secret.yay.should eq(true)
|
36
|
+
@secret.sanitize_by_name! :burn
|
37
|
+
@secret.test.should eq(nil)
|
38
|
+
@secret.yay.should eq(false)
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
data/spec/timestamp_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis_object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Bragg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: utf8_utils
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- lib/redis_object/ext/benchmark.rb
|
105
105
|
- lib/redis_object/ext/cleaner.rb
|
106
106
|
- lib/redis_object/ext/filters.rb
|
107
|
+
- lib/redis_object/ext/sanitization.rb
|
107
108
|
- lib/redis_object/ext/script_cache.rb
|
108
109
|
- lib/redis_object/ext/shardable.rb
|
109
110
|
- lib/redis_object/ext/triggers.rb
|
@@ -140,6 +141,7 @@ files:
|
|
140
141
|
- spec/filters_spec.rb
|
141
142
|
- spec/indices_spec.rb
|
142
143
|
- spec/rename_class_spec.rb
|
144
|
+
- spec/sanitization_spec.rb
|
143
145
|
- spec/script_cache_spec.rb
|
144
146
|
- spec/spec_helper.rb
|
145
147
|
- spec/timestamp_spec.rb
|
@@ -182,6 +184,7 @@ test_files:
|
|
182
184
|
- spec/filters_spec.rb
|
183
185
|
- spec/indices_spec.rb
|
184
186
|
- spec/rename_class_spec.rb
|
187
|
+
- spec/sanitization_spec.rb
|
185
188
|
- spec/script_cache_spec.rb
|
186
189
|
- spec/spec_helper.rb
|
187
190
|
- spec/timestamp_spec.rb
|