safer_redis 1.0.0 → 1.1.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/CHANGELOG.md +4 -0
- data/Gemfile.lock +4 -3
- data/lib/safer_redis/command_doc.rb +4 -0
- data/lib/safer_redis/danger.rb +7 -0
- data/lib/safer_redis/suggestion.rb +21 -0
- data/lib/safer_redis/version.rb +1 -1
- data/lib/safer_redis.rb +7 -1
- metadata +4 -4
- data/safer_redis.gemspec +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b398837bfdbe584e367b80c02a881ebd6a9b2c975efc3aa4e36184530306cad
|
4
|
+
data.tar.gz: d3adf217f7f8df1a0bda2b1e33335cab5d5733609820f5ae1ac6b60634d94cd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba297615b774f407a5999a2454c0941a8dc492a9c8a9a2f221eabf8f60cdf4e4f6804cb1009fa04fd9131a1ea332eb9872fc7b5222adb89e1b4c61d2aec71575
|
7
|
+
data.tar.gz: e0337bdb4775911ad7bc13b2d559516e1a1a52492c9ad37c6401479ad9ade20abf64b81b09e4ffec7493decb9104e95eb8ce49f20d5b953c5af763287c55259f
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
safer_redis (
|
4
|
+
safer_redis (1.0.0)
|
5
5
|
redis (>= 4.6.0)
|
6
6
|
zeitwerk
|
7
7
|
|
@@ -11,9 +11,9 @@ GEM
|
|
11
11
|
connection_pool (2.3.0)
|
12
12
|
diff-lcs (1.5.0)
|
13
13
|
rake (13.0.6)
|
14
|
-
redis (5.0.
|
14
|
+
redis (5.0.6)
|
15
15
|
redis-client (>= 0.9.0)
|
16
|
-
redis-client (0.
|
16
|
+
redis-client (0.12.1)
|
17
17
|
connection_pool
|
18
18
|
rspec (3.12.0)
|
19
19
|
rspec-core (~> 3.12.0)
|
@@ -32,6 +32,7 @@ GEM
|
|
32
32
|
|
33
33
|
PLATFORMS
|
34
34
|
x86_64-darwin-21
|
35
|
+
x86_64-darwin-22
|
35
36
|
|
36
37
|
DEPENDENCIES
|
37
38
|
rake (~> 13.0)
|
data/lib/safer_redis/danger.rb
CHANGED
@@ -15,6 +15,13 @@ module SaferRedis
|
|
15
15
|
If you're sure this is okay, you can try again within `SaferRedis.really { ... }`
|
16
16
|
MESSAGE
|
17
17
|
|
18
|
+
if doc.suggestion
|
19
|
+
message = <<~MESSAGE
|
20
|
+
#{message}
|
21
|
+
Suggestion: #{doc.suggestion.description}
|
22
|
+
MESSAGE
|
23
|
+
end
|
24
|
+
|
18
25
|
super(message)
|
19
26
|
end
|
20
27
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SaferRedis
|
4
|
+
class Suggestion
|
5
|
+
attr_reader :command, :description
|
6
|
+
|
7
|
+
def initialize(command, description)
|
8
|
+
@command = command
|
9
|
+
@description = description
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.for_command(command)
|
13
|
+
case command
|
14
|
+
when "DEL"
|
15
|
+
new(command, "Consider using the non-blocking UNLINK command instead to delete the key on a background thread")
|
16
|
+
else
|
17
|
+
nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/safer_redis/version.rb
CHANGED
data/lib/safer_redis.rb
CHANGED
@@ -28,7 +28,13 @@ module SaferRedis
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def self.assess!(doc)
|
31
|
-
if doc.dangerous?
|
31
|
+
if doc.dangerous?
|
32
|
+
# Anything tagged @dangerous is… dangerous
|
33
|
+
raise SaferRedis::Danger.new(doc)
|
34
|
+
|
35
|
+
elsif doc.slow? && doc.complexity != "O(1)"
|
36
|
+
# Anything tagged @slow might be dangerous, but we'll let through O(1)
|
37
|
+
# complexity commands e.g. SET
|
32
38
|
raise SaferRedis::Danger.new(doc)
|
33
39
|
end
|
34
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: safer_redis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Annesley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -59,8 +59,8 @@ files:
|
|
59
59
|
- lib/safer_redis/command_doc.rb
|
60
60
|
- lib/safer_redis/danger.rb
|
61
61
|
- lib/safer_redis/interceptor.rb
|
62
|
+
- lib/safer_redis/suggestion.rb
|
62
63
|
- lib/safer_redis/version.rb
|
63
|
-
- safer_redis.gemspec
|
64
64
|
- sig/safer_redis.rbs
|
65
65
|
homepage: https://github.com/buildkite/safer_redis
|
66
66
|
licenses:
|
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
86
|
requirements: []
|
87
|
-
rubygems_version: 3.1
|
87
|
+
rubygems_version: 3.4.1
|
88
88
|
signing_key:
|
89
89
|
specification_version: 4
|
90
90
|
summary: Catch unsafe Redis commands in production
|
data/safer_redis.gemspec
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "lib/safer_redis/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "safer_redis"
|
7
|
-
spec.version = SaferRedis::VERSION
|
8
|
-
spec.authors = ["Paul Annesley"]
|
9
|
-
spec.email = ["paul@annesley.cc"]
|
10
|
-
|
11
|
-
spec.summary = "Catch unsafe Redis commands in production"
|
12
|
-
spec.description = "SaferRedis warns you before letting through commands that could impact production availability by being marked `@slow` or `@dangerous` in the Redis documentation"
|
13
|
-
spec.homepage = "https://github.com/buildkite/safer_redis"
|
14
|
-
spec.license = "MIT"
|
15
|
-
spec.required_ruby_version = ">= 2.6.0"
|
16
|
-
|
17
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
-
spec.metadata["source_code_uri"] = "https://github.com/buildkite/safer_redis"
|
19
|
-
spec.metadata["changelog_uri"] = "https://github.com/buildkite/safer_redis/blob/main/CHANGELOG.md"
|
20
|
-
|
21
|
-
# Specify which files should be added to the gem when it is released.
|
22
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
-
spec.files = Dir.chdir(__dir__) do
|
24
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
25
|
-
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
26
|
-
end
|
27
|
-
end
|
28
|
-
spec.require_paths = ["lib"]
|
29
|
-
|
30
|
-
# The only strategy implemented so far is intercepting the private Redis#send_command method,
|
31
|
-
# which was introduced in v4.6.0 via https://github.com/redis/redis-rb/pull/1058 and remains
|
32
|
-
# in the latest release (v5.0.5) at time of writing.
|
33
|
-
spec.add_dependency "redis", ">= 4.6.0"
|
34
|
-
spec.add_dependency "zeitwerk"
|
35
|
-
end
|