cloak-rb 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2398d4e9c6598ab9bc282e3a4ac5d84bd4a7c6ac168b02018432aebdd1ef59f0
4
- data.tar.gz: 0d5ccd2205af4e50a089f36a1e93b78825f18fa6945aa2202d9b361ccf33d093
3
+ metadata.gz: 2d80e7f19050d768a2f33ca148e7a7b177dc0bb3d09051005000a0b34f5286c4
4
+ data.tar.gz: b724ed183653e3d07d38d6139123ac2681a418c6734aff608b386ade5a5d0a63
5
5
  SHA512:
6
- metadata.gz: 5e0f4ea4ccd8f082390ea2111e7788fab4961038bcfce70f647b7585a0806733c38266d282f0366f9315aa6cbc9ceb5bcfd91dbd162f0239250823ac9cf2f54c
7
- data.tar.gz: debb76ae8864205d3a1363dbb56dfc24d09bb20242184a76a0541c82a24446b2f63eb3e27f0c9fe578b22cfb8c56f39a41b5cd2e164b968a882821d027e1ca69
6
+ metadata.gz: 291b97787047627d1ade5f3e4a5be46bf1f13132cc0cff6d3f154f17c9707b451d8117199826a5a2b77edc2190b77d6ca7d63ada6327c93cdfe734c574a35951
7
+ data.tar.gz: 45873eed6dc32ac04b5ce11e3a599d3ad72576f826b7a7fead42c98c53222f7842e0fd1636cce1154f7e2d43e7d4e7eb560a5d456074d9e5866f91af444b01c3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.1.1 (2022-03-23)
2
+
3
+ - Added error for `pipelined` and `multi` with block parameter
4
+ - Fixed error with `blpop`, `brpop`, `bzpopmin` and `bzpopmax` with version 4.6+ of `redis` gem
5
+
1
6
  ## 0.1.0 (2020-12-14)
2
7
 
3
8
  - First release
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2020 Andrew Kane
3
+ Copyright (c) 2020-2022 Andrew Kane
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -13,7 +13,7 @@ See [technical details](#technical-details) for more info.
13
13
  Add this line to your application’s Gemfile:
14
14
 
15
15
  ```ruby
16
- gem 'cloak-rb'
16
+ gem "cloak-rb"
17
17
  ```
18
18
 
19
19
  ## Getting Started
@@ -51,7 +51,14 @@ Create a client
51
51
  redis = Cloak::Redis.new(key: key)
52
52
  ```
53
53
 
54
- And use it in place of a `Redis` instance. A few methods aren’t supported:
54
+ And use it in place of a `Redis` instance.
55
+
56
+ ```ruby
57
+ redis.set("hello", "world")
58
+ redis.get("hello")
59
+ ```
60
+
61
+ A few methods aren’t supported:
55
62
 
56
63
  - `lrem` since encrypted list elements aren’t comparable
57
64
  - `setrange`, `setbit`, `append`, and `bitop` since encrypted strings can’t be modified in-place
@@ -68,7 +75,12 @@ Create a client
68
75
  dalli = Cloak::Dalli.new(key: key)
69
76
  ```
70
77
 
71
- And use it in place a `Dalli::Client` instance.
78
+ And use it in place of a `Dalli::Client` instance.
79
+
80
+ ```ruby
81
+ dalli.set("hello", "world")
82
+ dalli.get("hello")
83
+ ```
72
84
 
73
85
  ## Technical Details
74
86
 
data/lib/cloak/redis.rb CHANGED
@@ -10,13 +10,23 @@ module Cloak
10
10
  def_delegators :@redis, :auth, :select, :quit, :bgrewriteaof, :bgsave,
11
11
  :config, :client, :dbsize, :flushall, :flushdb, :info, :lastsave,
12
12
  :monitor, :save, :shutdown, :slaveof, :slowlog, :sync, :time,
13
- :unwatch, :pipelined, :multi, :exec, :discard
13
+ :unwatch, :exec, :discard
14
14
 
15
15
  def initialize(key: nil, **options)
16
16
  @redis = ::Redis.new(**options)
17
17
  create_encryptor(key)
18
18
  end
19
19
 
20
+ def pipelined(&block)
21
+ raise Error, "pipelined with block parameter not supported yet" if block&.arity != 0
22
+ @redis.pipelined(&block)
23
+ end
24
+
25
+ def multi(&block)
26
+ raise Error, "multi with block parameter not supported yet" if block&.arity != 0
27
+ @redis.multi(&block)
28
+ end
29
+
20
30
  def debug(*args)
21
31
  args[1] = encrypt_key(args[1]) if args[0] == "object"
22
32
  @redis.debug(*args)
@@ -739,7 +749,7 @@ module Cloak
739
749
 
740
750
  keys = args.flatten.map { |k| encrypt_key(k) }
741
751
 
742
- on_result(@redis._bpop(cmd, [keys, {timeout: timeout}], &blk)) do |res|
752
+ on_result(@redis.send(:_bpop, cmd, [keys, {timeout: timeout}], &blk)) do |res|
743
753
  if res.nil?
744
754
  res
745
755
  elsif zset
data/lib/cloak/utils.rb CHANGED
@@ -44,14 +44,6 @@ module Cloak
44
44
  @encryptor.open(to_binary(key), nonce: KEY_NONCE)
45
45
  end
46
46
 
47
- def encrypt_field(key, field)
48
- @encryptor.seal(to_binary(field), nonce: key.slice(0, 16))
49
- end
50
-
51
- def decrypt_field(key, field)
52
- @encryptor.open(to_binary(field), nonce: key.slice(0, 16))
53
- end
54
-
55
47
  def encrypt_member(value)
56
48
  @encryptor.seal(to_binary(value), nonce: MEMBER_NONCE)
57
49
  end
@@ -68,6 +60,14 @@ module Cloak
68
60
  @encryptor.open(to_binary(value), nonce: HLL_ELEMENT_NONCE)
69
61
  end
70
62
 
63
+ def encrypt_field(key, field)
64
+ @encryptor.seal(to_binary(field), nonce: key.slice(0, 16))
65
+ end
66
+
67
+ def decrypt_field(key, field)
68
+ @encryptor.open(to_binary(field), nonce: key.slice(0, 16))
69
+ end
70
+
71
71
  def to_binary(value)
72
72
  value = value.to_s
73
73
  value = value.dup.force_encoding(Encoding::BINARY) unless value.encoding == Encoding::BINARY
data/lib/cloak/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cloak
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloak-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-15 00:00:00.000000000 Z
11
+ date: 2022-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: miscreant
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  description:
28
- email: andrew@chartkick.com
28
+ email: andrew@ankane.org
29
29
  executables: []
30
30
  extensions: []
31
31
  extra_rdoc_files: []
@@ -57,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
57
  - !ruby/object:Gem::Version
58
58
  version: '0'
59
59
  requirements: []
60
- rubygems_version: 3.1.4
60
+ rubygems_version: 3.3.7
61
61
  signing_key:
62
62
  specification_version: 4
63
63
  summary: Application-level encryption for Redis and Memcached