safedb 0.3.1011 → 0.4.1002
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +56 -19
- data/README.md +15 -15
- data/Rakefile +7 -0
- data/bin/safe +2 -2
- data/lib/{interprete.rb → cli.rb} +168 -121
- data/lib/controller/admin/README.md +47 -0
- data/lib/controller/admin/access.rb +47 -0
- data/lib/controller/admin/checkin.rb +83 -0
- data/lib/controller/admin/checkout.rb +57 -0
- data/lib/controller/admin/diff.rb +75 -0
- data/lib/{usecase → controller/admin}/export.rb +15 -14
- data/lib/controller/admin/goto.rb +52 -0
- data/lib/controller/admin/import.rb +54 -0
- data/lib/controller/admin/init.rb +113 -0
- data/lib/controller/admin/login.rb +88 -0
- data/lib/{usecase → controller/admin}/logout.rb +0 -0
- data/lib/controller/admin/open.rb +39 -0
- data/lib/{usecase → controller/admin}/token.rb +2 -2
- data/lib/controller/admin/tree.md +54 -0
- data/lib/{usecase → controller/admin}/use.rb +0 -0
- data/lib/controller/admin/view.rb +61 -0
- data/lib/{usecase → controller/api}/docker/README.md +0 -0
- data/lib/{usecase → controller/api}/docker/docker.rb +1 -1
- data/lib/{usecase → controller/api}/jenkins/README.md +0 -0
- data/lib/{usecase → controller/api}/jenkins/jenkins.rb +1 -1
- data/lib/{usecase → controller/api}/terraform/README.md +1 -1
- data/lib/{usecase → controller/api}/terraform/terraform.rb +1 -1
- data/lib/{usecase → controller/api}/vpn/README.md +1 -1
- data/lib/{usecase → controller/api}/vpn/vpn.ini +0 -0
- data/lib/{usecase → controller/api}/vpn/vpn.rb +0 -0
- data/lib/{usecase → controller}/config/README.md +0 -0
- data/lib/{usecase → controller}/edit/README.md +0 -0
- data/lib/controller/edit/editverse.rb +48 -0
- data/lib/controller/edit/put.rb +35 -0
- data/lib/controller/edit/remove.rb +29 -0
- data/lib/{usecase/update/README.md → controller/edit/rename.md} +0 -0
- data/lib/{usecase → controller}/files/README.md +1 -1
- data/lib/controller/files/read.rb +36 -0
- data/lib/{usecase/files/eject.rb → controller/files/write.rb} +15 -20
- data/lib/{usecase → controller}/id.rb +0 -0
- data/lib/controller/query/print.rb +26 -0
- data/lib/controller/query/queryverse.rb +39 -0
- data/lib/controller/query/show.rb +50 -0
- data/lib/{session/require.gem.rb → controller/requirer.rb} +13 -9
- data/lib/{usecase → controller}/set.rb +4 -4
- data/lib/controller/usecase.rb +244 -0
- data/lib/{usecase → controller}/verse.rb +0 -0
- data/lib/{usecase → controller}/visit/README.md +0 -0
- data/lib/{usecase → controller}/visit/visit.rb +0 -0
- data/lib/factbase/facts.safedb.net.ini +7 -7
- data/lib/{keytools/key.docs.rb → model/README.md} +102 -66
- data/lib/model/book.rb +484 -0
- data/lib/model/branch.rb +48 -0
- data/lib/model/checkin.feature +33 -0
- data/lib/{configs/README.md → model/configs.md} +4 -4
- data/lib/model/content.rb +214 -0
- data/lib/model/indices.rb +132 -0
- data/lib/model/safe_tree.rb +51 -0
- data/lib/model/state.inspect.rb +221 -0
- data/lib/model/state.migrate.rb +334 -0
- data/lib/model/text_chunk.rb +68 -0
- data/lib/{extension → utils/extend}/array.rb +0 -0
- data/lib/{extension → utils/extend}/dir.rb +0 -0
- data/lib/{extension → utils/extend}/file.rb +0 -0
- data/lib/utils/extend/hash.rb +76 -0
- data/lib/{extension → utils/extend}/string.rb +6 -6
- data/lib/{session/fact.finder.rb → utils/facts/fact.rb} +0 -0
- data/lib/utils/identity/identifier.rb +356 -0
- data/lib/{keytools/key.ident.rb → utils/identity/machine.id.rb} +67 -4
- data/lib/utils/inspect/inspector.rb +81 -0
- data/lib/{keytools/kdf.bcrypt.rb → utils/kdfs/bcrypt.rb} +0 -0
- data/lib/{keytools → utils/kdfs}/kdf.api.rb +16 -16
- data/lib/{keytools/key.local.rb → utils/kdfs/kdfs.rb} +40 -40
- data/lib/{keytools/kdf.pbkdf2.rb → utils/kdfs/pbkdf2.rb} +0 -0
- data/lib/{keytools/kdf.scrypt.rb → utils/kdfs/scrypt.rb} +0 -0
- data/lib/{keytools → utils}/key.error.rb +2 -2
- data/lib/{keytools → utils}/key.pass.rb +2 -2
- data/lib/{keytools → utils/keys}/key.64.rb +0 -0
- data/lib/{keytools → utils/keys}/key.rb +6 -2
- data/lib/{keytools/key.iv.rb → utils/keys/random.iv.rb} +0 -0
- data/lib/{logging/gem.logging.rb → utils/logs/logger.rb} +6 -5
- data/lib/{keytools/key.pair.rb → utils/store/datamap.rb} +48 -30
- data/lib/{keytools/key.db.rb → utils/store/datastore.rb} +38 -104
- data/lib/utils/store/merge-boys-school.json +40 -0
- data/lib/utils/store/merge-girls-school.json +48 -0
- data/lib/utils/store/merge-merged-data.json +56 -0
- data/lib/utils/store/struct.rb +75 -0
- data/lib/utils/store/test-commands.sh +24 -0
- data/lib/{keytools/key.now.rb → utils/time/timestamp.rb} +32 -21
- data/lib/version.rb +1 -1
- metadata +86 -73
- data/lib/extension/hash.rb +0 -33
- data/lib/keytools/key.algo.rb +0 -109
- data/lib/keytools/key.api.rb +0 -1326
- data/lib/keytools/key.id.rb +0 -322
- data/lib/modules/cryptology/amalgam.rb +0 -70
- data/lib/modules/cryptology/engineer.rb +0 -99
- data/lib/modules/mappers/dictionary.rb +0 -288
- data/lib/session/time.stamp.rb +0 -340
- data/lib/session/user.home.rb +0 -49
- data/lib/usecase/cmd.rb +0 -471
- data/lib/usecase/edit/delete.rb +0 -46
- data/lib/usecase/files/file_me.rb +0 -78
- data/lib/usecase/files/read.rb +0 -169
- data/lib/usecase/files/write.rb +0 -89
- data/lib/usecase/goto.rb +0 -57
- data/lib/usecase/import.rb +0 -157
- data/lib/usecase/init.rb +0 -61
- data/lib/usecase/login.rb +0 -72
- data/lib/usecase/open.rb +0 -71
- data/lib/usecase/print.rb +0 -40
- data/lib/usecase/put.rb +0 -81
- data/lib/usecase/show.rb +0 -138
- data/lib/usecase/update/rename.rb +0 -180
- data/lib/usecase/view.rb +0 -71
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bcafea21f4204ecebc6712dd926e839aeb8c078904487528b44de4b1f87b4d8
|
4
|
+
data.tar.gz: 256015d30eb46362a1d3923d6a7cf0c1d88942b67c4f5cd8e7dce6b6b5fb40b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d013b6386bfc912ede2b8ad1736309c48cbbbb36d3e23731c092f4e041df47a3d012aa9a5ea5ecebb841d8f0066f040da2b3fb1c1e61adfff424997bc429f2ca
|
7
|
+
data.tar.gz: 42a6f28ecad6fc9fcbd759b4abdcfea468ebfe491cd75775698055b52946042009123edf6c1b5cc8bd56cd78fc8f78bd33ee42861cf3b973de44c67a7cc39beb
|
data/CONTRIBUTING.md
CHANGED
@@ -42,20 +42,68 @@ reek lib
|
|
42
42
|
```
|
43
43
|
|
44
44
|
|
45
|
-
##
|
45
|
+
## Automated Software Release
|
46
46
|
|
47
|
-
|
47
|
+
safedb is automatically released by Jenkins using a GitOps style pipeline defined in the Jenkinsfile and Dockerfile. The release to rubygems.org depends on
|
48
48
|
|
49
|
-
|
49
|
+
- a pull request to the [safe github master branch](https://github.com/devops4me/safedb.net.git)
|
50
|
+
- an error-free gem build
|
51
|
+
- an error-free documentation image build to www.safedb.net
|
52
|
+
- immaculate BDD test runs with **Cucumber and Aruba** in Linux environments incl Ubuntu, Raspbian and RHEL.
|
53
|
+
- an automated version number bump using the gem-release gem
|
54
|
+
- quality numbers passed by the Reek code quality analyzer
|
55
|
+
- available rubygems.org credentials in ~/.gem/credentials
|
50
56
|
|
51
|
-
|
52
|
-
- **or** a credentials file containing a hex API key
|
57
|
+
## release safedb to RubyGems.org
|
53
58
|
|
54
|
-
|
59
|
+
Once only use **`gem push`** at the repository root to create a **rubygems API key** and slurp it up from the **`~/.gem/credentials`** with **`safe file rubygems.org.credentials ~/.gem/credentials`**
|
60
|
+
Now when releasing we eject the file back into **`~/.gem/credentials`**, secure it ( with **`sudo chmod 0600 credentials`** ) and then issue the below command from the **gem-release** gem.
|
61
|
+
|
62
|
+
### `gem bump patch --tag --push --release --file=$PWD/lib/version.rb`
|
63
|
+
|
64
|
+
The gem bump (and release) command bumps up the patch (or major or minor) version, tags the repository, pushes the changes and releases to rubygems.org
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
## safedb development environment commands
|
69
|
+
|
70
|
+
### `rake install`
|
71
|
+
### `cucumber`
|
72
|
+
### `git checkout -b feature.commit-branch`
|
73
|
+
### `git add; git commit;`
|
74
|
+
### `git cherry -v origin`
|
75
|
+
### `git cherry -v origin feature.commit-branch`
|
76
|
+
### `git push -u origin feature.commit-branch`
|
77
|
+
### `git pull origin master`
|
78
|
+
### `git pull origin feature.commit-branch`
|
79
|
+
|
80
|
+
## common git feature merge commands
|
81
|
+
|
82
|
+
### `git checkout master`
|
83
|
+
### `git pull origin master`
|
84
|
+
### `git merge feature.commit-branch`
|
85
|
+
### `git push -u origin master`
|
86
|
+
|
87
|
+
|
88
|
+
## Branch Naming Convention
|
55
89
|
|
56
|
-
|
90
|
+
Branch names begin with either
|
57
91
|
|
58
|
-
|
92
|
+
- feature. (or)
|
93
|
+
- bug. (or)
|
94
|
+
- refactor.
|
95
|
+
|
96
|
+
Branch names are then typically a **verb-noun concatenation** like
|
97
|
+
|
98
|
+
- feature.safe-inport-export
|
99
|
+
- refactor.book-id-create-algorithm
|
100
|
+
- refactor.validate-book-names
|
101
|
+
|
102
|
+
## how to git push to safedb.net
|
103
|
+
|
104
|
+
Those with priveleges to release to safedb.net will have a private key to push pull requests into the repository.
|
105
|
+
|
106
|
+
This is how to setup the **ssh config** and **pem private key**.
|
59
107
|
|
60
108
|
```
|
61
109
|
safe login safe.ecosystem
|
@@ -71,15 +119,4 @@ git clone git@safedb.code:devops4me/safedb.net.git mirror.safedb.code
|
|
71
119
|
|
72
120
|
If a config file already exists then safe will back it up with a timestamp prefix before clobbering the file. Now bump up the major, minor or patch versions, then commit.
|
73
121
|
|
74
|
-
### development installs | rake install
|
75
|
-
|
76
|
-
Use rake install to locally test local software changes.
|
77
|
-
|
78
|
-
### bump | tag | release to RubyGems.org
|
79
|
-
|
80
|
-
Once only use **`gem push`** at the repository root to create a **rubygems API key** and slurp it up from the **`~/.gem/credentials`** with **`safe file rubygems.org.credentials ~/.gem/credentials`**
|
81
|
-
Now when releasing we eject the file back into **`~/.gem/credentials`**, secure it ( with **`sudo chmod 0600 credentials`** ) and then issue the below command from the **gem-release** gem.
|
82
|
-
|
83
|
-
### `gem bump patch --tag --push --release --file=$PWD/lib/version.rb`
|
84
122
|
|
85
|
-
This command bumps up the patch (or major or minor) version, tags the repository, pushes the changes and releases to rubygems.org
|
data/README.md
CHANGED
@@ -104,7 +104,7 @@ safe | Install and Configure
|
|
104
104
|
|
105
105
|
$ sudo apt-get install ruby-full # for OpenSSL we need full ruby
|
106
106
|
$ sudo gem install safedb # install the safe ruby gem
|
107
|
-
$ export SAFE_TTY_TOKEN=`safe token` # setup a shell
|
107
|
+
$ export SAFE_TTY_TOKEN=`safe token` # setup a shell variable
|
108
108
|
$ safe init joe@abc ~/safedb.creds # initialize a safe book in folder
|
109
109
|
$ safe login joe@abc # login with the created password
|
110
110
|
|
@@ -143,7 +143,7 @@ Advanced users should avoid adding the export command to <tt>~/.bash_profile</tt
|
|
143
143
|
|
144
144
|
When the shell closes the shell token will disappear which is good. You can clear it immediately with these commands.
|
145
145
|
|
146
|
-
$ unset SAFE_TTY_TOKEN # Delete the shell
|
146
|
+
$ unset SAFE_TTY_TOKEN # Delete the shell token
|
147
147
|
$ env | grep SAFE_TTY_TOKEN # Check SAFE_TTY_TOKEN is deleted
|
148
148
|
$ env -i bash # Delete every env var created by shell
|
149
149
|
|
@@ -578,7 +578,7 @@ safe | moving computer
|
|
578
578
|
We travel between laptops, desktops, virtual machines and even docker containers. Always run init the first time you use a domain on a different computer.
|
579
579
|
|
580
580
|
$ gem install safe
|
581
|
-
$ export SAFE_TTY_TOKEN=`safe token` # setup a shell
|
581
|
+
$ export SAFE_TTY_TOKEN=`safe token` # setup a shell variable
|
582
582
|
$ safe init joe@abc /home/joe/credentials # initialize a secrets domain
|
583
583
|
$ safe login joe@abc # login to the new domain
|
584
584
|
|
@@ -647,7 +647,7 @@ You can require safe (as an SDK) and interact with it directly from any other Ru
|
|
647
647
|
$ gem install safe
|
648
648
|
$ irb
|
649
649
|
$ > require "safe"
|
650
|
-
$ > SafeDb::
|
650
|
+
$ > SafeDb::CLI.version()
|
651
651
|
|
652
652
|
The above should return the **installed version** of SafeDb.
|
653
653
|
|
@@ -752,17 +752,17 @@ This method (theoretially) allows a version 3.428.24952 to restore an export of
|
|
752
752
|
|
753
753
|
## Safe's Concurrency Methodology
|
754
754
|
|
755
|
-
A safe repository (book) can be changed by one
|
755
|
+
A safe repository (book) can be changed by one branch but read concurrently by multiple branchs.
|
756
756
|
|
757
757
|
Directory Links are NOT PORTABLE to use to point to the active workspace especially if we the safe root folder is on a USB key.
|
758
758
|
A GOOD engough concurrency technique is a lock file in the BOOK's root folder that is named `safe.concurrency.lockfile.<<book.id>>`
|
759
759
|
|
760
|
-
The contents of the file will hold the relative directory name (
|
760
|
+
The contents of the file will hold the relative directory name (branch ID based) that has the lock and the branch ID that had it before that (if not first).
|
761
761
|
|
762
|
-
The <machine.id>.<bootup.id> is used to when the first read/write login
|
762
|
+
The <machine.id>.<bootup.id> is used to when the first read/write login branch occurs. Subsequent logins for a read/write branch will then have 2 choices in this shell.
|
763
763
|
|
764
|
-
- safe login ali.baba --steal # take over the primary read/write
|
765
|
-
- safe login ali.baba --branch # leave primary
|
764
|
+
- safe login ali.baba --steal # take over the primary read/write branch
|
765
|
+
- safe login ali.baba --branch # leave primary branch but open one that will not change the price of sugar
|
766
766
|
- safe login ali.baba --branch=master
|
767
767
|
- safe login ali.baba --branch=experimental
|
768
768
|
- safe login ali.baba -b experimental
|
@@ -775,7 +775,7 @@ A third choice arises if we visit the shell holding the directory pointer and lo
|
|
775
775
|
|
776
776
|
Logout NEVER TOUCHES the lock file (it could have moved on multiple times so only login can act on it).
|
777
777
|
|
778
|
-
However logout DELETES the cipher.file
|
778
|
+
However logout DELETES the cipher.file branch ciphertext that can be unlocked by branch key to retrieve the content key. This action renders it impossible to read or write any data from logged in book.
|
779
779
|
|
780
780
|
A subsequent login can again re-instate this privilege.
|
781
781
|
|
@@ -790,22 +790,22 @@ The first repo holds the live link.
|
|
790
790
|
|
791
791
|
Subsequent logins must perform two checks
|
792
792
|
|
793
|
-
- IS MY DIRECTORY (
|
794
|
-
- (if other directory) - Does the
|
793
|
+
- IS MY DIRECTORY (branch) noted as the latest in the lock file (possible if you've logged out of the same shell)
|
794
|
+
- (if other directory) - Does the branch key within that directory's cipher file have a value
|
795
795
|
|
796
796
|
The popup asking the user to STEAL or go READONLY is triggered if the answers above are NO then YES.
|
797
797
|
|
798
798
|
### Safe steal | HowTo
|
799
799
|
|
800
|
-
If
|
800
|
+
If branch key has no value then stealing is not necessary so the existence of the --steal flag does not change the price of sugar.
|
801
801
|
|
802
802
|
The Stealing flow of events is to
|
803
803
|
|
804
|
-
- copy the directory into a new one for this
|
804
|
+
- copy the directory into a new one for this branch named `<<book.id>>.<<timestamp>>.<<branch.key>>`
|
805
805
|
- validate the directory for data consistency (nice to have functionality)
|
806
806
|
- collect the password and if invalid stop now
|
807
807
|
- grab the lock file and write it to point it to our directory (we are it)
|
808
|
-
- create our own
|
808
|
+
- create our own branch key and write it in within our folder
|
809
809
|
|
810
810
|
### Safe branch | HowTo
|
811
811
|
|
data/Rakefile
CHANGED
data/bin/safe
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
require "thor"
|
2
2
|
require "fileutils"
|
3
|
+
require "strscan"
|
3
4
|
|
4
|
-
require "
|
5
|
-
require "
|
6
|
-
require "session/require.gem"
|
7
|
-
|
5
|
+
require "utils/logs/logger"
|
6
|
+
require "controller/requirer"
|
8
7
|
|
9
8
|
# Include the logger mixins so that every class can enjoy "import free"
|
10
9
|
# logging through pointers to the (extended) log behaviour.
|
11
|
-
include
|
10
|
+
include LogImpl
|
12
11
|
|
13
12
|
|
14
13
|
# This standard out sync command flushes text destined for STDOUT immediately,
|
@@ -20,7 +19,7 @@ $stdout.sync = true
|
|
20
19
|
# that this code is executing from. Only use this tool if your library is
|
21
20
|
# relatively small but highly interconnected. In these instances it raises
|
22
21
|
# productivity and reduces pesky "not found" exceptions.
|
23
|
-
|
22
|
+
SafeDb::Require.gems( __FILE__ )
|
24
23
|
|
25
24
|
|
26
25
|
# This command line processor extends the Thor gem CLI tools in order to
|
@@ -32,7 +31,7 @@ OpenSession::RecursivelyRequire.now( __FILE__ )
|
|
32
31
|
# - ensure that the parameter values are in range
|
33
32
|
# - delegate processing to the registered handlers
|
34
33
|
|
35
|
-
class
|
34
|
+
class CLI < Thor
|
36
35
|
|
37
36
|
|
38
37
|
log.info(x) { "request to interact with a safe book has been received." }
|
@@ -69,7 +68,7 @@ class Interprete < Thor
|
|
69
68
|
# - either <tt>safe --version</tt>
|
70
69
|
# - or <tt>safe version</tt>
|
71
70
|
def version
|
72
|
-
log.info(x) { "
|
71
|
+
log.info(x) { "print the version of this safedb.net personal database." }
|
73
72
|
|
74
73
|
puts ""
|
75
74
|
puts "safedb gem version => v#{SafeDb::VERSION}"
|
@@ -82,25 +81,23 @@ class Interprete < Thor
|
|
82
81
|
|
83
82
|
|
84
83
|
|
85
|
-
# Description of the
|
86
|
-
desc "init <book_name> <storage_dir>", "initialize
|
84
|
+
# Description of the book initialize call.
|
85
|
+
desc "init <book_name> <storage_dir>", "initialize a new safe credentials book"
|
87
86
|
|
88
87
|
# Use <tt>password</tt> if confident that either the command history is
|
89
88
|
# inaccessible or the call originates from non-interactive software.
|
90
89
|
option :password, :aliases => '-p'
|
91
90
|
|
92
|
-
# Initialize
|
93
|
-
#
|
91
|
+
# Initialize a safe credentials book with this name and collect the human sourced
|
92
|
+
# pasword to be put through key derivation functions.
|
94
93
|
#
|
95
|
-
# @param
|
96
|
-
|
97
|
-
|
98
|
-
log.info(x) { "initialize the safe book on this device." }
|
94
|
+
# @param book_name [String] the name of the credentials book to be created
|
95
|
+
def init( book_name )
|
96
|
+
log.info(x) { "initialize a new safe credentials book called [#{book_name}]." }
|
99
97
|
init_uc = SafeDb::Init.new
|
100
98
|
init_uc.password = options[ :password ] if options[ :password ]
|
101
|
-
init_uc.
|
102
|
-
init_uc.
|
103
|
-
init_uc.flow_of_events
|
99
|
+
init_uc.book_name = book_name
|
100
|
+
init_uc.flow()
|
104
101
|
end
|
105
102
|
|
106
103
|
|
@@ -112,14 +109,14 @@ class Interprete < Thor
|
|
112
109
|
# inaccessible or the call originates from non-interactive software.
|
113
110
|
option :password, :aliases => '-p'
|
114
111
|
|
115
|
-
# Login in order to securely interact with your
|
116
|
-
# @param
|
117
|
-
def login(
|
118
|
-
log.info(x) { "
|
112
|
+
# Login in order to securely interact with your safe credentials.
|
113
|
+
# @param book_name [String] the name of the credentials book to login to
|
114
|
+
def login( book_name = nil )
|
115
|
+
log.info(x) { "login to the safe credentials book called [#{book_name}]." }
|
119
116
|
login_uc = SafeDb::Login.new
|
120
|
-
login_uc.
|
117
|
+
login_uc.book_name = book_name unless book_name.nil?
|
121
118
|
login_uc.password = options[ :password ] if options[ :password ]
|
122
|
-
login_uc.
|
119
|
+
login_uc.flow()
|
123
120
|
end
|
124
121
|
|
125
122
|
|
@@ -132,10 +129,10 @@ class Interprete < Thor
|
|
132
129
|
#
|
133
130
|
# @param key_name [String] the key whose value is to be printed
|
134
131
|
def print key_name
|
135
|
-
log.info(x) { "
|
132
|
+
log.info(x) { "print the key value at the opened chapter and verse." }
|
136
133
|
print_uc = SafeDb::Print.new
|
137
134
|
print_uc.key_name = key_name
|
138
|
-
print_uc.
|
135
|
+
print_uc.flow()
|
139
136
|
end
|
140
137
|
|
141
138
|
|
@@ -145,21 +142,21 @@ class Interprete < Thor
|
|
145
142
|
|
146
143
|
# Print the name of the verse at the opened chapter and verse location.
|
147
144
|
def verse
|
148
|
-
log.info(x) { "
|
145
|
+
log.info(x) { "print the verse name at the opened chapter and verse." }
|
149
146
|
verse_uc = SafeDb::Verse.new
|
150
|
-
verse_uc.
|
147
|
+
verse_uc.flow()
|
151
148
|
end
|
152
149
|
|
153
150
|
|
154
151
|
|
155
152
|
# Description of the safe token use case.
|
156
|
-
desc "token", "generate and print out an encrypted (shell bound)
|
153
|
+
desc "token", "generate and print out an encrypted (shell bound) shell token"
|
157
154
|
|
158
|
-
# The<b>token</b> use cases prints out an encrypted
|
155
|
+
# The<b>token</b> use cases prints out an encrypted shell token tied
|
159
156
|
# to the workstation and shell environment.
|
160
157
|
def token
|
161
|
-
log.info(x) { "
|
162
|
-
SafeDb::Token.new.
|
158
|
+
log.info(x) { "generate and print out an encrypted (shell bound) shell token" }
|
159
|
+
SafeDb::Token.new.flow()
|
163
160
|
end
|
164
161
|
|
165
162
|
|
@@ -191,11 +188,67 @@ class Interprete < Thor
|
|
191
188
|
# @param verse [String]
|
192
189
|
# the verse of the logged in book and specified chapter to open
|
193
190
|
def open chapter, verse
|
194
|
-
log.info(x) { "
|
191
|
+
log.info(x) { "open a chapter and verse to read from or write to." }
|
195
192
|
open_uc = SafeDb::Open.new
|
196
|
-
open_uc.
|
197
|
-
open_uc.
|
198
|
-
open_uc.
|
193
|
+
open_uc.chapter = chapter
|
194
|
+
open_uc.verse = verse
|
195
|
+
open_uc.flow()
|
196
|
+
end
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
# Description of the diff use case command from the point of view
|
201
|
+
# of either a checkout from master to branch, a checkin from branch
|
202
|
+
# to master or a diff listing prophesying about both.
|
203
|
+
desc "diff", "master and branch diff with --checkin (-i), --checkout (-o) or both."
|
204
|
+
|
205
|
+
# A checkin is basically a copy-overwrite operation which does not finesse
|
206
|
+
# like the merging checkout does. The diff report illustrates that the master
|
207
|
+
# will essentially reflect the working branch's current state.
|
208
|
+
method_option :checkin, :type => :boolean, :aliases => "-i"
|
209
|
+
|
210
|
+
# A checkout is effectively an incoming merge of the master's data
|
211
|
+
# structure into the working branch. With checkouts nothing ever gets
|
212
|
+
# deleted.
|
213
|
+
method_option :checkout, :type => :boolean, :aliases => "-o"
|
214
|
+
|
215
|
+
# The <b>diff use case</b> spells out the key differences between the safe book
|
216
|
+
# on the master line the one on the current working branch.
|
217
|
+
#
|
218
|
+
# By default when conflicts occur, priority is given to the current working branch.
|
219
|
+
# No parameters are required to perform a diff.
|
220
|
+
def diff
|
221
|
+
log.info(x) { "prophesy list of checkout and/or checkin actions. CLI options are #{options.to_s()}" }
|
222
|
+
diff_uc = SafeDb::Diff.new()
|
223
|
+
diff_uc.checkin = true if options[ :checkin ]
|
224
|
+
diff_uc.checkout = true if options[ :checkout ]
|
225
|
+
diff_uc.flow()
|
226
|
+
end
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
# Description of the checkin use case command.
|
231
|
+
desc "checkin", "commit (save) the branch changes by putting them into master."
|
232
|
+
|
233
|
+
# The <b>checkin use case</b> commits any changes made to the safe book into
|
234
|
+
# master. This is straightforward if the master's state has not been forwarded
|
235
|
+
# by a ckeckin from another (shell) branch.
|
236
|
+
def checkin
|
237
|
+
log.info(x) { "commit (save) any changes made to this branch into the master." }
|
238
|
+
SafeDb::CheckIn.new.flow()
|
239
|
+
end
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
# Description of the checkout use case command.
|
244
|
+
desc "checkout", "refresh (update) the working branch with changes from the master."
|
245
|
+
|
246
|
+
# The <b>checkout use case</b> commits any changes made to the safe book into
|
247
|
+
# master. This is straightforward if the master's state has not been forwarded
|
248
|
+
# by a ckeckin from another (shell) branch.
|
249
|
+
def checkout
|
250
|
+
log.info(x) { "refresh (update) the working branch with changes from the master." }
|
251
|
+
SafeDb::CheckOut.new.flow()
|
199
252
|
end
|
200
253
|
|
201
254
|
|
@@ -207,117 +260,111 @@ class Interprete < Thor
|
|
207
260
|
# The --print flag demands that the exported text goes to stdout otherwise it
|
208
261
|
# will be placed in an aptly named file in the present working directory.
|
209
262
|
def export
|
210
|
-
log.info(x) { "
|
211
|
-
SafeDb::Export.new.
|
263
|
+
log.info(x) { "export book chapter content or dictionary at verse in JSON format." }
|
264
|
+
SafeDb::Export.new.flow()
|
212
265
|
end
|
213
266
|
|
214
267
|
|
215
268
|
|
216
|
-
# Description of the
|
217
|
-
desc "
|
269
|
+
# Description of the import use case command.
|
270
|
+
desc "import", "imports the contents of the parameter json file into this book."
|
218
271
|
|
219
|
-
#
|
220
|
-
#
|
221
|
-
#
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
put_uc.secret_id = secret_id
|
228
|
-
put_uc.secret_value = secret_value
|
229
|
-
put_uc.flow_of_events
|
272
|
+
# The <b>import use case</b> takes a filepath parameter in order to pull in
|
273
|
+
# a <em>json</em> formatted data structure.
|
274
|
+
# @param import_filepath [String] the path to the JSON file that we will import
|
275
|
+
def import import_filepath
|
276
|
+
log.info(x) { "importing into current book from file #{import_filepath}." }
|
277
|
+
import_uc = SafeDb::Import.new
|
278
|
+
import_uc.import_filepath = import_filepath
|
279
|
+
import_uc.flow()
|
230
280
|
end
|
231
281
|
|
232
282
|
|
233
283
|
|
234
|
-
# Description of the
|
235
|
-
desc "
|
284
|
+
# Description of the put secret command.
|
285
|
+
desc "put <key> <value>", "put key/value pair into dictionary at open chapter and verse"
|
236
286
|
|
237
|
-
#
|
238
|
-
#
|
287
|
+
# Put a secret with an id like login/username and a value like joebloggs into the
|
288
|
+
# context (eg work/laptop) that was opened with the open command.
|
239
289
|
#
|
240
|
-
# @param
|
241
|
-
# @param
|
242
|
-
def
|
243
|
-
log.info(x) { "
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
file_uc.flow_of_events
|
290
|
+
# @param credential_id [String] the id of the secret to put into the opened context
|
291
|
+
# @param credential_value [String] the value of the secret to put into the opened context
|
292
|
+
def put credential_id, credential_value
|
293
|
+
log.info(x) { "put key/value pair into dictionary at open chapter and verse." }
|
294
|
+
put_uc = SafeDb::Put.new
|
295
|
+
put_uc.credential_id = credential_id
|
296
|
+
put_uc.credential_value = credential_value
|
297
|
+
put_uc.flow()
|
249
298
|
end
|
250
299
|
|
251
300
|
|
252
301
|
|
253
|
-
# Description of the
|
254
|
-
desc "
|
302
|
+
# Description of the set configuration directives command.
|
303
|
+
desc "set <directive_name> <directive_value>", "set book-scoped configuration directive"
|
255
304
|
|
256
|
-
# The <b>
|
257
|
-
#
|
305
|
+
# The <b>set <em>use case</em></b> is the generic tool for setting book scoped
|
306
|
+
# configuration directives. These directives can only be read, written, updated
|
307
|
+
# or removed during a logged in branch.
|
258
308
|
#
|
259
|
-
# @param
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
309
|
+
# @param directive_name [String] the name of the book-scoped configuration directive
|
310
|
+
# @param directive_value [String] the value of the book-scoped configuration directive
|
311
|
+
def set directive_name, directive_value
|
312
|
+
log.info(x) { "set the configuration directive value for #{directive_name}" }
|
313
|
+
set_uc = SafeDb::Set.new
|
314
|
+
set_uc.directive_name = directive_name
|
315
|
+
set_uc.directive_value = directive_value
|
316
|
+
set_uc.flow()
|
266
317
|
end
|
267
318
|
|
268
319
|
|
269
320
|
|
270
|
-
# Description of the
|
271
|
-
desc "
|
321
|
+
# Description of the remove command.
|
322
|
+
desc "remove <line_id>", "remove a line (key/value pair), or a verse, chapter and even a book"
|
272
323
|
|
273
|
-
# The <b>
|
324
|
+
# The <b>remove use case</b> can remove a single line (key/value pair), or
|
274
325
|
# a verse, chapter and even a book
|
275
326
|
#
|
276
|
-
# @param
|
277
|
-
def
|
278
|
-
log.info(x) { "
|
279
|
-
|
280
|
-
|
281
|
-
|
327
|
+
# @param line_id [String] the ID of the entity to remove (line, verse, chapter or book)
|
328
|
+
def remove line_id
|
329
|
+
log.info(x) { "remove a safe entity with a key id [#{line_id}]." }
|
330
|
+
remove_uc = SafeDb::Remove.new()
|
331
|
+
remove_uc.line_id = line_id
|
332
|
+
remove_uc.flow()
|
282
333
|
end
|
283
334
|
|
284
335
|
|
285
336
|
|
286
337
|
# Description of the read command.
|
287
|
-
desc "read <file_url>", "read
|
338
|
+
desc "read <file_url>", "read file into the open chapter and verse for safe keeping."
|
288
339
|
|
289
|
-
# The <b>read use case</b> pulls a
|
290
|
-
# or from a remote http, https, git, S3, GoogleDrive and/or ssh source.
|
291
|
-
#
|
292
|
-
# This use case expects a @file_url parameter. The actions it takes are to
|
293
|
-
#
|
294
|
-
# - register @in.url to mirror @file_url
|
295
|
-
# - register @out.url to mirror @file_url
|
296
|
-
# - check the location of @file_url
|
297
|
-
# - if no file exists it humbly finishes up
|
340
|
+
# The <b>read use case</b> pulls a file in from either an accessible filesystem.
|
298
341
|
#
|
342
|
+
# @param file_key [String] keyname representing the file that is being read in
|
299
343
|
# @param file_url [String] url of file to ingest and assimilate into the safe
|
300
|
-
def read file_url
|
301
|
-
log.info(x) { "
|
344
|
+
def read file_key, file_url
|
345
|
+
log.info(x) { "read file into key #{file_key} from url #{file_url}" }
|
302
346
|
read_uc = SafeDb::Read.new
|
347
|
+
read_uc.file_key = file_key
|
303
348
|
read_uc.file_url = file_url
|
304
|
-
read_uc.
|
349
|
+
read_uc.flow()
|
305
350
|
end
|
306
351
|
|
307
352
|
|
308
353
|
|
309
354
|
# Description of the write command.
|
310
|
-
desc "write <
|
355
|
+
desc "write <file_key>", "write out file to current folder or use --to_dir=</path/to/dir."
|
311
356
|
|
312
357
|
# The <b>write use case</b> writes out a file that was previously ingested
|
313
358
|
# and coccooned inside the safe.
|
314
359
|
#
|
315
|
-
# @param
|
316
|
-
def write(
|
317
|
-
log.info(x) { "
|
360
|
+
# @param file_key [String] the key name of the file to write out onto the filesystem
|
361
|
+
def write( file_key )
|
362
|
+
log.info(x) { "write out the file against key #{file_key}" }
|
363
|
+
log.info(x) { "output folder optionally set to #{options[:to_dir]}" } if options[:to_dir]
|
318
364
|
write_uc = SafeDb::Write.new
|
319
|
-
write_uc.
|
320
|
-
write_uc.
|
365
|
+
write_uc.file_key = file_key
|
366
|
+
write_uc.to_dir = options[:to_dir] if options[:to_dir]
|
367
|
+
write_uc.flow()
|
321
368
|
end
|
322
369
|
|
323
370
|
|
@@ -328,8 +375,8 @@ class Interprete < Thor
|
|
328
375
|
# Show the secrets at the opened path. These secrets
|
329
376
|
# are simply written out to the shell console.
|
330
377
|
def show
|
331
|
-
log.info(x) { "
|
332
|
-
SafeDb::Show.new.
|
378
|
+
log.info(x) { "show dictionary at the opened chapter and verse." }
|
379
|
+
SafeDb::Show.new.flow()
|
333
380
|
end
|
334
381
|
|
335
382
|
|
@@ -340,9 +387,9 @@ class Interprete < Thor
|
|
340
387
|
# Display a bird's eye view of the domain's database including
|
341
388
|
# its envelopes, their keys and imported objects such as files.
|
342
389
|
def view
|
343
|
-
log.info(x) { "
|
390
|
+
log.info(x) { "print list of chapter and verse combos to console." }
|
344
391
|
view_uc = SafeDb::View.new
|
345
|
-
view_uc.
|
392
|
+
view_uc.flow()
|
346
393
|
end
|
347
394
|
|
348
395
|
|
@@ -356,10 +403,10 @@ class Interprete < Thor
|
|
356
403
|
# @param index [Number]
|
357
404
|
# the integer index chosen from the list procured by the view command.
|
358
405
|
def goto index
|
359
|
-
log.info(x) { "
|
406
|
+
log.info(x) { "opens the chapter and verse at index [#{index}]." }
|
360
407
|
goto_uc = SafeDb::Goto.new
|
361
408
|
goto_uc.index = index
|
362
|
-
goto_uc.
|
409
|
+
goto_uc.flow()
|
363
410
|
|
364
411
|
end
|
365
412
|
|
@@ -385,10 +432,10 @@ class Interprete < Thor
|
|
385
432
|
# the terraform command to run which is currently limited to plan, apply and destroy.
|
386
433
|
# This parameter is optional and if nothing is given then "apply" is assumed.
|
387
434
|
def terraform( command = nil )
|
388
|
-
log.info(x) { "
|
435
|
+
log.info(x) { "will export IAM credentials then invoke $ terraform #{command}" }
|
389
436
|
terraform_uc = SafeDb::Terraform.new
|
390
437
|
terraform_uc.command = command if command
|
391
|
-
terraform_uc.
|
438
|
+
terraform_uc.flow()
|
392
439
|
end
|
393
440
|
|
394
441
|
|
@@ -422,14 +469,14 @@ class Interprete < Thor
|
|
422
469
|
#
|
423
470
|
def jenkins( command, service, url )
|
424
471
|
|
425
|
-
log.info(x) { "
|
472
|
+
log.info(x) { "request to #{command} #{service} credentials to Jenkins at #{url}" }
|
426
473
|
jenkins_uc = SafeDb::Jenkins.new
|
427
474
|
|
428
475
|
jenkins_uc.command = command if command
|
429
476
|
jenkins_uc.service = service if service
|
430
477
|
jenkins_uc.url = url if url
|
431
478
|
|
432
|
-
jenkins_uc.
|
479
|
+
jenkins_uc.flow()
|
433
480
|
|
434
481
|
end
|
435
482
|
|
@@ -448,10 +495,10 @@ class Interprete < Thor
|
|
448
495
|
# login or logout
|
449
496
|
def docker( command = "login" )
|
450
497
|
|
451
|
-
log.info(x) { "
|
498
|
+
log.info(x) { "request to #{command} into or out of a docker repository." }
|
452
499
|
docker_uc = SafeDb::Docker.new
|
453
500
|
docker_uc.command = command
|
454
|
-
docker_uc.
|
501
|
+
docker_uc.flow()
|
455
502
|
|
456
503
|
end
|
457
504
|
|
@@ -461,16 +508,16 @@ class Interprete < Thor
|
|
461
508
|
desc "vpn <command>", "runs vpn command typically safe vpn up or safe vpn down"
|
462
509
|
|
463
510
|
# This VPN use case connects to the VPN whose specifics are recorded within the vpn.ini
|
464
|
-
# factfile living in the same directory as the vpn.rb
|
511
|
+
# factfile living in the same directory as the vpn.rb controlling class.
|
465
512
|
#
|
466
513
|
# @param command [String]
|
467
514
|
# the vpn command to run which is currently limited to up or down
|
468
515
|
# This parameter is optional and if nothing is given then "up" is assumed.
|
469
516
|
def vpn( command = nil )
|
470
|
-
log.info(x) { "
|
517
|
+
log.info(x) { "VPN connection command #{command} has been issued." }
|
471
518
|
vpn_uc = SafeDb::Vpn.new
|
472
519
|
vpn_uc.command = command if command
|
473
|
-
vpn_uc.
|
520
|
+
vpn_uc.flow()
|
474
521
|
end
|
475
522
|
|
476
523
|
|
@@ -480,9 +527,9 @@ class Interprete < Thor
|
|
480
527
|
|
481
528
|
# Put out the multiple formats of the current timestamp.
|
482
529
|
def id
|
483
|
-
log.info(x) { "
|
530
|
+
log.info(x) { "prints out the current timestamp identifiers." }
|
484
531
|
id_uc = SafeDb::Id.new
|
485
|
-
id_uc.
|
532
|
+
id_uc.flow()
|
486
533
|
end
|
487
534
|
|
488
535
|
|