shellject 0.3.0 → 1.0.1

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: f852ab84afcd6024a06c8800f9548070d46fab84
4
- data.tar.gz: 265c5405d7f35afa07ff55ba6713299baa3d1359
3
+ metadata.gz: 1adad2b5bf6230314ff760499cc1d72499bdaf42
4
+ data.tar.gz: 0ed395b9b253f34fa69f8273b1964acf61194381
5
5
  SHA512:
6
- metadata.gz: b683257c6b4260a07cfb8ea57e3fd99d113c8c7b50f3c17dc933fb0f59649979dd7d033c306a55ef0070e837861211bf9c898ae250f8e60129d6afe829def48e
7
- data.tar.gz: d4100ca8c408ba0875d5ce6fed1b65360a37ff5edb73b71feea306e6b491926019a45d859780709651e326467103c75b9c6d1a3c64644d4ddbb624a7f1919c7e
6
+ metadata.gz: 245b13ce9b263102c7fa8a583b78fe2c4e204fef29be582ff3bc844140025e62a1d64b47a79268e5d3ceb819f338724bff5b6ccd98b24425c9e8a0d6820dc23a
7
+ data.tar.gz: 571f066016d01375efb5fcfc9dcd7a9b8f4354c499a2f00e5e1e0ec43b936dd6e95531335e149f12797d35187941eb04cbe8bdc0ebaa77dd2613fcb95ab3916f
data/README.md CHANGED
@@ -41,8 +41,30 @@ Store your secret environment variables (API keys, AWS secrets etc.) with GPGME,
41
41
 
42
42
  ## Usage
43
43
 
44
- $ shellject --help
45
-
44
+ ### Creating a new shelljection
45
+ 1. Create a text file with the shell code you wish to have securely injected. Here's one we prepared earlier:
46
+
47
+ `$ cat my-secret-stuff.sh`
48
+ ```
49
+ export SECRET_APIKEY=abc123
50
+ export OTHER_VAR=stuff
51
+ ```
52
+ 1. Save the file contents as a shelljection:
53
+ `$ shellject save --name stuff my-secret-stuff.sh`
54
+ 1. Test the shelljection:
55
+
56
+ `$ shellject load stuff`
57
+
58
+ `echo $SECRET_APIKEY # "abc123"`
59
+
60
+ `echo $OTHER_VAR # "stuff"`
61
+ 1. *REMOVE THE ORIGINAL FILE!*
62
+ 1. Now, you can securely load the enviroment variables whenever you wish:
63
+
64
+ `$ shellject load stuff`
65
+
66
+ ###For further help and options:
67
+ `$ shellject --help`
46
68
  ## Development
47
69
 
48
70
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec shellject` to use the code located in this directory, ignoring other installed copies of this gem.
@@ -0,0 +1,8 @@
1
+ module Shellject
2
+ # Factory method for creating crypto instances.
3
+ module CryptoFactory
4
+ def self.create
5
+ GPGME::Crypto.new always_trust: true
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ module Shellject
2
+ module Tasks
3
+ # A task that needs access to a crypto instance
4
+ module CryptoTask
5
+ def crypto
6
+ @crypto ||= CryptoFactory.create
7
+ end
8
+ end
9
+ end
10
+ end
@@ -2,6 +2,7 @@ module Shellject
2
2
  module Tasks
3
3
  # Loads, decrypts, and outputs a shelljection
4
4
  class Load
5
+ include CryptoTask
5
6
  attr_reader :save_directory, :name
6
7
 
7
8
  def initialize(save_directory, name)
@@ -20,7 +21,7 @@ module Shellject
20
21
  private
21
22
 
22
23
  def ensure_readable
23
- fail ShelljectError, "Could not read file #{path}" unless readable?
24
+ raise ShelljectError, "Could not read file #{path}" unless readable?
24
25
  end
25
26
 
26
27
  def readable?
@@ -30,10 +31,6 @@ module Shellject
30
31
  def path
31
32
  @path ||= save_directory.path_for name
32
33
  end
33
-
34
- def crypto
35
- GPGME::Crypto.new always_trust: true
36
- end
37
34
  end
38
35
  end
39
36
  end
@@ -2,6 +2,7 @@ module Shellject
2
2
  module Tasks
3
3
  # Encrypts and saves a file as a shelljection.
4
4
  class Save
5
+ include CryptoTask
5
6
  attr_reader :save_directory, :input_path, :name
6
7
 
7
8
  def initialize(save_directory, input_path, name = nil)
@@ -31,7 +32,7 @@ module Shellject
31
32
 
32
33
  def ensure_writable
33
34
  FileUtils.mkdir_p(output_path.parent)
34
- fail ShelljectError, "Cannot save to #{output_path}" unless writable?
35
+ raise ShelljectError, "Cannot save to #{output_path}" unless writable?
35
36
  end
36
37
 
37
38
  def writable?
@@ -39,7 +40,7 @@ module Shellject
39
40
  end
40
41
 
41
42
  def ensure_readable
42
- fail ShelljectError, "Cannot read file #{input_path}" unless readable?
43
+ raise ShelljectError, "Cannot read file #{input_path}" unless readable?
43
44
  end
44
45
 
45
46
  def readable?
@@ -53,10 +54,6 @@ module Shellject
53
54
  def name
54
55
  @name ||= File.basename(input_path)
55
56
  end
56
-
57
- def crypto
58
- GPGME::Crypto.new always_trust: true
59
- end
60
57
  end
61
58
  end
62
59
  end
@@ -1,4 +1,4 @@
1
1
  # Provides the gem version.
2
2
  module Shellject
3
- VERSION = '0.3.0'
3
+ VERSION = '1.0.1'.freeze
4
4
  end
data/lib/shellject.rb CHANGED
@@ -5,6 +5,8 @@ require 'gpgme'
5
5
 
6
6
  require 'shellject/version'
7
7
  require 'shellject/save_directory'
8
+ require 'shellject/crypto_factory'
9
+ require 'shellject/tasks/crypto_task'
8
10
  require 'shellject/tasks/load'
9
11
  require 'shellject/tasks/save'
10
12
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shellject
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergei Matheson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-02-18 00:00:00.000000000 Z
11
+ date: 2016-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gpgme
@@ -188,7 +188,9 @@ files:
188
188
  - config.reek
189
189
  - exe/shellject
190
190
  - lib/shellject.rb
191
+ - lib/shellject/crypto_factory.rb
191
192
  - lib/shellject/save_directory.rb
193
+ - lib/shellject/tasks/crypto_task.rb
192
194
  - lib/shellject/tasks/load.rb
193
195
  - lib/shellject/tasks/save.rb
194
196
  - lib/shellject/version.rb