safedb 0.2.7 → 0.3.1005

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: 30a324556ac98545ab07f345b1bf502deb262ab05fd1ba6768f0be22f383fbcb
4
- data.tar.gz: abb20f9e15dc091b8ce3a498942dddd77567fec704eec586bf2755a393e5644f
3
+ metadata.gz: 718df8b99a21bac018c59c65972a82fbb2b117a8aeab58b7e1836dc65c4c759e
4
+ data.tar.gz: b0eab23a4e4216f70badb1f454b621081fee24d3b88fce7c11cf43674d2bd018
5
5
  SHA512:
6
- metadata.gz: a342cc015febbadb9b5e3155c4117547738bf8033e151b44f6655ed33f3faa3eda928fc78219b00a2bab6fd6b6e74a90b613725a4dd1922713e73cd715d20ab5
7
- data.tar.gz: 639c206abbf990497b24e383621a61fc181b3b28a4ef6ff8049a0684a986ef2bc6b46aa0e99a49a7a56b327711536b5d67ca54cb6144d40e2c639d19c4f8d47d
6
+ metadata.gz: be459393d8ea7bfd99e1a9613e3d1b0229ab01487ec5ba7c533264e0deccd5ea6154d1eb80bd050826704f973e86eb1163c79d908bb775617abd562f17ffc120
7
+ data.tar.gz: 921bbb4522ac6edc6a3f85d1acb9b019321fb6cb4dc7ad205ab44bc0a0f06089ea575605d2b0fe84f4a3747d4c58f3a50e942120f32148e6924c6f2c3cd88c43
data/CONTRIBUTING.md CHANGED
@@ -9,18 +9,39 @@ You can contriubute software, documentation, issues and even good ideas. Most co
9
9
  To contribute software you'll need to setup a development environment.
10
10
 
11
11
  ```
12
- sudo apt-get install --assume-yes ruby-full, libicu-dev, git
12
+ sudo apt-get install --assume-yes ruby-full libicu-dev git
13
13
  sudo chown -R $USER:$USER /var/lib/gems
14
14
  sudo chown -R $USER:$USER /usr/local/bin
15
- gem install safedb bundler gem-release
15
+ sudo chown -R $USER:$USER /usr/local/lib
16
+ gem install safedb bundler gem-release cucumber aruba
16
17
  git clone https://github.com/devops4me/safedb.net.git mirror.safedb.ro
17
18
  cd mirror.safedb
18
19
  rake install
20
+ bundle install
21
+ cucumber
19
22
  ```
20
23
 
21
24
  You change the software as you see fit and **send a pull request** when you are ready.
22
25
 
23
26
 
27
+ ## Running Cucumber/Aruba Tests
28
+
29
+ Use the simple **`cucumber`** command in the project directory to run the tests.
30
+
31
+ ## Reek | Ruby Code Quality
32
+
33
+ software quality must improve with every check-in and conversely we should never holistically degrade quality. Every change must be small and incremental so keeping the quality metrics ticking in the right direction is not too much to ask.
34
+
35
+ **[reek code quality documentation](https://github.com/troessner/reek/tree/v5.3.1/docs)**
36
+
37
+ We must **install and run reek** within development and continuous integration pipelines, so as to derive a listing of software quality issues.
38
+
39
+ ```
40
+ gem install reek
41
+ reek lib
42
+ ```
43
+
44
+
24
45
  ## Releasing Software
25
46
 
26
47
  Those with priveleges to release to safedb.net will have a private key to push (or pull) in git repository changes.
data/Gemfile CHANGED
@@ -1,10 +1,7 @@
1
- ## ============================================
2
- ## Try removing this file
3
- ## See what happens
4
- ## ============================================
5
1
  source "https://rubygems.org"
6
2
 
7
3
  git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
8
4
 
9
5
  # Specify your gem's dependencies in safedb.gemspec
10
6
  gemspec
7
+ gem 'aruba', '~> 1.0.0-alpha.2'
data/README.md CHANGED
@@ -114,18 +114,19 @@ You only need to run init once on a computer for each domain - after that you si
114
114
 
115
115
  More information will be provided on installing and using safe via a gem install, Ubuntu's apt-get, yum, a docker container, a development install, a unit test install and a software development kit (SDK) install.
116
116
 
117
- ## Create Alias for Export Safe Terminal Token
117
+ ## Automatically Create Safe Token
118
118
 
119
- It is tiresome To type <tt>export SAFE_TTY_TOKEN=`safe token`</tt> every time you use the safe. A solution is to create a smaller alias command like <tt>safetty</tt> which will run when we open up a shell.
119
+ Always typing <tt>export SAFE_TTY_TOKEN=`safe token`</tt> before using safe is tiresome. Ubuntu provides **`.bash_aliases`** for creating tokens like these at the genesis of each shell.
120
120
 
121
121
  ```bash
122
- echo "alias safetty='export SAFE_TTY_TOKEN=\`safe token\`'" >> ~/.bash_aliases
122
+ echo "export SAFE_TTY_TOKEN=\`safe token\`" >> ~/.bash_aliases
123
+ source ~/.bash_aliases # no need to create a new shell
124
+ cat ~/.bash_aliases # we expect the export command
125
+ printenv | grep SAFE_TTY_TOKEN # we expect the environment var
123
126
  ```
124
127
 
125
- Note the **escaped back-ticks** surrounding <tt>safe token</tt>. It is easy to mistake them for apostrophes.
128
+ Note the **escaped back-ticks** around <tt>safe token</tt>.
126
129
 
127
- $ cat ~/.bash_aliases # Check the alias has been added to ~/.bash_aliases
128
- $ source ~/.bash_aliases # Use source to avoid grabbing a new shell this time
129
130
 
130
131
  ## safe book login command
131
132
 
@@ -729,19 +729,10 @@ module SafeDb
729
729
  # - reading the encrypted and encoded content, decoding and decrypting it
730
730
  # - employing index key, ciphertext and random iv to reveal the content
731
731
  #
732
- # @param use_grandparent_pid [Boolean]
733
- #
734
- # Optional boolean parameter. If set to true the PID (process ID) used
735
- # as part of an obfuscator key and normally acquired from the parent
736
- # process should now be acquired from the grandparent's process.
737
- #
738
- # Set to true when accessing the safe's credentials from a sub process
739
- # rather than directly through the logged in shell.
740
- #
741
732
  # @return [String]
742
733
  # decode, decrypt and hen return the plain text content that was written
743
734
  # to a file by the {write_content} method.
744
- def self.read_master_db( use_grandparent_pid = false )
735
+ def self.read_master_db()
745
736
 
746
737
  # --
747
738
  # -- Get the filepath to the breadcrumbs file using the trail in
@@ -758,7 +749,7 @@ module SafeDb
758
749
  # --
759
750
  # -- Regenerate intra-session key from the session token.
760
751
  # --
761
- intra_key = KeyLocal.regenerate_shell_key( to_token(), use_grandparent_pid )
752
+ intra_key = KeyLocal.regenerate_shell_key( to_token() )
762
753
 
763
754
  # --
764
755
  # -- Decrypt and acquire the content enryption key that was created
@@ -110,7 +110,58 @@ module SafeDb
110
110
  # It will also be different on this workstation if the application
111
111
  # instance identifier provided is different.
112
112
  def self.derive_app_instance_machine_id( app_ref )
113
- return derive_identifier( app_ref + KeyIdent.derive_machine_identifier() )
113
+ return derive_identifier( app_ref + derive_machine_identifier() )
114
+ end
115
+
116
+
117
+ # This method uses a one-way function to return a combinatorial digested
118
+ # machine identification string using a number of distinct input parameters
119
+ # to deliver the characteristic of producing the same identifier for the
120
+ # same machine, virtual machine, workstation and/or compute element, and
121
+ # reciprocally, a different one on a different machine.
122
+ #
123
+ # The userspace is also a key machine identifier so a different machine user
124
+ # generates a different identifier when all other things remain equal.
125
+ #
126
+ # @return [String]
127
+ # a one line textual machine workstation or compute element identifier
128
+ # that is (surprisingly) different when the machine user changes.
129
+ def self.derive_machine_identifier
130
+
131
+ require 'socket'
132
+
133
+ identity_text = [
134
+ Etc.getlogin,
135
+ get_machine_id(),
136
+ Socket.gethostname()
137
+ ].join.reverse
138
+
139
+ return identity_text
140
+
141
+ end
142
+
143
+
144
+ # The machine identifier is a UUID based hash value that is tied to the
145
+ # CPU and motherboard of the machine. This read-only identifier can be
146
+ # accessed without sudoer permissions so is perfect for license generators
147
+ # and environment sensitive software.
148
+ #
149
+ # In the modern era of virtualization you should always check the behaviour
150
+ # of the above identifiers when used inside
151
+ #
152
+ # - docker containers
153
+ # - Amazon EC2 servers (or Azure or GCE)
154
+ # - vagrant (VirtualBox/VMWare)
155
+ # - Windows MSGYWIN (Ubuntu) environments
156
+ # - Kubernetes pods
157
+ #
158
+ # @return [String] the machine ID hash value
159
+ def self.get_machine_id
160
+
161
+ machine_id_cmd = "cat /etc/machine-id"
162
+ machine_id_str = %x[ #{machine_id_cmd} ]
163
+ return machine_id_str.chomp
164
+
114
165
  end
115
166
 
116
167
 
@@ -52,22 +52,13 @@ module SafeDb
52
52
  # - the user comes back to their <b>workstation</b>
53
53
  # - the clock ticks into another day, month, year ...
54
54
  #
55
- # @param use_grandparent_pid [Boolean]
56
- #
57
- # Optional boolean parameter. If set to true the PID (process ID) used
58
- # as part of an obfuscator key and normally acquired from the parent
59
- # process should now be acquired from the grandparent's process.
60
- #
61
- # Set to true when accessing the safe's credentials from a sub process
62
- # rather than directly through the logged in shell.
63
- #
64
55
  # @return [String]
65
56
  # Return a one line textual shell identity string.
66
57
  #
67
58
  # As key derivation algorithms enforcing a maximum length may be length may
68
59
  # be applied, each character must add value so non-alphanumerics (mostly hyphens)
69
60
  # are cleansed out before returning.
70
- def self.derive_shell_identifier( use_grandparent_pid = false )
61
+ def self.derive_shell_identifier
71
62
 
72
63
  require 'socket'
73
64
 
@@ -76,7 +67,6 @@ module SafeDb
76
67
 
77
68
  identity_text =
78
69
  [
79
- get_ancestor_pid( use_grandparent_pid ),
80
70
  get_bootup_id(),
81
71
  Etc.getlogin(),
82
72
  Socket.gethostname()
@@ -87,6 +77,29 @@ module SafeDb
87
77
  end
88
78
 
89
79
 
80
+ # If you need to know whether a Linux computer has been rebooted or
81
+ # you need an identifier that stays the same until the computer reboots,
82
+ # look no further than the read only (non sudoer accessible) **boot id**.
83
+ #
84
+ # In the modern era of virtualization you should always check the behaviour
85
+ # of the above identifiers when used inside
86
+ #
87
+ # - docker containers
88
+ # - Amazon EC2 servers (or Azure or GCE)
89
+ # - vagrant (VirtualBox/VMWare)
90
+ # - Windows MSGYWIN (Ubuntu) environments
91
+ # - Kubernetes pods
92
+ #
93
+ # @return [String] the bootup ID hash value
94
+ def self.get_bootup_id
95
+
96
+ bootup_id_cmd = "cat /proc/sys/kernel/random/boot_id"
97
+ bootup_id_str = %x[ #{bootup_id_cmd} ]
98
+ return bootup_id_str.chomp
99
+
100
+ end
101
+
102
+
90
103
  # Return an ancestor process ID meaning return either the parent process
91
104
  # ID or the grandparent process ID. The one returned depends on the paremeter
92
105
  # boolean value.
@@ -140,80 +153,6 @@ module SafeDb
140
153
  end
141
154
 
142
155
 
143
- # This method uses a one-way function to return a combinatorial digested
144
- # machine identification string using a number of distinct input parameters
145
- # to deliver the characteristic of producing the same identifier for the
146
- # same machine, virtual machine, workstation and/or compute element, and
147
- # reciprocally, a different one on a different machine.
148
- #
149
- # The userspace is also a key machine identifier so a different machine user
150
- # generates a different identifier when all other things remain equal.
151
- #
152
- # @return [String]
153
- # a one line textual machine workstation or compute element identifier
154
- # that is (surprisingly) different when the machine user changes.
155
- def self.derive_machine_identifier
156
-
157
- require 'socket'
158
-
159
- identity_text = [
160
- Etc.getlogin,
161
- get_machine_id(),
162
- Socket.gethostname()
163
- ].join.reverse
164
-
165
- return identity_text
166
-
167
- end
168
-
169
-
170
- # If you need to know whether a Linux computer has been rebooted or
171
- # you need an identifier that stays the same until the computer reboots,
172
- # look no further than the read only (non sudoer accessible) **boot id**.
173
- #
174
- # In the modern era of virtualization you should always check the behaviour
175
- # of the above identifiers when used inside
176
- #
177
- # - docker containers
178
- # - Amazon EC2 servers (or Azure or GCE)
179
- # - vagrant (VirtualBox/VMWare)
180
- # - Windows MSGYWIN (Ubuntu) environments
181
- # - Kubernetes pods
182
- #
183
- # @return [String] the bootup ID hash value
184
- def self.get_bootup_id
185
-
186
- bootup_id_cmd = "cat /proc/sys/kernel/random/boot_id"
187
- bootup_id_str = %x[ #{bootup_id_cmd} ]
188
- return bootup_id_str.chomp
189
-
190
- end
191
-
192
-
193
- # The machine identifier is a UUID based hash value that is tied to the
194
- # CPU and motherboard of the machine. This read-only identifier can be
195
- # accessed without sudoer permissions so is perfect for license generators
196
- # and environment sensitive software.
197
- #
198
- # In the modern era of virtualization you should always check the behaviour
199
- # of the above identifiers when used inside
200
- #
201
- # - docker containers
202
- # - Amazon EC2 servers (or Azure or GCE)
203
- # - vagrant (VirtualBox/VMWare)
204
- # - Windows MSGYWIN (Ubuntu) environments
205
- # - Kubernetes pods
206
- #
207
- # @return [String] the machine ID hash value
208
- def self.get_machine_id
209
-
210
- machine_id_cmd = "cat /etc/machine-id"
211
- machine_id_str = %x[ #{machine_id_cmd} ]
212
- return machine_id_str.chomp
213
-
214
- end
215
-
216
-
217
156
  end
218
157
 
219
158
 
@@ -128,26 +128,17 @@ module SafeDb
128
128
  # {self.instantiate_shell_key_and_generate_token} and provided
129
129
  # here ad verbatim.
130
130
  #
131
- # @param use_grandparent_pid [Boolean]
132
- #
133
- # Optional boolean parameter. If set to true the PID (process ID) used
134
- # as part of an obfuscator key and normally acquired from the parent
135
- # process should now be acquired from the grandparent's process.
136
- #
137
- # Set to true when accessing the safe's credentials from a sub process
138
- # rather than directly through the logged in shell.
139
- #
140
131
  # @return [SafeDb::Key]
141
132
  # an extremely high entropy 256 bit key derived (digested) from 48
142
133
  # random bytes at the beginning of the shell (cli) session.
143
- def self.regenerate_shell_key( session_token, use_grandparent_pid = false )
134
+ def self.regenerate_shell_key( session_token )
144
135
 
145
136
  assert_session_token_size( session_token )
146
137
  bcrypt_salt = session_token[ BCRYPT_SALT_START_INDEX .. BCRYPT_SALT_END_INDEX ].reverse
147
138
  assert_bcrypt_salt_size( bcrypt_salt )
148
139
 
149
140
  key_ciphertext = session_token[ 0 .. ( BCRYPT_SALT_START_INDEX - 1 ) ]
150
- obfuscator_key = derive_session_crypt_key( bcrypt_salt, use_grandparent_pid )
141
+ obfuscator_key = derive_session_crypt_key( bcrypt_salt )
151
142
  regenerated_key = obfuscator_key.do_decrypt_key( key_ciphertext )
152
143
 
153
144
  return regenerated_key
@@ -199,22 +190,13 @@ module SafeDb
199
190
  # Either use BCrypt to generate the salt or retrieve and post in a
200
191
  # previously generated salt which must hold 22 printable characters.
201
192
  #
202
- # @param use_grandparent_pid [Boolean]
203
- #
204
- # Optional boolean parameter. If set to true the PID (process ID) used
205
- # as part of an obfuscator key and normally acquired from the parent
206
- # process should now be acquired from the grandparent's process.
207
- #
208
- # Set to true when accessing the safe's credentials from a sub process
209
- # rather than directly through the logged in shell.
210
- #
211
193
  # @return [SafeDb::Key]
212
194
  # a digested key suitable for short term (session scoped) use with the
213
195
  # guarantee that the same key will be returned whenever called from within
214
196
  # the same executing shell environment and a different key when not.
215
- def self.derive_session_crypt_key bcrypt_salt_key, use_grandparent_pid = false
197
+ def self.derive_session_crypt_key bcrypt_salt_key
216
198
 
217
- shell_id_text = KeyIdent.derive_shell_identifier( use_grandparent_pid )
199
+ shell_id_text = KeyIdent.derive_shell_identifier()
218
200
  truncate_text = shell_id_text.length > KdfBCrypt::BCRYPT_MAX_IN_TEXT_LENGTH
219
201
  shell_id_trim = shell_id_text unless truncate_text
220
202
  shell_id_trim = shell_id_text[ 0 .. ( KdfBCrypt::BCRYPT_MAX_IN_TEXT_LENGTH - 1 ) ] if truncate_text
@@ -0,0 +1,30 @@
1
+ #### The **safe philosophy** is to minimize human interaction with large random credential strings. Your credential-less interactions with Terraform, AWS and now website logins is not just **simple**, it is also **more secure**.
2
+
3
+ # safe visit | visit (login to) a website
4
+
5
+ **Issue <tt>safe visit</tt> and you will be logged in.**
6
+
7
+ To login to a website your verse needs to contain a <tt>signin.url</tt>, a <tt>username</tt> or <tt>email</tt> and a <tt>password</tt>.
8
+
9
+ ## Technologies Used to Visit Websites
10
+
11
+ **Selinium** and the **Ruby Watir** library are used to interact with web browsers to enable hands free logins.
12
+
13
+ ### How to install Watir
14
+
15
+ Use **`curl`** to pull down and place the following executable into /usr/local/bin
16
+
17
+ https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz
18
+
19
+ Now when you run the **`ruby visit.rb`** the browser should pop up and search for our search term.
20
+
21
+ ### Reading Material
22
+
23
+ https://applitools.com/tutorials/watir.html#run-your-first-test
24
+ http://watir.com/guides/
25
+
26
+ http://watir.com/
27
+ https://www.rubydoc.info/gems/watir/
28
+
29
+
30
+
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/ruby
2
+
3
+ module SafeDb
4
+
5
+ class Visit < UseCase
6
+
7
+ def execute
8
+
9
+ require "watir"
10
+ require "rspec/expectations"
11
+
12
+ ## see README.md for documentation on installing geckodriver
13
+
14
+ @browser ||= Watir::Browser.new :firefox
15
+ @browser.goto "google.com"
16
+ @browser.text_field(:name => "q").set "apollo akora"
17
+ @browser.button.click
18
+
19
+ @browser.div(:id => "resultStats").wait_until(&:present?)
20
+ sleep 20
21
+ @browser.close
22
+
23
+ end
24
+
25
+
26
+ end
27
+
28
+
29
+ end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module SafeDb
2
- VERSION = "0.2.7"
2
+ VERSION = "0.3.1005"
3
3
  end
data/safedb.gemspec CHANGED
@@ -29,6 +29,8 @@ Gem::Specification.new do |spec|
29
29
  spec.add_dependency 'thor', '~> 0.20'
30
30
  spec.add_dependency 'inifile', '~> 3.0'
31
31
 
32
- spec.add_development_dependency "bundler", "~> 1.16"
32
+ spec.add_development_dependency "bundler"
33
+ spec.add_development_dependency "cucumber", "~> 2.0"
34
+ spec.add_development_dependency "aruba", "~> 1.0.0-alpha.1"
33
35
 
34
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safedb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.3.1005
5
5
  platform: ruby
6
6
  authors:
7
7
  - Apollo Akora
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-26 00:00:00.000000000 Z
11
+ date: 2019-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bcrypt
@@ -54,18 +54,46 @@ dependencies:
54
54
  version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: cucumber
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: aruba
57
85
  requirement: !ruby/object:Gem::Requirement
58
86
  requirements:
59
87
  - - "~>"
60
88
  - !ruby/object:Gem::Version
61
- version: '1.16'
89
+ version: 1.0.0.pre.alpha.1
62
90
  type: :development
63
91
  prerelease: false
64
92
  version_requirements: !ruby/object:Gem::Requirement
65
93
  requirements:
66
94
  - - "~>"
67
95
  - !ruby/object:Gem::Version
68
- version: '1.16'
96
+ version: 1.0.0.pre.alpha.1
69
97
  description: safe is a credentials manager for the linux command line written in Ruby.
70
98
  It locks and unlocks secrets in a safe simple and intuitive manner. You can then
71
99
  visit websites, manufacture keys and passwords, inject credentials into Jenkins,
@@ -160,6 +188,8 @@ files:
160
188
  - lib/usecase/use.rb
161
189
  - lib/usecase/verse.rb
162
190
  - lib/usecase/view.rb
191
+ - lib/usecase/visit/README.md
192
+ - lib/usecase/visit/visit.rb
163
193
  - lib/usecase/vpn/README.md
164
194
  - lib/usecase/vpn/vpn.ini
165
195
  - lib/usecase/vpn/vpn.rb
@@ -185,8 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
215
  - !ruby/object:Gem::Version
186
216
  version: '0'
187
217
  requirements: []
188
- rubyforge_project:
189
- rubygems_version: 2.7.6
218
+ rubygems_version: 3.0.2
190
219
  signing_key:
191
220
  specification_version: 4
192
221
  summary: safe locks and unlocks secrets in a simple, secure and intuitive way.