sym 2.7.0 → 2.8.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
  SHA1:
3
- metadata.gz: 7b37f317d0ff96c9cf5a96c63df07c09bb44b416
4
- data.tar.gz: cc8ca5879102dffbdc67e4c6e813a6d7711bd3aa
3
+ metadata.gz: 6053432fc439cae6524efafc83f10ef5eba1478b
4
+ data.tar.gz: 07a5849debd54dbbbe0716ec72ce21de69b8947e
5
5
  SHA512:
6
- metadata.gz: c638780011463e131e754ec7fc0ee5a1d71f8b3ab6063c3c117123a24639f5e9fb8da981c6e81781681fd966380571ba0fccf5b9883f885ec5b21bf9e8697b7c
7
- data.tar.gz: 82ada53242e4d3ae2350c893edec7da3446e0a740357fda4e11d3e4a2ebb53c29597f429f6ee54c110aefcca86c50b1967eaf3706eaa1ed27c82bff5a0a3dc52
6
+ metadata.gz: 05dd00292348432a11a38fa22964016c949148e093ad8f0f5d71927455024aaf4d7b7ed113f71024d12e62858b9dceb75994f1281b7d0ee09eed4498c6238d6d
7
+ data.tar.gz: 9f69a6b471db6173ff6e7f57d43e99340ddd3e68805e24374233048c686ed04bbb9bc79c7d2ae0eb5f32ab078c1abd2fdc43d907ba7a65b33dea160fc6a69007
@@ -0,0 +1,61 @@
1
+ # Ruby CircleCI 2.0 configuration file
2
+ #
3
+ # Check https://circleci.com/docs/2.0/language-ruby/ for more details
4
+ #
5
+ version: 2
6
+ jobs:
7
+ build:
8
+ docker:
9
+ # specify the version you desire here
10
+ - image: circleci/ruby:2.4.1-node-browsers
11
+
12
+ working_directory: ~/repo
13
+
14
+ steps:
15
+ - checkout
16
+ - restore_cache:
17
+ keys:
18
+ - v1-dependencies-{{ checksum "Gemfile.lock" }}
19
+ - v1-dependencies-
20
+
21
+ - run:
22
+ name: install dependencies
23
+ command: |
24
+ bundle install --jobs=4 --retry=3 --path vendor/bundle
25
+
26
+ - save_cache:
27
+ paths:
28
+ - ./vendor/bundle
29
+ key: v1-dependencies-{{ checksum "Gemfile.lock" }}
30
+
31
+ - run:
32
+ name: install memcached
33
+ command: |
34
+ sudo apt-get update && sudo apt-get install -y memcached
35
+ sudo service start memcached || true
36
+ memcached -d || true
37
+ echo "checking if memcached is running...."
38
+ ps -ef | grep [m]emcached
39
+ # echo 'stats' | nc localhost 11211
40
+ # echo "if we see the stats, memcached is running!"
41
+
42
+ - run:
43
+ name: install sym bash helpers
44
+ command: |
45
+ bundle exec exe/sym -B ~/.bash_profile
46
+
47
+ - run:
48
+ name: run tests
49
+ command: |
50
+ [[ -z ${_bash} && -x /usr/local/bin/bash ]] && _bash=/usr/local/bin/bash
51
+ [[ -z ${_bash} && -x /usr/bin/bash ]] && _bash=/usr/bin/bash
52
+ [[ -z ${_bash} && -x /bin/bash ]] && _bash=/bin/bash
53
+ ${_bash} -l -c "
54
+ export USER=circleci
55
+ export HOME=/home/${USER}/repo
56
+ ruby --version
57
+ bundle exec rspec --version
58
+ bundle exec exe/sym --version
59
+ bundle exec rspec --backtrace --format documentation
60
+ "
61
+
data/.document CHANGED
@@ -1,2 +1,2 @@
1
- lib/ exe/ - README.md LICENSE sym-3.0-cli.md
1
+ lib/ exe/ - README.md LICENSE
2
2
 
data/.gitignore CHANGED
@@ -13,3 +13,4 @@
13
13
  /*.enc
14
14
  **/.DS_Store
15
15
  .ruby-version
16
+ temp/
data/.rspec CHANGED
@@ -1,3 +1,4 @@
1
1
  --format progress
2
2
  --color
3
3
  --order rand
4
+ --profile 2
@@ -1,14 +1,11 @@
1
1
  language: ruby
2
- cache: bundler
3
2
  env:
4
- - CODECLIMATE_REPO_TOKEN=c71874cc22acffe1e2543d3388d3a96c73a65f0cfe17169dadd8de4a6c062c39 TEST_DRB=true
3
+ - CODECLIMATE_REPO_TOKEN=c71874cc22acffe1e2543d3388d3a96c73a65f0cfe17169dadd8de4a6c062c39 TEST_DRB=true HOME=/home/travis USER=travis
5
4
  services:
6
5
  - memcached
7
6
  rvm:
8
- - 2.2.7
9
- - 2.3.4
10
- - 2.4.1
11
- - jruby-9.1.9.0
7
+ - 2.3.5
8
+ - 2.4.2
12
9
  notifications:
13
10
  email:
14
11
  recipients:
@@ -24,3 +21,11 @@ addons:
24
21
  # regular test configuration
25
22
  after_success:
26
23
  - bundle exec codeclimate-test-reporter
24
+ before_script:
25
+ - echo stats | nc localhost 11211
26
+ script:
27
+ - bundle exec exe/sym -B ~/.bash_profile -vTD
28
+ - ls -alF ~/.sym*
29
+ - ls -alF .
30
+ - mkdir -p temp
31
+ - bundle exec rspec --format documentation
@@ -4,6 +4,17 @@
4
4
 
5
5
  [Changes since the last tag](https://github.com/kigster/sym/compare/v2.7.0...HEAD)
6
6
 
7
+ ## [v2.8.0](https://github.com/kigster/sym/tree/v2.8.0) (2018-01-05)
8
+ [Full Changelog](https://github.com/kigster/sym/compare/v2.7.0...v2.8.0)
9
+
10
+ Version 2.8.0 with several key changes below:
11
+
12
+ - Ensuring that Sym exits with a non-zero code when errors occur
13
+ - Ensuring that coverage, and doc folders are removed before release
14
+ - Adding sym-encrypt() and sym-decrypt() BASH helpers
15
+ - Major update to `sym.symit` to provide easier access to commands.
16
+ - Cleaning up output of the errors
17
+
7
18
  ## [v2.7.0](https://github.com/kigster/sym/tree/v2.7.0) (2017-06-23)
8
19
  [Full Changelog](https://github.com/kigster/sym/compare/v2.6.3...v2.7.0)
9
20
 
data/README.md CHANGED
@@ -1,13 +1,15 @@
1
1
  # Sym — Light-weight Symmetric Encryption for Humans
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/sym.svg)](https://badge.fury.io/rb/sym)
4
- [![Downloads](http://ruby-gem-downloads-badge.herokuapp.com/sym?type=total)](https://rubygems.org/gems/sym)
4
+ [![Sym Downloads](http://ruby-gem-downloads-badge.herokuapp.com/sym?extension=png)](https://rubygems.org/gems/sym)
5
5
 
6
6
  [![Build Status](https://travis-ci.org/kigster/sym.svg?branch=master)](https://travis-ci.org/kigster/sym)
7
7
  [![Code Climate](https://codeclimate.com/github/kigster/sym/badges/gpa.svg)](https://codeclimate.com/github/kigster/sym)
8
8
  [![Test Coverage](https://codeclimate.com/github/kigster/sym/badges/coverage.svg)](https://codeclimate.com/github/kigster/sym/coverage)
9
9
  [![Issue Count](https://codeclimate.com/github/kigster/sym/badges/issue_count.svg)](https://codeclimate.com/github/kigster/sym)
10
10
 
11
+ **Discuss Sym on Gitter**:
12
+
11
13
  [![Gitter](https://img.shields.io/gitter/room/gitterHQ/gitter.svg)](https://gitter.im/kigster/sym)
12
14
 
13
15
  ---
@@ -30,10 +32,24 @@ Your donation of absolutely any amount is very much appreciated.
30
32
 
31
33
  <p><strong>sym</strong> uses the <em><a href="https://en.wikipedia.org/wiki/Symmetric-key_algorithm">Symmetric Encryption</a></em> algorithm. This means that the same key is used to encrypt and decrypt data. In addition to the key, the encryption uses a randomized IV vector, which is automatically generated per each encryption and serialized with the data. Result of encryption is zlib-compressed, and base64 encoded, to be suitable for storage as string. The generated keys are also base64-encoded for convenience.</p>
32
34
 
33
- <p>Finally, the library offers encryption using any regular password, and in particular supports password-protected encryption keys. The key can be specified by a filename, environment variable, or OS-X Keychain password entry name, or as is.</p>
35
+ <p>Finally, the library offers encryption using any regular password, and in particular supports password-protected encryption keys. Automatic key detection algorithm attempts to resolve a provided key as a filename, an environment variable name, an OS-X Keychain password entry name, a key itself, or a default key file.</p>
34
36
 
35
37
  </div>
36
38
 
39
+ ### Quick Demo of the CLI in Action
40
+
41
+ [![asciicast](design/ascii-cinema.png)](https://asciinema.org/a/106737)
42
+
43
+
44
+ #### Help Screens, Examples and Symit Bash Wrapper
45
+
46
+ This may be a good time to take a look at the full help message for the `sym` tool, shown naturally with a `-h` or `--help` option. Examples can be shown with `-E/--examples` flag.
47
+
48
+ Additionally, Sym comes with a helpful BASH wrapper `symit`.
49
+
50
+ **Help screens for `sym` and `symit` are shown in full on another page — [Sym Help Screens and Symit](SYM-CLI.md). Please refer to it for complete help screens and the examples.**
51
+
52
+
37
53
  ## Supported Ruby Versions
38
54
 
39
55
  [![Build Status](https://travis-ci.org/kigster/sym.svg?branch=master)](https://travis-ci.org/kigster/sym)
@@ -501,12 +517,6 @@ sym -Adf file.enc -o file.original
501
517
  sym -Atf file.enc
502
518
  ```
503
519
 
504
- #### CLI Help Screen and Examples
505
-
506
- This may be a good time to take a look at the full help message for the `sym` tool, shown naturally with a `-h` or `--help` option. Examples can be shown with `-E/--examples` flag.
507
-
508
- Please take a look at the [SYM-CLI](SYM-CLI.md) for a complete help screen and the examples.
509
-
510
520
  ## Fine Tuning
511
521
 
512
522
  <a name="rubyapi-config"></a>
@@ -611,4 +621,3 @@ Please submit feature requests, bugs, or donations :)
611
621
  * [Barry Anderson](https://twitter.com/z3ndrag0n) (sanity checking, review)
612
622
 
613
623
 
614
-
data/Rakefile CHANGED
@@ -2,13 +2,21 @@ require 'bundler/gem_tasks'
2
2
  require 'rspec/core/rake_task'
3
3
  require 'yard'
4
4
 
5
+
5
6
  def shell(*args)
6
7
  puts "running: #{args.join(' ')}"
7
8
  system(args.join(' '))
8
9
  end
9
10
 
10
- task :permissions do
11
- shell('rm -rf pkg/')
11
+ task :clean do
12
+ shell('rm -rf pkg/ tmp/ coverage/ doc/ ' )
13
+ end
14
+
15
+ task :gem => [:build] do
16
+ shell('gem install pkg/*')
17
+ end
18
+
19
+ task :permissions => [ :clean ] do
12
20
  shell("chmod -v o+r,g+r * */* */*/* */*/*/* */*/*/*/* */*/*/*/*/*")
13
21
  shell("find . -type d -exec chmod o+x,g+x {} \\;")
14
22
  end
@@ -16,7 +24,7 @@ end
16
24
  task :build => :permissions
17
25
 
18
26
  YARD::Rake::YardocTask.new(:doc) do |t|
19
- t.files = %w(lib/**/*.rb exe/*.rb - README.md LICENSE sym-3.0-cli.md)
27
+ t.files = %w(lib/**/*.rb exe/*.rb - README.md LICENSE)
20
28
  t.options.unshift('--title','"Sym – Symmetric Key Encryption for Your Data"')
21
29
  t.after = ->() { exec('open doc/index.html') }
22
30
  end
data/SYM-CLI.md CHANGED
@@ -1,143 +1,20 @@
1
1
  # Sym CLI Help Screen
2
2
 
3
- ```text
4
- Sym (2.5.1) – encrypt/decrypt data with a private key
3
+ ### Sym Help
5
4
 
6
- Usage:
7
- Generate a new key, optionally password protected, and save it
8
- in one of: keychain, file, or STDOUT (-q turns off STDOUT)
9
-
10
- sym -g [ -p/--password ] [-c] [-x keychain | -o file | ] [-q]
5
+ Below is the HELP screen for Sym:
11
6
 
12
- To specify encryption key, provide the key as
13
- 1) a string, 2) a file path, 3) an OS-X Keychain, 4) env variable name
14
- 5) use -i to paste/type the key interactively
15
- 6) default key file (if present) at /Users/kig/.sym.key
16
-
17
- KEY-SPEC = -k/--key [ key | file | keychain | env variable name ]
18
- -i/--interactive
7
+ ![examples](design/sym-help.png)
19
8
 
20
- Encrypt/Decrypt from STDIN/file/args, to STDOUT/file:
21
-
22
- sym -e/--encrypt KEY-SPEC [-f [file | - ] | -s string ] [-o file]
23
- sym -d/--decrypt KEY-SPEC [-f [file | - ] | -s string ] [-o file]
9
+ ### Additional Sym Examples
24
10
 
25
- Auto-detect mode based on a special file extension ".enc"
26
-
27
- sym -n/--negate KEY-SPEC file[.enc]
28
-
29
- Edit an encrypted file in $EDITOR
30
-
31
- sym -t/--edit KEY-SPEC -f file [ -b/--backup ]
32
-
33
- Save commonly used flags in a BASH variable. Below we save the KeyChain
34
- "staging" as the default key name, and enable password caching.
35
-
36
- export SYM_ARGS="-ck staging"
37
-
38
- Then activate $SYM_ARGS by using -A/--sym-args flag:
39
-
40
- sym -Aef file
41
-
42
- Modes:
43
- -e, --encrypt encrypt mode
44
- -d, --decrypt decrypt mode
45
- -t, --edit edit encrypted file in an $EDITOR
46
- -n, --negate [file] encrypts any regular file into file.enc
47
- conversely decrypts file.enc into file.
48
-
49
- Create a new private key:
50
- -g, --generate generate a new private key
51
- -p, --password encrypt the key with a password
52
- -x, --keychain [key-name] write the key to OS-X Keychain
53
-
54
- Read existing private key from:
55
- -k, --key [key-spec] private key, key file, or keychain
56
- -i, --interactive Paste or type the key interactively
57
-
58
- Password Cache:
59
- -c, --cache-passwords enable password cache
60
- -u, --cache-timeout [seconds] expire passwords after
61
- -r, --cache-provider [provider] cache provider, one of memcached, drb
62
-
63
- Data to Encrypt/Decrypt:
64
- -s, --string [string] specify a string to encrypt/decrypt
65
- -f, --file [file] filename to read from
66
- -o, --output [file] filename to write to
67
-
68
- Flags:
69
- -b, --backup create a backup file in the edit mode
70
- -v, --verbose show additional information
71
- -q, --quiet do not print to STDOUT
72
- -T, --trace print a backtrace of any errors
73
- -D, --debug print debugging information
74
- -V, --version print library version
75
- -N, --no-color disable color output
76
- -A, --sym-args read more CLI arguments from $SYM_ARGS
77
-
78
- Utility:
79
- -B, --bash-support [file] append bash completion & utils to a file
80
- such as ~/.bash_profile or ~/.bashrc
81
-
82
- Help & Examples:
83
- -E, --examples show several examples
84
- -h, --help show help
85
- ```
11
+ ![examples](design/sym-examples.png)
86
12
 
87
- ## Examples
13
+ ### Symit BASH Wrapper
88
14
 
89
- ```bash
90
- # generate a new private key into an environment variable:
91
- export mykey=$(sym -g)
92
- echo $mykey
93
- 75ngenJpB6zL47/8Wo7Ne6JN1pnOsqNEcIqblItpfg4=
94
- ————————————————————————————————————————————————————————————————————————————————
95
- # generate a new key with a cached password & save to the default key file
96
- sym -gcpqo /Users/kig/.sym.key
97
- New Password : ••••••••••
98
- Confirm Password : ••••••••••
99
- ————————————————————————————————————————————————————————————————————————————————
100
- # encrypt a plain text string with default key file, and immediately decrypt it
101
- sym -es "secret string" | sym -d
102
- secret string
103
- ————————————————————————————————————————————————————————————————————————————————
104
- # encrypt secrets file using key in the environment, and --negate option:
105
- export PRIVATE_KEY="75ngenJpB6zL47/8Wo7Ne6JN1pnOsqNEcIqblItpfg4="
106
- sym -ck PRIVATE_KEY -n secrets.yml
15
+ Sym comes with the bash wrapper `symit` which is installed whenever you run `sym -B ~/.bash_profile`.
16
+ Below is the help screen with some of the examples:
107
17
 
108
- ————————————————————————————————————————————————————————————————————————————————
109
- # encrypt a secrets file using the key in the keychain:
110
- sym -gqx keychain.key
111
- sym -ck keychain.key -n secrets.yml
112
- secret string
113
- ————————————————————————————————————————————————————————————————————————————————
114
- # encrypt/decrypt sym.yml using the default key file
115
- sym -gcq > /Users/kig/.sym.key
116
- sym -n secrets.yml
117
- sym -df secrets.yml.enc
118
- ————————————————————————————————————————————————————————————————————————————————
119
- # decrypt an encrypted file and print it to STDOUT:
120
- sym -ck production.key -df secrets.yml.enc
121
- ————————————————————————————————————————————————————————————————————————————————
122
- # edit an encrypted file in $EDITOR, use default key file, create file backup
123
- sym -tbf secrets.enc
18
+ ![symit](design/sym-symit-help.png)
124
19
 
125
- Private Key: ••••••••••••••••••••••••••••••••••••••••••••
126
- Saved encrypted content to sym.enc.
127
20
 
128
- Diff:
129
- 3c3
130
- # (c) 2015 Konstantin Gredeskoul. All rights reserved.
131
- ---
132
- # (c) 2016 Konstantin Gredeskoul. All rights reserved.
133
- ————————————————————————————————————————————————————————————————————————————————
134
- # generate a new password-encrypted key, save it to your Keychain:
135
- sym -gpcx staging.key
136
- ————————————————————————————————————————————————————————————————————————————————
137
- # use the new key to encrypt a file:
138
- sym -e -c -k staging.key -n etc/passwords.enc
139
- ————————————————————————————————————————————————————————————————————————————————
140
- # use the new key to inline-edit the encrypted file:
141
- sym -k mykey -t sym.yml.enc
142
- ————————————————————————————————————————————————————————————————————————————————
143
- ```
@@ -1,10 +1,25 @@
1
1
  #!/usr/bin/env bash
2
2
  #
3
- # Sym command line completion
3
+ # Sym Command Line completion and other utilities
4
+ #
5
+ # © 2015-2018, Konstantin Gredeskoul, https://github.com/kigster/sym
4
6
  #
5
- # © 2015-2016, Konstantin Gredeskoul, https://github.com/kigster/sym
6
7
  # MIT LICENSE
7
8
  #
9
+ ###########################################################################
10
+
11
+ ( [[ -n $ZSH_EVAL_CONTEXT && $ZSH_EVAL_CONTEXT =~ :file$ ]] || \
12
+ [[ -n $BASH_VERSION && $0 != "$BASH_SOURCE" ]]) && _s_=1 || _s_=0
13
+
14
+ bash_version=$(/usr/bin/env bash --version | awk '{FS="version"}{print $4}')
15
+ bash_version=${bash_version:0:1}
16
+
17
+ if [[ "${bash_version}" -lt 4 ]]; then
18
+ echo "Sym BASH helpers are incompatible with BASH version 3 or older."
19
+ echo "Please upgrade your BASH to version 4+ released in 2009. Srsly."
20
+ (( $_s_ )) && return 1
21
+ (( $_s_ )) || exit 1
22
+ fi
8
23
 
9
24
  declare -a bash_completion_locations=(/usr/local/etc/bash_completion /usr/etc/bash_completion /etc/bash_completion)
10
25
  loaded=false
@@ -64,6 +79,53 @@ _sym()
64
79
  return 0
65
80
  } && complete -F _sym $nospace $filenames sym
66
81
 
82
+ sym-encrypt() {
83
+ local key=$1
84
+ local from=$2
85
+ local to=$3
86
+ local args=
87
+
88
+ [[ -n $key ]] && args="${args} -ck ${key}"
89
+
90
+ if [[ -n $to ]]; then
91
+ args="${args} -o ${to}"
92
+ [[ -n $from ]] && args="${args} -f ${from}"
93
+ else
94
+ [[ -n $from ]] && args="${args} -n ${from}"
95
+ fi
96
+
97
+ if [[ -z $args ]]; then
98
+ echo "usage: sym-encrypt key file [ outfile ]"
99
+ else
100
+ sym -e ${args}
101
+ fi
102
+ }
103
+
104
+ sym-decrypt() {
105
+ local key=$1
106
+ local from=$2
107
+ local to=$3
108
+ local args=
109
+
110
+ [[ -n $key ]] && args="${args} -ck ${key}"
111
+
112
+ if [[ -n $to ]]; then
113
+ args="${args} -o ${to}"
114
+ [[ -n $from ]] && args="${args} -f ${from}"
115
+ else
116
+ [[ -n $from ]] && args="${args} -n ${from}"
117
+ fi
118
+
119
+ if [[ -z $args ]]; then
120
+ echo "usage: sym-decrypt key file [ outfile ]"
121
+ else
122
+ sym -d ${args}
123
+ fi
124
+ }
125
+
126
+ alias syme="sym-encrypt"
127
+ alias symd="sym-decrypt"
128
+
67
129
  # Local variables:
68
130
  # mode: shell-script
69
131
  # sh-basic-offset: 4