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 +4 -4
- data/README.md +24 -2
- data/lib/shellject/crypto_factory.rb +8 -0
- data/lib/shellject/tasks/crypto_task.rb +10 -0
- data/lib/shellject/tasks/load.rb +2 -5
- data/lib/shellject/tasks/save.rb +3 -6
- data/lib/shellject/version.rb +1 -1
- data/lib/shellject.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1adad2b5bf6230314ff760499cc1d72499bdaf42
|
4
|
+
data.tar.gz: 0ed395b9b253f34fa69f8273b1964acf61194381
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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.
|
data/lib/shellject/tasks/load.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/shellject/tasks/save.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
data/lib/shellject/version.rb
CHANGED
data/lib/shellject.rb
CHANGED
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.
|
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:
|
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
|