streetcreds 0.2.1 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c091cee96b3744e58afb7f442814e6bf845e4889
4
- data.tar.gz: 7ea0010369b9464a6245f0c374d09d3f6da61b4f
3
+ metadata.gz: 4992cea56865f3bea517948f1b74b2278cbd3d9f
4
+ data.tar.gz: dad38638afac30b47c78c17a6401443aefd877df
5
5
  SHA512:
6
- metadata.gz: 43bec2164b265fb5f8edcb57457152b785fcd10f85482532b25c8e8b5f86172bf066d5f72b32404af23020ec4ed4e45335ca32abaeada4659f08cb6b9f561ede
7
- data.tar.gz: f8db05359831be99e312e35c4e1832b76b1b37ada5b3f4f50bdf1f84b4921adc2acf35b3c57699d46ee41d9a61e53154525094f8998e76b2de8ba27c7fdba947
6
+ metadata.gz: 53ede8197582183c6df7ba4cf2edde7d63a71460d486de928538d356c966c9e1600f65cba33abbef49d01985b27f84a7e4d022b5694129a44fe37f933e1f185a
7
+ data.tar.gz: 56368552c1564d21a1907a6eb042bbae6499647b0684ee0bab5b066f00cc57a34a76aee6ce30d42dd074d3c82efcf72c9ed0a925a4f0d005b4cd1d596af69172
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: streetcreds
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wesley Boynton
@@ -72,18 +72,7 @@ email:
72
72
  executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
- files:
76
- - ".gitignore"
77
- - Gemfile
78
- - Gemfile.lock
79
- - LICENSE.txt
80
- - README.md
81
- - lib/streetcreds.rb
82
- - lib/streetcreds/cred_file.rb
83
- - lib/streetcreds/patches/openssl_cipher_patch.rb
84
- - lib/streetcreds/patches/yaml_patch.rb
85
- - lib/streetcreds/version.rb
86
- - streetcreds.gemspec
75
+ files: []
87
76
  homepage:
88
77
  licenses:
89
78
  - MIT
data/.gitignore DELETED
@@ -1 +0,0 @@
1
- *.gem
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
data/Gemfile.lock DELETED
@@ -1,24 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- streetcreds (0.2.0)
5
- encrypted_strings
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- byebug (9.0.6)
11
- encrypted_strings (0.3.3)
12
- rake (10.5.0)
13
-
14
- PLATFORMS
15
- ruby
16
-
17
- DEPENDENCIES
18
- bundler (~> 1.15)
19
- byebug
20
- rake (~> 10.0)
21
- streetcreds!
22
-
23
- BUNDLED WITH
24
- 1.15.1
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2017 Wesley Boynton
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
data/README.md DELETED
@@ -1,44 +0,0 @@
1
- # StreetCreds
2
-
3
- This is a gem that manages encrypted YAML files that can be used to store credentials and stuff you might just not want to leave lying around on your system.
4
-
5
- It doesn't use a strong or unique IV or anything like that. It's not top-notch security. It's just a quick-and-dirty way to obfuscate things you might be using locally to enable your code to access resources, short of using a local deployment of a secret manager like Hashicorp Vault.
6
-
7
- It uses ruby 2.0 hash-syntax for many of its methods, allowing you to leave some things un-filled and asking for them if it needs them. If you don't want your code being interrupted to ask for a password, provide one programatically.
8
-
9
- This is a complete rewrite of StreetCreds 0.1 and is definitely not backwards-compatible. It's barely the same thing.
10
-
11
- ## Usage
12
-
13
- Use it like this:
14
- ```ruby
15
- # #convert_on_valid is false by default and will assume you want to encrypt a valid YAML file
16
- # if it hasn't been encrypted already.
17
- cf = StreetCreds::CredFile.new(filepath: '~/mycreds.yml', convert_on_valid: true)
18
-
19
- # Add a cred via code:
20
- cf['github'] = {'username' => 'wwboynton', password: 'xxxxxxxxxxxxxx'}
21
- # Worth noting, all your keys will be recursively symbolized. Hope that's okay.
22
-
23
- # #inspect is overridden and will #inspect the internal hash.
24
- # This will show all values, including passwords and sensitive data!
25
- puts cf.inspect
26
-
27
- # Save back to the file. This will always be encrypted.
28
- cf.save
29
-
30
- # Decrypt a file in-place
31
- StreetCreds::CredFile.decrypt_existing_file(filepath: '~/mycreds.yml')
32
-
33
- # You can encrypt-in-place too, but you could also just use #convert_on_valid
34
- StreetCreds::CredFile.encrypt_existing_file(filepath: '~/mycreds.yml')
35
-
36
- ```
37
-
38
- ## License
39
-
40
- It's MIT. Do whatever.
41
-
42
- ## Contributing
43
-
44
- I guess you can PR if you really want to. I'd probably look at it.
data/lib/streetcreds.rb DELETED
@@ -1,9 +0,0 @@
1
- require 'streetcred/version'
2
- require 'streetcred/cred_file'
3
- require 'encrypted_strings'
4
- require 'streetcred/patches/openssl_cipher_patch'
5
- require 'yaml'
6
- require 'streetcred/patches/yaml_patch'
7
- require 'fileutils'
8
- require 'pp'
9
- # require 'byebug'
@@ -1,85 +0,0 @@
1
- module StreetCred
2
- class CredFile
3
- def self.encrypt_existing_file(filepath:)
4
- filepath = full_path(filepath)
5
- hash = YAML.load(File.open(filepath))
6
- new(filepath: filepath, hash: hash)
7
- end
8
-
9
- def self.decrypt_existing_file(filepath:)
10
- filepath = full_path(filepath)
11
- decrypted_contents = new(filepath: filepath).decrypt_file
12
- File.open(filepath, 'w+') { |f| f.write(decrypted_contents) }
13
- end
14
-
15
- def initialize(filepath:, hash: nil, convert_on_valid: false, password: nil)
16
- @filepath = self.class.full_path(filepath)
17
- @password = password
18
- load_file(hash: hash, convert_on_valid: convert_on_valid)
19
- end
20
-
21
- def load_file(convert_on_valid:, hash: nil)
22
- if hash.nil?
23
- begin
24
- file_contents = File.read(@filepath)
25
- return @hash = {} if file_contents.empty?
26
- @hash = YAMLHelper.load_if_valid(file_contents) if convert_on_valid
27
- @hash = YAMLHelper.load_if_valid(decrypt_file) unless @hash
28
- rescue Errno::ENOENT
29
- @hash = {}
30
- end
31
- end
32
- @hash = self.class.symbolize_keys(@hash)
33
- end
34
-
35
- def decrypt_file(contents: nil, password: nil)
36
- contents = File.read(@filepath) unless contents
37
- password = ask_password if password.nil?
38
- contents.decrypt(:symmetric, :password => password)
39
- end
40
-
41
- def save
42
- FileUtils.mkdir_p(File.dirname(@filepath))
43
- yaml = self.class.symbolize_keys(@hash).to_yaml
44
- if yaml.empty?
45
- File.delete(@filepath)
46
- else
47
- encrypted_yaml = encrypt_file(contents: yaml)
48
- File.open(@filepath, 'w+') { |f| f.write(encrypted_yaml) }
49
- end
50
- end
51
-
52
- def encrypt_file(contents:, password: nil)
53
- password = ask_password if password.nil?
54
- contents.encrypt(:symmetric, :password => password)
55
- end
56
-
57
- def ask_password
58
- return @password if @password
59
- print "Password?\n> "
60
- @password = $stdin.noecho(&:gets).chomp
61
- puts ''
62
- @password
63
- end
64
-
65
- def inspect
66
- @hash.inspect
67
- end
68
-
69
- # Act like a hash
70
- def method_missing(meth, *args)
71
- @hash.send(meth, *args)
72
- end
73
-
74
- def self.full_path(filepath)
75
- Pathname.new(filepath).expand_path.to_s
76
- end
77
-
78
- # Adapted from https://stackoverflow.com/a/8379653/5637619
79
- def self.symbolize_keys(hash)
80
- Hash[hash.map do |k, v|
81
- [k.to_sym, (v.is_a?(Hash) ? symbolize_keys(v) : v)]
82
- end]
83
- end
84
- end
85
- end
@@ -1,12 +0,0 @@
1
- require 'encrypted_strings'
2
-
3
- # I know monkey patches are bad, but this warning is annoying and the encrypted_strings guys haven't accepted that PR.
4
- module EncryptedStrings
5
- class SymmetricCipher
6
- def build_cipher(type) #:nodoc:
7
- cipher = OpenSSL::Cipher.new(algorithm).send(type)
8
- cipher.pkcs5_keyivgen(password)
9
- cipher
10
- end
11
- end
12
- end
@@ -1,9 +0,0 @@
1
- module YAMLHelper
2
- def self.load_if_valid(str)
3
- res = YAML.load(str)
4
- return false unless res.is_a?(Hash)
5
- res
6
- # rescue Exception => e
7
- # return false
8
- end
9
- end
@@ -1,3 +0,0 @@
1
- module StreetCreds
2
- VERSION = "0.2.1"
3
- end
data/streetcreds.gemspec DELETED
@@ -1,36 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "streetcreds/version"
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "streetcreds"
8
- spec.version = StreetCreds::VERSION
9
- spec.authors = ["Wesley Boynton"]
10
- spec.email = ["wes@boynton.io"]
11
-
12
- spec.summary = %q{Dead-simple password-based encryption and decryption of some yaml configuration files}
13
- spec.license = "MIT"
14
-
15
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
16
- # to allow pushing to a single host or delete this section to allow pushing to any host.
17
- # if spec.respond_to?(:metadata)
18
- # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
19
- # else
20
- # raise "RubyGems 2.0 or newer is required to protect against " \
21
- # "public gem pushes."
22
- # end
23
-
24
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
25
- f.match(%r{^(test|spec|features)/})
26
- end
27
- spec.bindir = "exe"
28
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
- spec.require_paths = ["lib"]
30
-
31
- spec.add_runtime_dependency "encrypted_strings"
32
-
33
- spec.add_development_dependency "bundler", "~> 1.15"
34
- spec.add_development_dependency "rake", "~> 10.0"
35
- spec.add_development_dependency "byebug"
36
- end