eyaml 0.1.0 → 0.2.0

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
  SHA256:
3
- metadata.gz: e589d4929a268cf0c2d783b52e67da11a5ddea2a471f826f5d440de02b39f56e
4
- data.tar.gz: 1f94b57be40ec52893b62aea8f16ee0a81a997b69672852c3430553e2aa24f5f
3
+ metadata.gz: c4f178a1f6b7fb06fde94557868732ec3b13a6d90f5682f2505f29c7c3699dfe
4
+ data.tar.gz: 63434158bf5b56334cefbf3d73da83e357a39f02e17c7aaad2e63d0622ee70b5
5
5
  SHA512:
6
- metadata.gz: 6a1ba5c9640edbe938325c02290405c102ba10f7a68f01c7701740944a208cf531abdc95b94f3ed730e9db90ebf89db848eedf6ad45eec7ddf6b39c362b4480f
7
- data.tar.gz: 4e3490d63c5319fa6855a4257fe848663709ecc4e1d54105332f9b2a30352edf0a9221999f58a1a5ba61165721ef0d3627a5c166204a533ac55c6a6c4b6b29c1
6
+ metadata.gz: 945cb549642f915c0ecb60c2fc55709dced0e4805b7e3367657cb2daee7242995d8b09ab6fd0546e58334b557bd6bcb9ca03f8e13d3f1484c71d90ea0ba47b91
7
+ data.tar.gz: db020b6d97d9f8296d8ec8c51101d2db12deb04535c89bec2949a256a6fb2e0854a910e9e08b3b160f265878b68594040d41ace1263ad49477dcecdddf03baf2
@@ -0,0 +1,12 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "bundler"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
7
+
8
+ - package-ecosystem: "github-actions"
9
+ # Checks for workflow files stored in the default location of `.github/workflows`
10
+ directory: "/"
11
+ schedule:
12
+ interval: "weekly"
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ *.gem
data/Gemfile CHANGED
@@ -4,7 +4,7 @@ source "https://rubygems.org"
4
4
 
5
5
  gemspec
6
6
 
7
- gem "ffi", github: "cheddar-me/ffi", branch: "apple-m1", submodules: true
7
+ gem "ffi", "~> 1.15.5"
8
8
  gem "rbnacl"
9
9
 
10
10
  gem "railties"
data/Gemfile.lock CHANGED
@@ -1,75 +1,70 @@
1
- GIT
2
- remote: https://github.com/cheddar-me/ffi.git
3
- revision: 6d091e74c04c4bae9680c47595d58e879469790c
4
- branch: apple-m1
5
- submodules: true
6
- specs:
7
- ffi (1.15.0)
8
-
9
1
  PATH
10
2
  remote: .
11
3
  specs:
12
- eyaml (0.1.0)
4
+ eyaml (0.2.0)
13
5
  rbnacl (~> 7.1)
14
6
  thor (~> 1.1)
15
7
 
16
8
  GEM
17
9
  remote: https://rubygems.org/
18
10
  specs:
19
- actionpack (6.1.3.1)
20
- actionview (= 6.1.3.1)
21
- activesupport (= 6.1.3.1)
22
- rack (~> 2.0, >= 2.0.9)
11
+ actionpack (7.0.1)
12
+ actionview (= 7.0.1)
13
+ activesupport (= 7.0.1)
14
+ rack (~> 2.0, >= 2.2.0)
23
15
  rack-test (>= 0.6.3)
24
16
  rails-dom-testing (~> 2.0)
25
17
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
26
- actionview (6.1.3.1)
27
- activesupport (= 6.1.3.1)
18
+ actionview (7.0.1)
19
+ activesupport (= 7.0.1)
28
20
  builder (~> 3.1)
29
21
  erubi (~> 1.4)
30
22
  rails-dom-testing (~> 2.0)
31
23
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
32
- activesupport (6.1.3.1)
24
+ activesupport (7.0.1)
33
25
  concurrent-ruby (~> 1.0, >= 1.0.2)
34
26
  i18n (>= 1.6, < 2)
35
27
  minitest (>= 5.1)
36
28
  tzinfo (~> 2.0)
37
- zeitwerk (~> 2.3)
38
29
  builder (3.2.4)
39
30
  coderay (1.1.3)
40
- concurrent-ruby (1.1.8)
31
+ concurrent-ruby (1.1.9)
41
32
  crass (1.0.6)
42
- diff-lcs (1.4.4)
33
+ diff-lcs (1.5.0)
43
34
  erubi (1.10.0)
44
- fakefs (1.3.2)
45
- i18n (1.8.10)
35
+ fakefs (1.4.0)
36
+ ffi (1.15.5)
37
+ i18n (1.8.11)
46
38
  concurrent-ruby (~> 1.0)
47
- loofah (2.9.0)
39
+ loofah (2.13.0)
48
40
  crass (~> 1.0.2)
49
41
  nokogiri (>= 1.5.9)
50
42
  method_source (1.0.0)
51
- minitest (5.14.4)
52
- nokogiri (1.11.2-arm64-darwin)
43
+ minitest (5.15.0)
44
+ nokogiri (1.13.0-arm64-darwin)
45
+ racc (~> 1.4)
46
+ nokogiri (1.13.0-x86_64-linux)
53
47
  racc (~> 1.4)
54
- pry (0.14.0)
48
+ pry (0.14.1)
55
49
  coderay (~> 1.1)
56
50
  method_source (~> 1.0)
57
- racc (1.5.2)
51
+ racc (1.6.0)
58
52
  rack (2.2.3)
59
53
  rack-test (1.1.0)
60
54
  rack (>= 1.0, < 3)
61
55
  rails-dom-testing (2.0.3)
62
56
  activesupport (>= 4.2.0)
63
57
  nokogiri (>= 1.6)
64
- rails-html-sanitizer (1.3.0)
58
+ rails-html-sanitizer (1.4.2)
65
59
  loofah (~> 2.3)
66
- railties (6.1.3.1)
67
- actionpack (= 6.1.3.1)
68
- activesupport (= 6.1.3.1)
60
+ railties (7.0.1)
61
+ actionpack (= 7.0.1)
62
+ activesupport (= 7.0.1)
69
63
  method_source
70
- rake (>= 0.8.7)
64
+ rake (>= 12.2)
71
65
  thor (~> 1.0)
72
- rake (13.0.3)
66
+ zeitwerk (~> 2.5)
67
+ rake (13.0.6)
73
68
  rbnacl (7.1.1)
74
69
  ffi
75
70
  rspec (3.10.0)
@@ -84,19 +79,20 @@ GEM
84
79
  rspec-mocks (3.10.2)
85
80
  diff-lcs (>= 1.2.0, < 2.0)
86
81
  rspec-support (~> 3.10.0)
87
- rspec-support (3.10.2)
88
- thor (1.1.0)
82
+ rspec-support (3.10.3)
83
+ thor (1.2.1)
89
84
  tzinfo (2.0.4)
90
85
  concurrent-ruby (~> 1.0)
91
- zeitwerk (2.4.2)
86
+ zeitwerk (2.5.3)
92
87
 
93
88
  PLATFORMS
94
89
  arm64-darwin-20
90
+ x86_64-linux
95
91
 
96
92
  DEPENDENCIES
97
93
  eyaml!
98
94
  fakefs
99
- ffi!
95
+ ffi (~> 1.15.5)
100
96
  pry
101
97
  railties
102
98
  rake (~> 13.0)
data/bin/publish ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ gem build eyaml
6
+ gem push $(ls -t *.gem | head -1)
data/lib/eyaml/cli.rb CHANGED
@@ -2,18 +2,13 @@ module EYAML
2
2
  class InvalidFormatError < StandardError; end
3
3
 
4
4
  class CLI < Thor
5
- class_option :keydir, aliases: "-k", type: :string, desc: "Directory containing EYAML keys"
6
-
7
5
  desc "encrypt", "(Re-)encrypt one or more EYAML files"
8
6
  def encrypt(*files)
9
7
  files.each do |file|
10
8
  file_path = Pathname.new(file)
11
9
  next unless file_path.exist?
12
10
 
13
- bytes_written = EYAML.encrypt_file_in_place(
14
- file_path,
15
- keydir: options.fetch(:keydir, nil)
16
- )
11
+ bytes_written = EYAML.encrypt_file_in_place(file_path)
17
12
 
18
13
  puts "Wrote #{bytes_written} bytes to #{file_path}."
19
14
  end
@@ -21,6 +16,7 @@ module EYAML
21
16
 
22
17
  method_option :output, type: :string, desc: "print output to the provided file, rather than stdout", aliases: "-o"
23
18
  method_option :"key-from-stdin", type: :boolean, desc: "read the private key from STDIN", default: false
19
+ method_option :keydir, type: :string, desc: "Directory containing EYAML keys", aliases: "-k"
24
20
  desc "decrypt", "Decrypt an EYAML file"
25
21
  def decrypt(file)
26
22
  file_path = Pathname.new(file)
@@ -48,6 +44,7 @@ module EYAML
48
44
  end
49
45
 
50
46
  method_option :write, type: :boolean, aliases: "-w", desc: "rather than printing both keys, print the public and write the private into the keydir", default: false
47
+ method_option :keydir, type: :string, desc: "Directory containing EYAML keys", aliases: "-k"
51
48
  desc "keygen", "Generate a new EYAML keypair"
52
49
  def keygen
53
50
  public_key, private_key = EYAML.generate_keypair(
@@ -16,10 +16,10 @@ module EYAML
16
16
  end
17
17
  end
18
18
 
19
- def initialize(yaml, public_key, private_key)
19
+ def initialize(yaml, public_key, private_key = nil)
20
20
  @tree = yaml
21
- @public_key = EYAML::Util.ensure_binary_encoding(public_key)
22
- @private_key = EYAML::Util.ensure_binary_encoding(private_key)
21
+ @public_key = RbNaCl::Util.hex2bin(public_key)
22
+ @private_key = private_key && RbNaCl::Util.hex2bin(private_key.strip)
23
23
  end
24
24
 
25
25
  def decrypt
data/lib/eyaml/util.rb CHANGED
@@ -6,14 +6,6 @@ module EYAML
6
6
  def pretty_yaml(some_hash)
7
7
  some_hash.to_yaml.delete_prefix("---\n")
8
8
  end
9
-
10
- def ensure_binary_encoding(str)
11
- if str.encoding == Encoding::BINARY
12
- return str
13
- end
14
-
15
- RbNaCl::Util.hex2bin(str)
16
- end
17
9
  end
18
10
  end
19
11
  end
data/lib/eyaml/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EYAML
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/eyaml.rb CHANGED
@@ -26,17 +26,16 @@ module EYAML
26
26
  [public_key, private_key]
27
27
  end
28
28
 
29
- def encrypt(plaindata, keydir: nil)
29
+ def encrypt(plaindata)
30
30
  public_key = load_public_key(plaindata)
31
- private_key = load_private_key_from(public_key: public_key, keydir: keydir)
32
31
 
33
- encryption_manager = EncryptionManager.new(plaindata, public_key, private_key)
32
+ encryption_manager = EncryptionManager.new(plaindata, public_key)
34
33
  encryption_manager.encrypt
35
34
  end
36
35
 
37
- def encrypt_file_in_place(file_path, keydir: nil)
36
+ def encrypt_file_in_place(file_path)
38
37
  plaindata = YAML.load_file(file_path)
39
- cipherdata = encrypt(plaindata, keydir: keydir)
38
+ cipherdata = encrypt(plaindata)
40
39
 
41
40
  eyaml = format_for_file(cipherdata, file_path)
42
41
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eyaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emil Stolarsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-14 00:00:00.000000000 Z
11
+ date: 2022-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -75,6 +75,7 @@ executables:
75
75
  extensions: []
76
76
  extra_rdoc_files: []
77
77
  files:
78
+ - ".github/dependabot.yml"
78
79
  - ".github/workflows/test.yml"
79
80
  - ".gitignore"
80
81
  - ".rspec"
@@ -86,6 +87,7 @@ files:
86
87
  - Rakefile
87
88
  - bin/console
88
89
  - bin/eyaml
90
+ - bin/publish
89
91
  - bin/setup
90
92
  - eyaml.gemspec
91
93
  - lib/eyaml.rb