safedb 0.7.1001 → 0.10.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +50 -3
  3. data/Dockerfile +46 -0
  4. data/Jenkinsfile +45 -0
  5. data/README.md +16 -0
  6. data/Rakefile +2 -2
  7. data/cucumber-test.sh +55 -0
  8. data/lib/cli.rb +20 -7
  9. data/lib/controller/abstract/controller.rb +2 -3
  10. data/lib/controller/access/init.rb +11 -7
  11. data/lib/controller/access/login.rb +0 -2
  12. data/lib/controller/book/commit.rb +1 -0
  13. data/lib/controller/db/obliterate.feature +45 -0
  14. data/lib/controller/db/obliterate.rb +58 -0
  15. data/lib/controller/db/pull.rb +10 -26
  16. data/lib/controller/db/push.rb +29 -321
  17. data/lib/controller/db/{remote.rb → remote-github-keypair.rb} +11 -6
  18. data/lib/controller/db/remote-github-token.rb +69 -0
  19. data/lib/controller/db/state.rb +63 -0
  20. data/lib/controller/query/publish.rb +27 -0
  21. data/lib/controller/requirer.rb +0 -1
  22. data/lib/manual/git-interaction.md +176 -0
  23. data/lib/manual/remote.md +0 -1
  24. data/lib/model/book.rb +13 -1
  25. data/lib/model/checkin.feature +15 -27
  26. data/lib/model/content.rb +25 -27
  27. data/lib/model/indices.rb +35 -8
  28. data/lib/model/state_evolve.rb +21 -0
  29. data/lib/model/text_chunk.rb +1 -1
  30. data/lib/utils/extend/string.rb +28 -0
  31. data/lib/utils/git/gitflow.rb +565 -0
  32. data/lib/utils/git/github.rb +69 -0
  33. data/lib/utils/identity/machine.id.rb +2 -2
  34. data/lib/utils/keys/keypair.rb +93 -0
  35. data/lib/utils/logs/logger.rb +3 -4
  36. data/lib/utils/time/timestamp.rb +2 -0
  37. data/lib/version.rb +1 -1
  38. data/pod-image-builder.yaml +27 -0
  39. data/pod-image-safetty.yaml +18 -0
  40. data/safedb.gemspec +1 -6
  41. metadata +17 -64
  42. data/genius-decision.txt +0 -25
  43. data/lib/controller/db/model_git_service.rb +0 -399
  44. data/lib/plugin/github.rb +0 -53
  45. data/lib/utils/store/github.rb +0 -27
@@ -8,6 +8,99 @@ module SafeDb
8
8
  # ssh formatted public key and/or the pem formatted private key.
9
9
  class Keypair
10
10
 
11
+ ######## ################################################################## #####################
12
+ ######## ################################################################## #####################
13
+ ######## KeyPair Creation with ssh_config SSH config file in .ssh Directory #####################
14
+ ######## ################################################################## #####################
15
+ ######## ################################################################## #####################
16
+
17
+ =begin
18
+
19
+
20
+ private_key_path = File.join( Indices::SSH_DIRECTORY_PATH, @verse[ Indices::REMOTE_PRIVATE_KEY_KEYNAME ] )
21
+ private_key_exists = File.file?( private_key_path )
22
+ puts "private key found at #{private_key_path}" if private_key_exists
23
+
24
+ unless private_key_exists
25
+
26
+ puts "private key will be created at #{private_key_path}"
27
+ file_writer = Write.new()
28
+ file_writer.file_key = Indices::PRIVATE_KEY_DEFAULT_KEY_NAME
29
+ file_writer.to_dir = Indices::SSH_DIRECTORY_PATH
30
+ file_writer.flow()
31
+
32
+ FileUtils.chmod( 0600, private_key_path, :verbose => true )
33
+
34
+ end
35
+
36
+ git_username = @verse[ Indices::GIT_REPOSITORY_USER_KEYNAME ]
37
+ git_reponame = @verse[ Indices::GIT_REPOSITORY_NAME_KEYNAME ]
38
+
39
+ ssh_host_name = @verse[ Indices::REMOTE_MIRROR_SSH_HOST_KEYNAME ]
40
+ ssh_config_exists = File.file?( Indices::SSH_CONFIG_FILE_PATH )
41
+ config_file_contents = File.read( Indices::SSH_CONFIG_FILE_PATH ) if ssh_config_exists
42
+ ssh_config_written = ssh_config_exists && config_file_contents.include?( ssh_host_name )
43
+ puts "ssh config for host #{ssh_host_name} has already been written" if ssh_config_written
44
+
45
+ unless ssh_config_written
46
+
47
+ puts "ssh config for host #{ssh_host_name} will be written"
48
+ config_backup_path = File.join( Indices::SSH_DIRECTORY_PATH, "safe.clobbered.ssh.config-#{TimeStamp.yyjjj_hhmm_sst()}" )
49
+ File.write( config_backup_path, config_file_contents ) if ssh_config_exists
50
+ puts "original ssh config at #{config_backup_path}" if ssh_config_exists
51
+
52
+ File.open( Indices::SSH_CONFIG_FILE_PATH, "a" ) do |line|
53
+ line.puts( "\n" )
54
+ line.puts( "Host #{ ssh_host_name }" )
55
+ line.puts( "HostName github.com" )
56
+ line.puts( "User #{ git_username }" )
57
+ line.puts( "IdentityFile #{ private_key_path }" )
58
+ line.puts( "StrictHostKeyChecking no" )
59
+ end
60
+
61
+ puts "ssh config has been successfully written"
62
+
63
+ end
64
+
65
+ puts ""
66
+
67
+ ssh_test_cmd_string = "ssh -i #{private_key_path} -vT git@github.com"
68
+ system( ssh_test_cmd_string )
69
+ ssh_cmd_exit_status = $?.exitstatus
70
+
71
+ unless ssh_cmd_exit_status == 1
72
+
73
+ puts ""
74
+ puts "The command exit status is #{ssh_test_exitstatus}"
75
+ puts ""
76
+ puts "### ##### : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
77
+ puts "### Error : SSH test result did not contain expected string."
78
+ puts "### Query : #{ ssh_test_cmd_string }"
79
+ puts "### ##### : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
80
+ puts ""
81
+
82
+ return
83
+
84
+ end
85
+
86
+ puts ""
87
+ puts "### ####### : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
88
+ puts "### Success : The SSH connection test was a roaring success."
89
+ puts "### Command : #{ ssh_test_cmd_string }"
90
+ puts "### ####### : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
91
+ puts ""
92
+
93
+ =end
94
+
95
+
96
+
97
+
98
+ ######## ################################################################## #####################
99
+ ######## ################################################################## #####################
100
+
101
+
102
+
103
+
11
104
  # Generate an elliptic curve cryptographic keypair. After the key is
12
105
  # generated, both the public and private keys can be retrieved through
13
106
  # the accessors.
@@ -24,10 +24,9 @@ require "logger"
24
24
  #
25
25
  module LogImpl
26
26
 
27
- @@gem_name = "safedb.net"
28
- @@gem_base = File.join( Dir.home(), ".#{@@gem_name}" )
27
+ @@gem_base = File.join( File.join( Dir.home, ".config" ), "safedb" )
29
28
  FileUtils.mkdir_p( @@gem_base ) unless File.exists?( @@gem_base )
30
- @@log_path = File.join( @@gem_base, "safedb-summary.log" )
29
+ @@log_path = File.join( @@gem_base, "safedb-cli-usage.log" )
31
30
 
32
31
 
33
32
  # Classes that include (MIXIN) this logging module will
@@ -88,7 +87,7 @@ module LogImpl
88
87
  def get_logger
89
88
 
90
89
  file_logger = Logger.new @@log_path
91
- file_logger.level = Logger::DEBUG
90
+ file_logger.level = Logger::INFO
92
91
  original_formatter = Logger::Formatter.new
93
92
 
94
93
  file_logger.formatter = proc { |severity, datetime, progname, msg|
@@ -470,6 +470,8 @@ module SafeDb
470
470
  # move method contents into test class
471
471
  def self.log_instance_time
472
472
 
473
+ log.info(x) { "activity timestamp is #{yyjjj_hhmm_sst} representing #{TimeStamp.instance.time_now.ctime}" }
474
+
473
475
  log.debug(x) { "[stamp] -------------- => -------------------------------- #" }
474
476
  log.debug(x) { "[stamp] eco time stamp => [#{TimeStamp.instance.time_now.ctime}]" }
475
477
  log.debug(x) { "[stamp] -------------- => -------------------------------- #" }
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module SafeDb
2
- VERSION = "0.7.1001"
2
+ VERSION = "0.10.5"
3
3
  end
@@ -0,0 +1,27 @@
1
+ # This kubernetes pod template instantiates a slave (JNLP) sidecar container
2
+ # for Jenkins master slave communications and the Google Kaniko container for
3
+ # building docker images without demanding privileged docker in/out access.
4
+ ---
5
+ kind: Pod
6
+ metadata:
7
+ name: kaniko
8
+ spec:
9
+ containers:
10
+ - name: jnlp
11
+ image: jenkins/jnlp-slave:latest
12
+ - name: kaniko
13
+ image: gcr.io/kaniko-project/executor:debug
14
+ imagePullPolicy: Always
15
+ volumeMounts:
16
+ - name: regcredsvolume
17
+ mountPath: /kaniko/.docker
18
+ command:
19
+ - /busybox/sh
20
+ - "-c"
21
+ args:
22
+ - /busybox/cat
23
+ tty: true
24
+ volumes:
25
+ - name: regcredsvolume
26
+ secret:
27
+ secretName: registrycreds
@@ -0,0 +1,18 @@
1
+ metadata:
2
+ labels:
3
+ pod-type: jenkins-worker
4
+ spec:
5
+ containers:
6
+ - name: jnlp
7
+ env:
8
+ - name: CONTAINER_ENV_VAR
9
+ value: jnlp
10
+ - name: safettytests
11
+ image: devops4me/safetty:latest
12
+ imagePullPolicy: Always
13
+ command:
14
+ - cat
15
+ tty: true
16
+ env:
17
+ - name: CONTAINER_ENV_VAR
18
+ value: safettytests
data/safedb.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.bindir = "bin"
24
24
  spec.executables = [ 'safe' ]
25
25
  spec.require_paths = ["lib"]
26
- spec.required_ruby_version = '>= 2.3.0'
26
+ spec.required_ruby_version = '>= 2.5.1'
27
27
 
28
28
  spec.add_dependency 'bcrypt', '~> 3.1'
29
29
  spec.add_dependency 'thor', '~> 0.20'
@@ -31,9 +31,4 @@ Gem::Specification.new do |spec|
31
31
  spec.add_dependency 'octokit', '~> 4.14'
32
32
  spec.add_dependency 'net-ssh', '~> 5.2'
33
33
 
34
- spec.add_development_dependency "bundler", "~> 0"
35
- spec.add_development_dependency "cucumber", "~> 2.0"
36
- spec.add_development_dependency "aruba", "~> 1.0.0-alpha.1"
37
- spec.add_development_dependency "gem-release", "~> 0"
38
-
39
34
  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.7.1001
4
+ version: 0.10.5
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-09-19 00:00:00.000000000 Z
11
+ date: 2020-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bcrypt
@@ -80,62 +80,6 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '5.2'
83
- - !ruby/object:Gem::Dependency
84
- name: bundler
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: cucumber
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '2.0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '2.0'
111
- - !ruby/object:Gem::Dependency
112
- name: aruba
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: 1.0.0.pre.alpha.1
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: 1.0.0.pre.alpha.1
125
- - !ruby/object:Gem::Dependency
126
- name: gem-release
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
83
  description: safe is a credentials manager for the linux command line written in Ruby.
140
84
  It locks and unlocks secrets in a safe simple and intuitive manner. You can then
141
85
  visit websites, manufacture keys and passwords, inject credentials into Jenkins,
@@ -150,12 +94,14 @@ files:
150
94
  - ".gitignore"
151
95
  - ".yardopts"
152
96
  - CONTRIBUTING.md
97
+ - Dockerfile
153
98
  - Gemfile
99
+ - Jenkinsfile
154
100
  - LICENSE
155
101
  - README.md
156
102
  - Rakefile
157
103
  - bin/safe
158
- - genius-decision.txt
104
+ - cucumber-test.sh
159
105
  - lib/cli.rb
160
106
  - lib/controller/abstract/authenticate.rb
161
107
  - lib/controller/abstract/controller.rb
@@ -185,10 +131,13 @@ files:
185
131
  - lib/controller/book/refresh.rb
186
132
  - lib/controller/book/view.rb
187
133
  - lib/controller/config/README.md
188
- - lib/controller/db/model_git_service.rb
134
+ - lib/controller/db/obliterate.feature
135
+ - lib/controller/db/obliterate.rb
189
136
  - lib/controller/db/pull.rb
190
137
  - lib/controller/db/push.rb
191
- - lib/controller/db/remote.rb
138
+ - lib/controller/db/remote-github-keypair.rb
139
+ - lib/controller/db/remote-github-token.rb
140
+ - lib/controller/db/state.rb
192
141
  - lib/controller/edit/README.md
193
142
  - lib/controller/edit/generate.rb
194
143
  - lib/controller/edit/keys.rb
@@ -207,6 +156,7 @@ files:
207
156
  - lib/controller/navigate/open.rb
208
157
  - lib/controller/query/copy.rb
209
158
  - lib/controller/query/print.rb
159
+ - lib/controller/query/publish.rb
210
160
  - lib/controller/query/show.rb
211
161
  - lib/controller/query/tell.rb
212
162
  - lib/controller/requirer.rb
@@ -218,6 +168,7 @@ files:
218
168
  - lib/manual/crypto-math.md
219
169
  - lib/manual/dir-structure.md
220
170
  - lib/manual/drag-drop.md
171
+ - lib/manual/git-interaction.md
221
172
  - lib/manual/login-logout.md
222
173
  - lib/manual/push-pull.md
223
174
  - lib/manual/remote.md
@@ -234,7 +185,6 @@ files:
234
185
  - lib/model/state_evolve.rb
235
186
  - lib/model/state_query.rb
236
187
  - lib/model/text_chunk.rb
237
- - lib/plugin/github.rb
238
188
  - lib/utils/ciphers/aes-256.rb
239
189
  - lib/utils/ciphers/blowfish.rb
240
190
  - lib/utils/ciphers/cipher.rb
@@ -246,6 +196,8 @@ files:
246
196
  - lib/utils/extend/hash.rb
247
197
  - lib/utils/extend/string.rb
248
198
  - lib/utils/facts/fact.rb
199
+ - lib/utils/git/gitflow.rb
200
+ - lib/utils/git/github.rb
249
201
  - lib/utils/identity/identifier.rb
250
202
  - lib/utils/identity/machine.id.rb
251
203
  - lib/utils/inspect/inspector.rb
@@ -263,13 +215,14 @@ files:
263
215
  - lib/utils/logs/logger.rb
264
216
  - lib/utils/store/datamap.rb
265
217
  - lib/utils/store/datastore.rb
266
- - lib/utils/store/github.rb
267
218
  - lib/utils/store/merge-boys-school.json
268
219
  - lib/utils/store/merge-girls-school.json
269
220
  - lib/utils/store/merge-merged-data.json
270
221
  - lib/utils/store/struct.rb
271
222
  - lib/utils/time/timestamp.rb
272
223
  - lib/version.rb
224
+ - pod-image-builder.yaml
225
+ - pod-image-safetty.yaml
273
226
  - safedb.gemspec
274
227
  homepage: https://www.safedb.net
275
228
  licenses:
@@ -284,7 +237,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
284
237
  requirements:
285
238
  - - ">="
286
239
  - !ruby/object:Gem::Version
287
- version: 2.3.0
240
+ version: 2.5.1
288
241
  required_rubygems_version: !ruby/object:Gem::Requirement
289
242
  requirements:
290
243
  - - ">="
data/genius-decision.txt DELETED
@@ -1,25 +0,0 @@
1
-
2
- ###########################################################################
3
- Put the JSOn files together with the crypts in the same git repository
4
- ###########################################################################
5
-
6
-
7
- The bottom line to simplify is that everything goes up - the file
8
-
9
- safe pull does not need any authentication
10
- safe push requires you to be authenticated
11
-
12
-
13
- Maybe safe pull will create a subdirectory in .safedb.net and then writes into a config (say json) file in ~/.safedb.net the directory name.
14
- Maybe safe switch changes the safe database folder by writing that config file
15
-
16
-
17
-
18
-
19
- Simplify the Safe
20
-
21
- - safe pull https://github.com..../repo-name?branch-or-commit-name
22
- - pull backs up the current directory into ~/.safe-backups
23
-
24
- - safe push (will send wherever the pull came from)
25
- - or safe push (from a verse uses the config in the verse to do the push