sidekiq-encrypted_args 1.0.2 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGE_LOG.md +34 -5
- data/README.md +55 -26
- data/VERSION +1 -1
- data/lib/sidekiq/encrypted_args/client_middleware.rb +23 -19
- data/lib/sidekiq/encrypted_args/server_middleware.rb +19 -8
- data/lib/sidekiq/encrypted_args.rb +97 -38
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fdd24a7aeee28447ee34b8bddaa462a967a4d01ded3b9e0fc1c3561310c9a0a
|
4
|
+
data.tar.gz: 42e1f30f93d6c1c9c71e25b9ef46ea1334d89a09746f4cb75f6facf38c0943be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6c1409dac2ed256f73c5f18d303adaba6e28fec7114b97ea943d16e1aaa34cb3107233c0cce4ab372b085430c7c4b4b2efbc555b123f13aef72bd2691d44170
|
7
|
+
data.tar.gz: 765dea1c7d85313a4ef7451f1ce5293ee7a8cfab53304037ff1f4f4d056831fb7250e3478e87bce8e92023c03cca4788f1276e923830d6343e7edc9e1574ab52
|
data/CHANGE_LOG.md
CHANGED
@@ -1,14 +1,43 @@
|
|
1
|
-
#
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## 1.1.1
|
8
|
+
|
9
|
+
### Fixed
|
10
|
+
- Client middleware will no longer encrypt already encrypted arguments when a job is retried.
|
11
|
+
|
12
|
+
## 1.1.0
|
13
|
+
|
14
|
+
### Added
|
15
|
+
- Use `to_json` if it is defined when serializing encrypted args to JSON.
|
16
|
+
- Add client middleware to the server default configuration. This ensures that arguments will be encrypted if a worker enqueues a job with encrypted arguments.
|
17
|
+
- Client middleware now reads sidekiq options from the job hash instead of from the worker class so that the list of encrypted arguments is always in sync on the job payload.
|
18
|
+
- Added additional option to specify encrypted args with array of argument indexes.
|
19
|
+
|
20
|
+
### Changed
|
21
|
+
- Client middleware is now prepended while server middleware is appended.
|
22
|
+
|
23
|
+
### Fixed
|
24
|
+
- Don't raise error if undefined class name is passed to client middleware as a string.
|
25
|
+
|
26
|
+
### Deprecated
|
27
|
+
- Deprecated setting encrypted args as hash or array of booleans.
|
2
28
|
|
3
29
|
## 1.0.2
|
4
30
|
|
5
|
-
|
31
|
+
### Changed
|
32
|
+
- Remove overly noisy log warning when running without the secret set
|
6
33
|
|
7
34
|
## 1.0.1
|
8
35
|
|
9
|
-
|
10
|
-
|
36
|
+
### Added
|
37
|
+
|
38
|
+
### Fixed
|
39
|
+
- Added support for scheduled jobs
|
11
40
|
|
12
41
|
## 1.0.0
|
13
42
|
|
14
|
-
|
43
|
+
- Initial release
|
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# Sidekiq Encrypted Args
|
2
2
|
|
3
|
-
![Continuous Integration](https://github.com/bdurand/sidekiq-encrypted_args/workflows/Continuous%20Integration/badge.svg?branch=master)
|
4
|
-
[![Maintainability](https://api.codeclimate.com/v1/badges/70ab3782e4d5285eb173/maintainability)](https://codeclimate.com/github/bdurand/sidekiq-encrypted_args/maintainability)
|
3
|
+
[![Continuous Integration](https://github.com/bdurand/sidekiq-encrypted_args/workflows/Continuous%20Integration/badge.svg?branch=master)](https://github.com/bdurand/sidekiq-encrypted_args/actions?query=workflow%3A%22Continuous+Integration%22)
|
5
4
|
[![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
|
6
5
|
|
7
6
|
Support for encrypting arguments for [Sidekiq](https://github.com/mperham/sidekiq).
|
@@ -14,7 +13,7 @@ This can be an even bigger issue if you use scheduled jobs since sensitive data
|
|
14
13
|
|
15
14
|
## Solution
|
16
15
|
|
17
|
-
This gem adds Sidekiq middleware that allows you to specify job arguments for your workers that should be encrypted in Redis. You do this by adding `encrypted_args` to the `sidekiq_options` in the worker. Jobs for these workers will have their arguments encrypted in Redis and decrypted when passed to `perform` method.
|
16
|
+
This gem adds Sidekiq middleware that allows you to specify job arguments for your workers that should be encrypted in Redis. You do this by adding `encrypted_args` to the `sidekiq_options` in the worker. Jobs for these workers will have their arguments encrypted in Redis and decrypted when passed to the `perform` method.
|
18
17
|
|
19
18
|
To use the gem, you will need to specify a secret that will be used to encrypt the arguments as well as add the middleware to your Sidekiq client and server middleware stacks. You can set that up by adding this to the end of your Sidekiq initialization:
|
20
19
|
|
@@ -24,14 +23,16 @@ Sidekiq::EncryptedArgs.configure!(secret: "YourSecretKey")
|
|
24
23
|
|
25
24
|
If the secret is not set, the value of the `SIDEKIQ_ENCRYPTED_ARGS_SECRET` environment variable will be used as the secret. If this variable is not set, job arguments will not be encrypted.
|
26
25
|
|
27
|
-
The call to `Sidekiq::EncryptedArgs.configure!` will
|
26
|
+
The call to `Sidekiq::EncryptedArgs.configure!` will **prepend** the client encryption middleware and **append** server decryption middleware. By doing this, any other middleware you register will only receive the encrypted parameters (e.g. logging middleware will receive the encrypted parameters).
|
27
|
+
|
28
|
+
You can add the middleware manually if you need more control over where they appear in the stacks.
|
28
29
|
|
29
30
|
```ruby
|
30
31
|
Sidekiq::EncryptedArgs.secret = "YourSecretKey"
|
31
32
|
|
32
33
|
Sidekiq.configure_client do |config|
|
33
34
|
config.client_middleware do |chain|
|
34
|
-
chain.
|
35
|
+
chain.prepend Sidekiq::EncryptedArgs::ClientMiddleware
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
@@ -39,6 +40,12 @@ Sidekiq.configure_server do |config|
|
|
39
40
|
config.server_middleware do |chain|
|
40
41
|
chain.add Sidekiq::EncryptedArgs::ServerMiddleware
|
41
42
|
end
|
43
|
+
|
44
|
+
# register client middleware on the server so that starting jobs in a Sidekiq::Worker also get encrypted args
|
45
|
+
# https://github.com/mperham/sidekiq/wiki/Middleware#client-middleware-registered-in-both-places
|
46
|
+
config.client_middleware do |chain|
|
47
|
+
chain.prepend Sidekiq::EncryptedArgs::ClientMiddleware
|
48
|
+
end
|
42
49
|
end
|
43
50
|
```
|
44
51
|
|
@@ -59,30 +66,24 @@ class SecretWorker
|
|
59
66
|
end
|
60
67
|
```
|
61
68
|
|
62
|
-
You can also encrypt
|
69
|
+
You can also choose to only encrypt specific arguments with an array of either argument names (symbols or strings) or indexes. This is useful to preserve visibility into non-sensitive arguments for troubleshooting or other reasons. Both of these examples encrypt just the second argument to the `perform` method.
|
63
70
|
|
64
71
|
```ruby
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
end
|
70
|
-
```
|
72
|
+
# Pass in a list of argument names that should be encrypted
|
73
|
+
sidekiq_options encrypted_args: [:arg_2]
|
74
|
+
# or
|
75
|
+
sidekiq_options encrypted_args: ["arg_2"]
|
71
76
|
|
72
|
-
|
73
|
-
|
74
|
-
sidekiq_options encrypted_args: { arg_2: true, arg_1: false }
|
75
|
-
|
76
|
-
def perform(arg_1, arg_2, arg_3)
|
77
|
-
end
|
77
|
+
def perform(arg_1, arg_2, arg_3)
|
78
|
+
end
|
78
79
|
```
|
79
80
|
|
80
81
|
```ruby
|
81
|
-
|
82
|
-
|
82
|
+
# Pass in an array of integers indicating which argument positions should be encrypted
|
83
|
+
sidekiq_options encrypted_args: [1]
|
83
84
|
|
84
|
-
|
85
|
-
|
85
|
+
def perform(arg_1, arg_2, arg_3)
|
86
|
+
end
|
86
87
|
```
|
87
88
|
|
88
89
|
You don't need to change anything else about your workers. All of the arguments passed to the `perform` method will already be unencrypted when the method is called.
|
@@ -92,15 +93,43 @@ You don't need to change anything else about your workers. All of the arguments
|
|
92
93
|
If you need to roll your secret, you can simply provide an array when setting the secret.
|
93
94
|
|
94
95
|
```ruby
|
95
|
-
Sidekiq::EncryptedArgs.secret = ["CurrentSecret", "OldSecret"]
|
96
|
+
Sidekiq::EncryptedArgs.secret = ["CurrentSecret", "OldSecret", "EvenOlderSecret"]
|
96
97
|
```
|
97
98
|
|
98
|
-
The left most key will be considered the current key and
|
99
|
+
The first (left most) key will be considered the current key, and is used for encrypting arguments. When decrypting, we iterate over the secrets list until we find the correct one. This allows you to switch you secret keys without breaking jobs already enqueued in Redis.
|
99
100
|
|
100
|
-
If you are using the `SIDEKIQ_ENCRYPTED_ARGS_SECRET`
|
101
|
+
If you are using the `SIDEKIQ_ENCRYPTED_ARGS_SECRET` environment variable to specify your secret, you can delimit multiple keys with a spaces.
|
101
102
|
|
102
103
|
You can also safely add encryption to an existing worker. Any jobs that are already enqueued will still run even without having the arguments encrypted in Redis.
|
103
104
|
|
104
105
|
## Encryption
|
105
106
|
|
106
|
-
Encrypted arguments are stored using AES-256-GCM with a key derived from your secret using PBKDF2.
|
107
|
+
Encrypted arguments are stored using AES-256-GCM with a key derived from your secret using PBKDF2. For more info on the underlying encryption, refer to the [SecretKeys](https://github.com/bdurand/secret_keys) gem.
|
108
|
+
|
109
|
+
## Installation
|
110
|
+
|
111
|
+
Add this line to your application's Gemfile:
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
gem "sidekiq-encrypted_args"
|
115
|
+
```
|
116
|
+
|
117
|
+
And then execute:
|
118
|
+
```bash
|
119
|
+
$ bundle
|
120
|
+
```
|
121
|
+
|
122
|
+
Or install it yourself as:
|
123
|
+
```bash
|
124
|
+
$ gem install sidekiq-encrypted_args
|
125
|
+
```
|
126
|
+
|
127
|
+
## Contributing
|
128
|
+
|
129
|
+
Open a pull request on GitHub.
|
130
|
+
|
131
|
+
Please use the [standardrb](https://github.com/testdouble/standard) syntax and lint your code with `standardrb --fix` before submitting.
|
132
|
+
|
133
|
+
## License
|
134
|
+
|
135
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.1.1
|
@@ -5,17 +5,11 @@ module Sidekiq
|
|
5
5
|
# Sidekiq client middleware for encrypting arguments on jobs for workers
|
6
6
|
# with `encrypted_args` set in the `sidekiq_options`.
|
7
7
|
class ClientMiddleware
|
8
|
-
#
|
8
|
+
# Encrypt specified arguments before they're sent off to the queue
|
9
9
|
def call(worker_class, job, queue, redis_pool = nil)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
new_args = []
|
14
|
-
job["args"].each_with_index do |value, position|
|
15
|
-
value = EncryptedArgs.encrypt(value) if encrypted_args[position]
|
16
|
-
new_args << value
|
17
|
-
end
|
18
|
-
job["args"] = new_args
|
10
|
+
if job.include?("encrypted_args")
|
11
|
+
encrypted_args = EncryptedArgs.encrypted_args_option(worker_class, job)
|
12
|
+
encrypt_job_arguments!(job, encrypted_args)
|
19
13
|
end
|
20
14
|
|
21
15
|
yield
|
@@ -23,15 +17,25 @@ module Sidekiq
|
|
23
17
|
|
24
18
|
private
|
25
19
|
|
26
|
-
#
|
27
|
-
#
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
20
|
+
# Encrypt the arguments on job
|
21
|
+
#
|
22
|
+
# Additionally, set `job["encrypted_args"]` to the canonicalized version (i.e. `Array<Integer>`)
|
23
|
+
#
|
24
|
+
# @param [Hash]
|
25
|
+
# @param [Array<Integer>] encrypted_args array of indexes in job to encrypt
|
26
|
+
# @return [void]
|
27
|
+
def encrypt_job_arguments!(job, encrypted_args)
|
28
|
+
if encrypted_args
|
29
|
+
job_args = job["args"]
|
30
|
+
job_args.each_with_index do |value, position|
|
31
|
+
if encrypted_args.include?(position) && !EncryptedArgs.encrypted?(value)
|
32
|
+
job_args[position] = EncryptedArgs.encrypt(value)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
job["encrypted_args"] = encrypted_args
|
36
|
+
else
|
37
|
+
job.delete("encrypted_args")
|
38
|
+
end
|
35
39
|
end
|
36
40
|
end
|
37
41
|
end
|
@@ -2,22 +2,33 @@
|
|
2
2
|
|
3
3
|
module Sidekiq
|
4
4
|
module EncryptedArgs
|
5
|
+
# Sidekiq server middleware for decrypting arguments on jobs that have encrypted args.
|
5
6
|
class ServerMiddleware
|
6
|
-
#
|
7
|
-
# with `encrypted_args` set in the `sidekiq_options`.
|
7
|
+
# Wrap the server process to decrypt incoming arguments
|
8
8
|
def call(worker, job, queue)
|
9
|
-
encrypted_args =
|
9
|
+
encrypted_args = job["encrypted_args"]
|
10
10
|
if encrypted_args
|
11
|
-
|
12
|
-
job["args"]
|
13
|
-
|
14
|
-
|
11
|
+
encrypted_args = backward_compatible_encrypted_args(encrypted_args, worker.class, job)
|
12
|
+
job_args = job["args"]
|
13
|
+
encrypted_args.each do |position|
|
14
|
+
value = job_args[position]
|
15
|
+
job_args[position] = EncryptedArgs.decrypt(value)
|
15
16
|
end
|
16
|
-
job["args"] = new_args
|
17
17
|
end
|
18
18
|
|
19
19
|
yield
|
20
20
|
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
# Ensure that the encrypted args is an array of integers. If not re-read it from the class
|
25
|
+
# definition since gem version 1.0.2 and earlier did not update the encrypted_args on the job.
|
26
|
+
def backward_compatible_encrypted_args(encrypted_args, worker_class, job)
|
27
|
+
unless encrypted_args.is_a?(Array) && encrypted_args.all? { |position| position.is_a?(Integer) }
|
28
|
+
encrypted_args = EncryptedArgs.encrypted_args_option(worker_class, job)
|
29
|
+
end
|
30
|
+
encrypted_args
|
31
|
+
end
|
21
32
|
end
|
22
33
|
end
|
23
34
|
end
|
@@ -6,36 +6,44 @@ require "sidekiq"
|
|
6
6
|
|
7
7
|
module Sidekiq
|
8
8
|
module EncryptedArgs
|
9
|
-
# Error thrown when the
|
9
|
+
# Error thrown when the secret is invalid
|
10
10
|
class InvalidSecretError < StandardError
|
11
|
+
def initialize
|
12
|
+
super("Cannot decrypt. Invalid secret provided.")
|
13
|
+
end
|
11
14
|
end
|
12
15
|
|
13
16
|
class << self
|
14
17
|
# Set the secret key used for encrypting arguments. If this is not set,
|
15
18
|
# the value will be loaded from the `SIDEKIQ_ENCRYPTED_ARGS_SECRET` environment
|
16
|
-
# variable. If that value is not set, arguments will not be
|
17
|
-
#
|
18
|
-
# @param [String] value One or more secrets to use for encypting arguments.
|
19
|
+
# variable. If that value is not set, arguments will not be encrypted.
|
19
20
|
#
|
20
|
-
#
|
21
|
+
# You can set multiple secrets by passing an array if you need to roll your secrets.
|
21
22
|
# The left most value in the array will be used as the encryption secret, but
|
22
23
|
# all the values will be tried when decrypting. That way if you have scheduled
|
23
|
-
# jobs that were
|
24
|
+
# jobs that were encrypted with a different secret, you can still make it available
|
24
25
|
# when decrypting the arguments when the job gets run. If you are using the
|
25
|
-
#
|
26
|
+
# environment variable, separate the keys with spaces.
|
27
|
+
#
|
28
|
+
# @param [String] value One or more secrets to use for encrypting arguments.
|
29
|
+
# @return [void]
|
26
30
|
def secret=(value)
|
27
31
|
@encryptors = make_encryptors(value)
|
28
32
|
end
|
29
33
|
|
30
|
-
#
|
34
|
+
# Add the client and server middleware to the default Sidekiq
|
31
35
|
# middleware chains. If you need to ensure the order of where the middleware is
|
32
36
|
# added, you can forgo this method and add it yourself.
|
37
|
+
#
|
38
|
+
# This method prepends client middleware and appends server middleware.
|
39
|
+
#
|
40
|
+
# @param [String] secret optionally set the secret here. See {.secret=}
|
33
41
|
def configure!(secret: nil)
|
34
42
|
self.secret = secret unless secret.nil?
|
35
43
|
|
36
44
|
Sidekiq.configure_client do |config|
|
37
45
|
config.client_middleware do |chain|
|
38
|
-
chain.
|
46
|
+
chain.prepend Sidekiq::EncryptedArgs::ClientMiddleware
|
39
47
|
end
|
40
48
|
end
|
41
49
|
|
@@ -43,17 +51,21 @@ module Sidekiq
|
|
43
51
|
config.server_middleware do |chain|
|
44
52
|
chain.add Sidekiq::EncryptedArgs::ServerMiddleware
|
45
53
|
end
|
54
|
+
config.client_middleware do |chain|
|
55
|
+
chain.prepend Sidekiq::EncryptedArgs::ClientMiddleware
|
56
|
+
end
|
46
57
|
end
|
47
58
|
end
|
48
59
|
|
49
60
|
# Encrypt a value.
|
50
61
|
#
|
51
|
-
# @param [Object] data Data to encrypt. You can pass any JSON compatible data types or structures.
|
62
|
+
# @param [#to_json, Object] data Data to encrypt. You can pass any JSON compatible data types or structures.
|
52
63
|
#
|
53
64
|
# @return [String]
|
54
65
|
def encrypt(data)
|
55
66
|
return nil if data.nil?
|
56
|
-
|
67
|
+
|
68
|
+
json = (data.respond_to?(:to_json) ? data.to_json : JSON.generate(data))
|
57
69
|
encrypted = encrypt_string(json)
|
58
70
|
if encrypted == json
|
59
71
|
data
|
@@ -67,37 +79,62 @@ module Sidekiq
|
|
67
79
|
# @param [String] encrypted_data Data that was previously encrypted. If the value passed in is
|
68
80
|
# an unencrypted string, then the string itself will be returned.
|
69
81
|
#
|
70
|
-
# @return [
|
82
|
+
# @return [Object]
|
71
83
|
def decrypt(encrypted_data)
|
72
84
|
return encrypted_data unless SecretKeys::Encryptor.encrypted?(encrypted_data)
|
73
85
|
json = decrypt_string(encrypted_data)
|
74
86
|
JSON.parse(json)
|
75
87
|
end
|
76
88
|
|
77
|
-
|
89
|
+
# Check if a value is encrypted.
|
90
|
+
#
|
91
|
+
# @return [Boolean]
|
92
|
+
def encrypted?(value)
|
93
|
+
SecretKeys::Encryptor.encrypted?(value)
|
94
|
+
end
|
78
95
|
|
79
|
-
#
|
96
|
+
# Private helper method to get the encrypted args option from an options hash. The value of this option
|
80
97
|
# can be `true` or an array indicating if each positional argument should be encrypted, or a hash
|
81
98
|
# with keys for the argument position and true as the value.
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
99
|
+
#
|
100
|
+
# @private
|
101
|
+
def encrypted_args_option(worker_class, job)
|
102
|
+
option = job["encrypted_args"]
|
86
103
|
return nil if option.nil?
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
104
|
+
return [] if option == false
|
105
|
+
|
106
|
+
indexes = []
|
107
|
+
if option == true
|
108
|
+
job["args"].size.times { |i| indexes << i }
|
109
|
+
elsif option.is_a?(Hash)
|
110
|
+
deprecation_warning("hash")
|
111
|
+
indexes = replace_argument_positions(worker_class, option)
|
112
|
+
else
|
113
|
+
array_type = nil
|
114
|
+
deprecation_message = nil
|
115
|
+
Array(option).each_with_index do |val, position|
|
116
|
+
current_type = nil
|
117
|
+
if val.is_a?(Integer)
|
118
|
+
indexes << val
|
119
|
+
current_type = :integer
|
120
|
+
elsif val.is_a?(Symbol) || val.is_a?(String)
|
121
|
+
worker_class = constantize(worker_class) if worker_class.is_a?(String)
|
122
|
+
position = perform_method_parameter_index(worker_class, val)
|
123
|
+
indexes << position if position
|
124
|
+
current_type = :symbol
|
125
|
+
else
|
126
|
+
deprecation_message = "boolean array"
|
127
|
+
indexes << position if val
|
128
|
+
end
|
129
|
+
if array_type && current_type
|
130
|
+
deprecation_message = "array of mixed types"
|
131
|
+
else
|
132
|
+
array_type ||= current_type
|
133
|
+
end
|
98
134
|
end
|
135
|
+
deprecation_warning(deprecation_message) if deprecation_message
|
99
136
|
end
|
100
|
-
|
137
|
+
indexes
|
101
138
|
end
|
102
139
|
|
103
140
|
private
|
@@ -135,18 +172,40 @@ module Sidekiq
|
|
135
172
|
Array(secrets).map { |val| val.nil? ? nil : SecretKeys::Encryptor.from_password(val, SALT) }
|
136
173
|
end
|
137
174
|
|
138
|
-
def
|
139
|
-
|
140
|
-
|
175
|
+
def deprecation_warning(message)
|
176
|
+
warn("Sidekiq::EncryptedArgs: setting encrypted_args to #{message} is deprecated; support will be removed in version 1.2.")
|
177
|
+
end
|
178
|
+
|
179
|
+
# @param [String] class_name name of a class
|
180
|
+
# @return [Class] class that was referenced by name
|
181
|
+
def constantize(class_name)
|
182
|
+
names = class_name.split("::")
|
183
|
+
# Clear leading :: for root namespace since we're already calling from object
|
184
|
+
names.shift if names.empty? || names.first.empty?
|
185
|
+
# Map reduce to the constant. Use inherit=false to not accidentally search
|
186
|
+
# parent modules
|
187
|
+
names.inject(Object) { |constant, name| constant.const_get(name, false) }
|
188
|
+
end
|
189
|
+
|
190
|
+
def replace_argument_positions(worker_class, encrypt_option_hash)
|
191
|
+
encrypted_indexes = []
|
192
|
+
encrypt_option_hash.each do |key, value|
|
193
|
+
next unless value
|
141
194
|
if key.is_a?(Symbol) || key.is_a?(String)
|
142
|
-
|
143
|
-
|
144
|
-
updated[position] = value if position
|
195
|
+
position = perform_method_parameter_index(worker_class, key)
|
196
|
+
encrypted_indexes << position if position
|
145
197
|
elsif key.is_a?(Integer)
|
146
|
-
|
198
|
+
encrypted_indexes << key
|
147
199
|
end
|
148
200
|
end
|
149
|
-
|
201
|
+
encrypted_indexes
|
202
|
+
end
|
203
|
+
|
204
|
+
def perform_method_parameter_index(worker_class, parameter)
|
205
|
+
if worker_class
|
206
|
+
parameter = parameter.to_sym
|
207
|
+
worker_class.instance_method(:perform).parameters.find_index { |_, name| name == parameter }
|
208
|
+
end
|
150
209
|
end
|
151
210
|
end
|
152
211
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-encrypted_args
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Durand
|
8
8
|
- Winston Durand
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-04-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sidekiq
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '2.0'
|
56
|
-
description:
|
56
|
+
description:
|
57
57
|
email:
|
58
58
|
- bbdurand@gmail.com
|
59
59
|
- me@winstondurand.com
|
@@ -76,7 +76,7 @@ homepage: https://github.com/bdurand/sidekiq-encrypted_args
|
|
76
76
|
licenses:
|
77
77
|
- MIT
|
78
78
|
metadata: {}
|
79
|
-
post_install_message:
|
79
|
+
post_install_message:
|
80
80
|
rdoc_options: []
|
81
81
|
require_paths:
|
82
82
|
- lib
|
@@ -91,8 +91,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: '0'
|
93
93
|
requirements: []
|
94
|
-
rubygems_version: 3.
|
95
|
-
signing_key:
|
94
|
+
rubygems_version: 3.2.22
|
95
|
+
signing_key:
|
96
96
|
specification_version: 4
|
97
97
|
summary: Support for encrypting arguments that contain sensitive information in sidekiq
|
98
98
|
jobs.
|