encrypted-keystore 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f702b8696648c43bef8b8b61cf0da1c42b57e38a
4
+ data.tar.gz: 47b8ec4c2fd696497a1ddc1e84da6a4c84526d49
5
+ SHA512:
6
+ metadata.gz: c6dae5d82995e25913827aa3781d3a1b43a2ed7d5075b3ef1086602ec9db2c835b8aca6c42cbdeaef9879749176a7584862a17ef393fbf6f21911dd5e63c8d6d
7
+ data.tar.gz: aa2347013272c0a6bf155f9a07175cd7380b3200eb1f9b334866243342904760457d303844feafa4113784505a1eb5cc72c47d63a6090cc320714a92fa2d14c8
data/.rubocop.yml ADDED
@@ -0,0 +1,79 @@
1
+ require:
2
+ - rubocop-rspec
3
+ AllCops:
4
+ TargetRubyVersion: 2.3
5
+ Exclude:
6
+ - bin/**/*
7
+ - config/**/*
8
+ - db/**/*
9
+ - vendor/**/*
10
+ - tmp/**/*
11
+
12
+ Layout/IndentFirstHashElement:
13
+ EnforcedStyle: consistent
14
+ Layout/AccessModifierIndentation:
15
+ EnforcedStyle: outdent
16
+ Layout/EmptyLinesAroundAccessModifier:
17
+ Enabled: true
18
+ Layout/AlignArray:
19
+ Enabled: true
20
+ Layout/AlignHash:
21
+ Enabled: true
22
+ Layout/EmptyLineAfterGuardClause:
23
+ Enabled: true
24
+ Layout/SpaceInsideBlockBraces:
25
+ EnforcedStyle: space
26
+ EnforcedStyleForEmptyBraces: no_space
27
+ Layout/SpaceInsideHashLiteralBraces:
28
+ EnforcedStyle: space
29
+ EnforcedStyleForEmptyBraces: no_space
30
+ Layout/SpaceInsideArrayLiteralBrackets:
31
+ EnforcedStyle: no_space
32
+
33
+ Lint/UnusedMethodArgument:
34
+ Enabled: true
35
+ Lint/UselessAssignment:
36
+ Enabled: true
37
+
38
+ Metrics/LineLength:
39
+ Max: 100
40
+ Metrics/MethodLength:
41
+ Enabled: true
42
+ Metrics/ClassLength:
43
+ Enabled: true
44
+ Max: 125
45
+ Metrics/ModuleLength:
46
+ Max: 125
47
+ Metrics/ParameterLists:
48
+ Enabled: true
49
+ Metrics/CyclomaticComplexity:
50
+ Enabled: true
51
+ Metrics/AbcSize:
52
+ Enabled: true
53
+
54
+ Naming/MemoizedInstanceVariableName:
55
+ Enabled: false
56
+ Naming/UncommunicativeMethodParamName:
57
+ Enabled: false
58
+
59
+ Style/Documentation:
60
+ Enabled: false
61
+ Style/FrozenStringLiteralComment:
62
+ Enabled: true
63
+ Style/NumericLiterals:
64
+ Enabled: true
65
+ Style/StringLiterals:
66
+ EnforcedStyle: single_quotes
67
+ Style/AndOr:
68
+ Enabled: true
69
+ Style/ClassCheck:
70
+ Enabled: true
71
+ Style/GuardClause:
72
+ Enabled: true
73
+
74
+ Security/Eval:
75
+ Enabled: true
76
+ Security/JSONLoad:
77
+ Enabled: true
78
+ Security/YAMLLoad:
79
+ Enabled: true
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.4.4
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,17 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ encrypted-keystore (0.0.3)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+
10
+ PLATFORMS
11
+ ruby
12
+
13
+ DEPENDENCIES
14
+ encrypted-keystore!
15
+
16
+ BUNDLED WITH
17
+ 1.17.3
data/Readme.md ADDED
@@ -0,0 +1,52 @@
1
+ # Rails, Quietly
2
+
3
+ A simple wrapper to suppress logging in various ways in Rails apps.
4
+
5
+ ## Installation
6
+
7
+ Add this to your Gemfile:
8
+
9
+ ```ruby
10
+ gem 'rails-quietly'
11
+ ```
12
+
13
+ or install directly:
14
+
15
+ ```bash
16
+ gem install rails-quietly
17
+ ```
18
+
19
+ ## Inclusion
20
+
21
+ In `config/applicaiton.rb`, include the following:
22
+
23
+ ```ruby
24
+ require 'quietly'
25
+ include Quietly::Local
26
+ ```
27
+
28
+ This puts the module into global scope.
29
+
30
+ ## Usage
31
+
32
+ You can either use the `quietly` method with a block:
33
+
34
+ ```ruby
35
+ result_b = quietly do
36
+ a = ModelA.query
37
+ ModelB.query(a)
38
+ end
39
+ ```
40
+
41
+ or manually suppress and restore logging:
42
+
43
+ ```ruby
44
+ old_logger = go_quiet
45
+
46
+ a = ModelA.query
47
+ result_b = ModelB.query(a)
48
+
49
+ end_quiet(old_logger)
50
+
51
+ result_b
52
+ ```
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'encrypted-keystore'
5
+ s.version = '0.0.3'
6
+ s.date = '2019-06-26'
7
+ s.summary = 'Simple key encrypter/decrypter'
8
+ s.description = 'A simple encrypted key storage system.'
9
+ s.homepage = 'http://rubygems.org/gems/encrypted-keystore'
10
+ s.license = 'GPL-3.0'
11
+ s.authors = ['Julian Fiander']
12
+ s.email = 'julian@fiander.one'
13
+ s.require_paths = %w[lib]
14
+ s.files = `git ls-files`.split("\n")
15
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ class EncryptedKeystore
4
+ require 'openssl'
5
+ require 'base64'
6
+
7
+ attr_accessor :file, :out, :key, :iv
8
+
9
+ def initialize(file: nil, out: nil, key: nil, iv: nil)
10
+ @file = file
11
+ @out = out
12
+ @key = key
13
+ @iv = iv
14
+ end
15
+
16
+ def decrypt
17
+ validate
18
+
19
+ write(dec_cipher)
20
+ end
21
+
22
+ def encrypt
23
+ validate(enc: true)
24
+
25
+ write(enc_cipher)
26
+ end
27
+
28
+ private
29
+
30
+ def dec_cipher
31
+ cipher = OpenSSL::Cipher.new('aes-256-cbc')
32
+ cipher.decrypt
33
+ cipher.key = Base64.decode64(@key)
34
+ cipher.iv = Base64.decode64(@iv)
35
+ cipher
36
+ end
37
+
38
+ def enc_cipher
39
+ cipher = OpenSSL::Cipher.new('aes-256-cbc')
40
+ cipher.encrypt
41
+ @key = Base64.encode64(cipher.random_key)
42
+ @iv = Base64.encode64(cipher.random_iv)
43
+ cipher
44
+ end
45
+
46
+ def write(cipher)
47
+ validate
48
+
49
+ buffer = +''
50
+ File.open(@out, 'wb') do |outfile|
51
+ File.open(@file, 'rb') do |infile|
52
+ outfile << cipher.update(buffer) while infile.read(4096, buffer)
53
+ outfile << cipher.final
54
+ end
55
+ end
56
+
57
+ @out
58
+ end
59
+
60
+ def validate(enc: false)
61
+ return true if !@file.nil? && !@out.nil? && (!enc || (!@key.nil? && !@iv.nil?))
62
+
63
+ raise ArgumentError, 'Required arguments have not been provided.'
64
+ end
65
+ end
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: encrypted-keystore
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Julian Fiander
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-06-26 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A simple encrypted key storage system.
14
+ email: julian@fiander.one
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - ".rubocop.yml"
20
+ - ".ruby-version"
21
+ - Gemfile
22
+ - Gemfile.lock
23
+ - Readme.md
24
+ - encrypted-keystore.gemspec
25
+ - lib/encrypted_keystore.rb
26
+ homepage: http://rubygems.org/gems/encrypted-keystore
27
+ licenses:
28
+ - GPL-3.0
29
+ metadata: {}
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubyforge_project:
46
+ rubygems_version: 2.6.14.1
47
+ signing_key:
48
+ specification_version: 4
49
+ summary: Simple key encrypter/decrypter
50
+ test_files: []