diffcrypt 0.2.0 → 0.3.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 +45 -0
- data/README.md +24 -6
- data/bin/diffcrypt +8 -0
- data/diffcrypt.gemspec +3 -2
- data/lib/diffcrypt/cli.rb +43 -0
- data/lib/diffcrypt/encryptor.rb +2 -0
- data/lib/diffcrypt/version.rb +1 -1
- metadata +22 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6055430f063cb4f1c161ca44b65e2d3a0a15d134546152c2e9e0b39486737f08
|
4
|
+
data.tar.gz: 4332842bbef701c1b775e1de410391f07e5bf477318727e0412afb29d0ba00a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d9b0a443e3d2521ba45385a57522d289fad5c9fa88707e5d6272ac0b23dcc4ee8dee9fc6c1831794468399917dccf95747ab0ac5c391c40ebcb991bbc7ebb22
|
7
|
+
data.tar.gz: '038974890091043cec270fb775b94705522445c1185fe07856d5558cbb970d96cfc86dfedfba8081f83a6ccc593e863b32df08f59a3916dc0a1c6e1fa4ceaf45'
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
## [0.3.0] - 2020-06-30
|
11
|
+
|
12
|
+
## Added
|
13
|
+
|
14
|
+
- CLI: Use diffcrypt from command line of any project without requiring ruby integration
|
15
|
+
- CLI: `diffcrypt encrypt` Directly encrypt any file and output the contents
|
16
|
+
- CLI: `diffcrypt decrypt` Directly decrypt any file and output the contents
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
## [0.2.0] - 2020-06-28
|
21
|
+
|
22
|
+
### Added
|
23
|
+
|
24
|
+
- Store client, cipher and checksum in file metadata
|
25
|
+
|
26
|
+
### Fixed
|
27
|
+
|
28
|
+
- Only attenpt to decrypt original content if it exists
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
## [0.1.1] - 2020-06-28
|
33
|
+
|
34
|
+
### Fixed
|
35
|
+
|
36
|
+
- Converting rails native credentials files would fail on first run
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
## [0.1.0] - 2020-06-28
|
41
|
+
|
42
|
+
### Added
|
43
|
+
|
44
|
+
- First release!
|
45
|
+
- Rails support via monkey patch
|
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Diffcrypt
|
2
2
|
|
3
|
+
[](https://rubygems.org/gems/diffcrypt)
|
4
|
+
[](https://circleci.com/gh/marcqualie/diffcrypt)
|
5
|
+
|
6
|
+
|
3
7
|
Diffable encrypted files that you can safely commit into your repo.
|
4
8
|
|
5
9
|
|
@@ -16,7 +20,7 @@ And then execute:
|
|
16
20
|
|
17
21
|
$ bundle install
|
18
22
|
|
19
|
-
Or install it
|
23
|
+
Or install it globally (to use the CLI from any project):
|
20
24
|
|
21
25
|
$ gem install diffcrypt
|
22
26
|
|
@@ -24,8 +28,24 @@ Or install it yourself as:
|
|
24
28
|
|
25
29
|
## Usage
|
26
30
|
|
31
|
+
There are a few ways to use the library, depending on how advanced your use case is.
|
32
|
+
|
27
33
|
|
28
|
-
###
|
34
|
+
### CLI
|
35
|
+
|
36
|
+
The easiest way to get started is to use the CLI.
|
37
|
+
|
38
|
+
```shell
|
39
|
+
diffcrypt decrypt -k $(cat test/fixtures/master.key) test/fixtures/example.yml.enc
|
40
|
+
diffcrypt encrypt -k $(cat test/fixtures/master.key) test/fixtures/example.yml
|
41
|
+
```
|
42
|
+
|
43
|
+
|
44
|
+
### Ruby
|
45
|
+
|
46
|
+
A direct API is exposed so `Diffcrypt::Encryptor` can be used in any ruby project.
|
47
|
+
|
48
|
+
**NOTE:** This API may change any time until v1.0
|
29
49
|
|
30
50
|
```ruby
|
31
51
|
encryptor = Diffcrypt::Encryptor.new('99e1f86b9e61f24c56ff4108dd415091')
|
@@ -34,18 +54,16 @@ encrypted = encryptor.encrypt(yaml)
|
|
34
54
|
File.write('tmp/example.yml.enc', encrypted)
|
35
55
|
```
|
36
56
|
|
37
|
-
### Decrypt a file
|
38
|
-
|
39
57
|
```ruby
|
40
58
|
encryptor = Diffcrypt::Encryptor.new('99e1f86b9e61f24c56ff4108dd415091')
|
41
59
|
yaml = File.read('test/fixtures/example.yml.enc')
|
42
60
|
config = YAML.safe_load(encryptor.decrypt(yaml))
|
43
61
|
```
|
44
62
|
|
45
|
-
### Rails
|
63
|
+
### Ruby on Rails
|
46
64
|
|
47
65
|
Currently there is not native support for rails, but ActiveSupport can be monkeypatched to override
|
48
|
-
the built in encrypter.
|
66
|
+
the built in encrypter. All existing `rails credentials:edit` also work with this method.
|
49
67
|
|
50
68
|
```ruby
|
51
69
|
require 'diffcrypt/rails/encrypted_configuration'
|
data/bin/diffcrypt
ADDED
data/diffcrypt.gemspec
CHANGED
@@ -25,9 +25,10 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
26
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
27
27
|
end
|
28
|
-
spec.bindir = '
|
29
|
-
spec.executables =
|
28
|
+
spec.bindir = 'bin'
|
29
|
+
spec.executables = %w[diffcrypt]
|
30
30
|
spec.require_paths = ['lib']
|
31
31
|
|
32
32
|
spec.add_runtime_dependency 'activesupport', '~> 6.0.0'
|
33
|
+
spec.add_runtime_dependency 'thor', '~> 1.0.1'
|
33
34
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './encryptor'
|
4
|
+
require_relative './version'
|
5
|
+
|
6
|
+
module Diffcrypt
|
7
|
+
class CLI < Thor
|
8
|
+
desc 'decrypt <path>', 'Decrypt a file'
|
9
|
+
method_option :key, aliases: %i[k], required: true
|
10
|
+
def decrypt(path)
|
11
|
+
ensure_file_exists(path)
|
12
|
+
contents = File.read(path)
|
13
|
+
puts encryptor.decrypt(contents)
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'encrypt <path>', 'Encrypt a file'
|
17
|
+
method_option :key, aliases: %i[k], required: true
|
18
|
+
def encrypt(path)
|
19
|
+
ensure_file_exists(path)
|
20
|
+
contents = File.read(path)
|
21
|
+
puts encryptor.encrypt(contents)
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'version', 'Show client version'
|
25
|
+
def version
|
26
|
+
say Diffcrypt::VERSION
|
27
|
+
end
|
28
|
+
|
29
|
+
no_commands do
|
30
|
+
def key
|
31
|
+
options[:key]
|
32
|
+
end
|
33
|
+
|
34
|
+
def encryptor
|
35
|
+
@encryptor ||= Encryptor.new(key)
|
36
|
+
end
|
37
|
+
|
38
|
+
def ensure_file_exists(path)
|
39
|
+
abort('[ERROR] File does not exist') unless File.exist?(path)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/diffcrypt/encryptor.rb
CHANGED
data/lib/diffcrypt/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diffcrypt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc Qualie
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -24,11 +24,26 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 6.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.0.1
|
27
41
|
description: Diffable encrypted configuration files that can be safely committed into
|
28
42
|
a git repository
|
29
43
|
email:
|
30
44
|
- marc@marcqualie.com
|
31
|
-
executables:
|
45
|
+
executables:
|
46
|
+
- diffcrypt
|
32
47
|
extensions: []
|
33
48
|
extra_rdoc_files: []
|
34
49
|
files:
|
@@ -36,14 +51,17 @@ files:
|
|
36
51
|
- ".github/dependabot.yml"
|
37
52
|
- ".gitignore"
|
38
53
|
- ".rubocop.yml"
|
54
|
+
- CHANGELOG.md
|
39
55
|
- Gemfile
|
40
56
|
- LICENSE.txt
|
41
57
|
- README.md
|
42
58
|
- Rakefile
|
43
59
|
- bin/console
|
60
|
+
- bin/diffcrypt
|
44
61
|
- bin/setup
|
45
62
|
- diffcrypt.gemspec
|
46
63
|
- lib/diffcrypt.rb
|
64
|
+
- lib/diffcrypt/cli.rb
|
47
65
|
- lib/diffcrypt/encryptor.rb
|
48
66
|
- lib/diffcrypt/rails/encrypted_configuration.rb
|
49
67
|
- lib/diffcrypt/version.rb
|