waylon-core 0.2.2 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +7 -1
- data/Rakefile +4 -0
- data/lib/waylon/cache.rb +4 -0
- data/lib/waylon/rspec/test_server.rb +2 -0
- data/lib/waylon/storage.rb +25 -3
- data/lib/waylon/version.rb +1 -1
- data/waylon-core.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 932e166cc8b43333b52643aa789415cc88d59441464e7eb0108ca1443f6ef48a
|
4
|
+
data.tar.gz: 517dc8256389a54b3f745a6db0da5f9a957f993dc96cbca8fe93bde0ed2e22a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a8132248f4128a44e0a1133846fe2afa134665f8e7df48feb5b1dba550cbffb68abf4778930d0e7d0dc657cd386a82fc32d0e9f4201fd1e28063efbd90d4719
|
7
|
+
data.tar.gz: 2ff90e41205b721a08d862100e7beefd1375450a61fc35af28c221d04580b6534a8104e0923ddf21a362332477834cece2d3a3a793d631c374860b6718184df5
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
waylon-core (0.2.
|
4
|
+
waylon-core (0.2.5)
|
5
5
|
addressable (~> 2.8)
|
6
6
|
faraday (~> 1.8)
|
7
7
|
i18n (~> 1.8)
|
@@ -17,6 +17,7 @@ GEM
|
|
17
17
|
addressable (2.8.1)
|
18
18
|
public_suffix (>= 2.0.2, < 6.0)
|
19
19
|
ast (2.4.2)
|
20
|
+
coderay (1.1.3)
|
20
21
|
concurrent-ruby (1.1.10)
|
21
22
|
connection_pool (2.2.5)
|
22
23
|
diff-lcs (1.5.0)
|
@@ -48,6 +49,7 @@ GEM
|
|
48
49
|
i18n (1.12.0)
|
49
50
|
concurrent-ruby (~> 1.0)
|
50
51
|
json (2.6.2)
|
52
|
+
method_source (1.0.0)
|
51
53
|
moneta (1.5.1)
|
52
54
|
mono_logger (1.1.1)
|
53
55
|
multi_json (1.15.0)
|
@@ -58,6 +60,9 @@ GEM
|
|
58
60
|
parallel (1.22.1)
|
59
61
|
parser (3.1.2.1)
|
60
62
|
ast (~> 2.4.1)
|
63
|
+
pry (0.14.1)
|
64
|
+
coderay (~> 1.1)
|
65
|
+
method_source (~> 1.0)
|
61
66
|
public_suffix (5.0.0)
|
62
67
|
puma (5.6.5)
|
63
68
|
nio4r (~> 2.0)
|
@@ -135,6 +140,7 @@ PLATFORMS
|
|
135
140
|
|
136
141
|
DEPENDENCIES
|
137
142
|
bundler (~> 2.3)
|
143
|
+
pry (~> 0.14)
|
138
144
|
rake (~> 13.0)
|
139
145
|
rspec (~> 3.10)
|
140
146
|
rubocop (~> 1.23)
|
data/Rakefile
CHANGED
@@ -19,5 +19,9 @@ end
|
|
19
19
|
task default: %i[spec rubocop yard]
|
20
20
|
|
21
21
|
task :demo do
|
22
|
+
require "pry"
|
23
|
+
Waylon::Logger.logger = ::Logger.new("/dev/null")
|
24
|
+
Waylon::Cache.storage = Moneta.new(:Cookie)
|
25
|
+
Waylon::Storage.storage = Moneta.new(:Cookie)
|
22
26
|
require "waylon/rspec/test_server"
|
23
27
|
end
|
data/lib/waylon/cache.rb
CHANGED
@@ -100,6 +100,8 @@ def handle_input(body, from: this_user, privately: true)
|
|
100
100
|
elsif ["su", "su -", "su admin", "su - admin"].include?(body)
|
101
101
|
puts 'Admin enabled! Use "exit" to go back to a normal user.'
|
102
102
|
@admin_enabled = true
|
103
|
+
elsif @admin_enabled && %w[irb pry].include?(body)
|
104
|
+
pry
|
103
105
|
else
|
104
106
|
message_count = Waylon::RSpec::TestSense.sent_messages.size
|
105
107
|
|
data/lib/waylon/storage.rb
CHANGED
@@ -8,8 +8,12 @@ module Waylon
|
|
8
8
|
url: "redis://#{ENV.fetch("REDIS", "localhost:6379")}/2"
|
9
9
|
)
|
10
10
|
|
11
|
+
def self.adapter
|
12
|
+
storage.adapter
|
13
|
+
end
|
14
|
+
|
11
15
|
def self.cipher
|
12
|
-
key_bytes = RbNaCl::Hash.sha256(
|
16
|
+
key_bytes = RbNaCl::Hash.sha256(encryption_key)[0..31]
|
13
17
|
RbNaCl::SimpleBox.from_secret_key(key_bytes)
|
14
18
|
end
|
15
19
|
|
@@ -21,6 +25,19 @@ module Waylon
|
|
21
25
|
storage.delete(key)
|
22
26
|
end
|
23
27
|
|
28
|
+
def self.each_key(&block)
|
29
|
+
storage.each_key(&block)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.encryption_key
|
33
|
+
ENV.fetch("ENCRYPTION_KEY", "thisisVeryUnsafe4U")
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.encryption_key_fingerprint
|
37
|
+
base = RbNaCl::Hash.sha256(encryption_key)[0..15]
|
38
|
+
Base64.urlsafe_encode64(RbNaCl::Hash.sha256(base)[0..7])
|
39
|
+
end
|
40
|
+
|
24
41
|
def self.key?(name)
|
25
42
|
storage.key?(name)
|
26
43
|
end
|
@@ -30,7 +47,11 @@ module Waylon
|
|
30
47
|
raw = storage.load(key)
|
31
48
|
return nil unless raw
|
32
49
|
|
33
|
-
|
50
|
+
wrapper = JSON.parse(raw)
|
51
|
+
value = wrapper["data"]
|
52
|
+
return nil unless value
|
53
|
+
|
54
|
+
decoded = Base64.decode64(value)
|
34
55
|
plain = this_cipher.decrypt(decoded)
|
35
56
|
JSON.parse(plain)
|
36
57
|
end
|
@@ -47,7 +68,8 @@ module Waylon
|
|
47
68
|
this_cipher = cipher
|
48
69
|
encrypted = this_cipher.encrypt(value.to_json)
|
49
70
|
encoded = Base64.encode64(encrypted)
|
50
|
-
|
71
|
+
wrapper = { cipher: cipher.class.name, data: encoded, key: encryption_key_fingerprint }
|
72
|
+
storage.store(key, wrapper.to_json)
|
51
73
|
end
|
52
74
|
end
|
53
75
|
end
|
data/lib/waylon/version.rb
CHANGED
data/waylon-core.gemspec
CHANGED
@@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
|
|
37
37
|
spec.add_dependency "resque", "~> 2.2"
|
38
38
|
|
39
39
|
spec.add_development_dependency "bundler", "~> 2.3"
|
40
|
+
spec.add_development_dependency "pry", "~> 0.14"
|
40
41
|
spec.add_development_dependency "rake", "~> 13.0"
|
41
42
|
spec.add_development_dependency "rspec", "~> 3.10"
|
42
43
|
spec.add_development_dependency "rubocop", "~> 1.23"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: waylon-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Gnagy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '2.3'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: pry
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0.14'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0.14'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: rake
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|