safedb 0.4.1002 → 0.5.1001
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +35 -23
- data/README.md +69 -29
- data/lib/cli.rb +28 -22
- data/lib/controller/admin/access.rb +1 -1
- data/lib/controller/admin/commit.rb +53 -0
- data/lib/controller/admin/diff.rb +23 -25
- data/lib/controller/admin/export.rb +9 -11
- data/lib/controller/admin/goto.rb +2 -3
- data/lib/controller/admin/import.rb +5 -7
- data/lib/controller/admin/login.rb +16 -2
- data/lib/controller/admin/logout.rb +1 -1
- data/lib/controller/admin/open.rb +4 -5
- data/lib/controller/admin/refresh.rb +55 -0
- data/lib/controller/admin/token.rb +1 -1
- data/lib/controller/admin/use.rb +1 -1
- data/lib/controller/admin/view.rb +8 -10
- data/lib/controller/api/docker/docker.rb +1 -1
- data/lib/controller/api/jenkins/jenkins.rb +1 -1
- data/lib/controller/api/terraform/terraform.rb +7 -34
- data/lib/controller/api/vpn/vpn.rb +1 -1
- data/lib/controller/{usecase.rb → controller.rb} +15 -8
- data/lib/controller/edit/editverse.rb +2 -2
- data/lib/controller/id.rb +1 -1
- data/lib/controller/query/copy.rb +127 -0
- data/lib/controller/query/queryverse.rb +2 -2
- data/lib/controller/requirer.rb +1 -1
- data/lib/controller/set.rb +1 -1
- data/lib/controller/verse.rb +1 -1
- data/lib/controller/visit/visit.rb +1 -1
- data/lib/manual/copy-paste.md +13 -0
- data/lib/{controller/admin/tree.md → manual/dir-structure.md} +0 -0
- data/lib/manual/drag-drop.md +77 -0
- data/lib/manual/login-logout.md +46 -0
- data/lib/model/README.md +2 -2
- data/lib/model/book.rb +11 -6
- data/lib/model/indices.rb +1 -1
- data/lib/model/state.inspect.rb +67 -53
- data/lib/model/state.migrate.rb +19 -19
- data/lib/model/text_chunk.rb +35 -15
- data/lib/utils/clipboard/clip.rb +92 -0
- data/lib/utils/key.pass.rb +3 -1
- data/lib/version.rb +1 -1
- metadata +11 -7
- data/lib/controller/admin/checkin.rb +0 -83
- data/lib/controller/admin/checkout.rb +0 -57
- data/lib/modules/cryptology/collect.rb +0 -138
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 745b886e46c4ed9a32467c96411d6ae720778445be31a814d53f6dd2fedd80f1
|
4
|
+
data.tar.gz: 977cd56ed9ff4c5f2ee9f9a019eb6e92fc25715382bdb74f7fcde190b92a45b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ee47c8b27a1bb6a6b32736f2e2cfeb4577b4e3f247ca7f434a4ed76c2e21bfb812678dd36dc256821412da73edff505455fabe526c18d6b82d57056016af56f
|
7
|
+
data.tar.gz: 412b4638f8e58dd020630c56d9ba05772705ce0251d23d591e30c9ccd12b00e8c3826271b98c36779c54628b2d85aed8534c685a54b663899bc821811d214619
|
data/CONTRIBUTING.md
CHANGED
@@ -54,7 +54,7 @@ safedb is automatically released by Jenkins using a GitOps style pipeline define
|
|
54
54
|
- quality numbers passed by the Reek code quality analyzer
|
55
55
|
- available rubygems.org credentials in ~/.gem/credentials
|
56
56
|
|
57
|
-
##
|
57
|
+
## Release to RubyGems.org
|
58
58
|
|
59
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
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.
|
@@ -63,26 +63,26 @@ Now when releasing we eject the file back into **`~/.gem/credentials`**, secure
|
|
63
63
|
|
64
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
65
|
|
66
|
+
## Common Development Commands
|
66
67
|
|
68
|
+
These commands will be used frequently while developing the safe.
|
67
69
|
|
68
|
-
|
70
|
+
- `rake install`
|
71
|
+
- `cucumber`
|
72
|
+
- `git checkout -b feature.verb-noun`
|
73
|
+
- `git add; git commit;`
|
74
|
+
- `git cherry -v origin`
|
75
|
+
- `git cherry -v origin feature.verb-noun`
|
76
|
+
- `git push -u origin feature.verb-noun`
|
77
|
+
- `git pull origin master`
|
78
|
+
- `git pull origin feature.verb-noun`
|
69
79
|
|
70
|
-
|
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`
|
80
|
+
When ready to merge the feature development branch into master these commands will be used.
|
79
81
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
### `git merge feature.commit-branch`
|
85
|
-
### `git push -u origin master`
|
82
|
+
- `git checkout master`
|
83
|
+
- `git pull origin master`
|
84
|
+
- `git merge feature.verb-noun`
|
85
|
+
- `git push origin master`
|
86
86
|
|
87
87
|
|
88
88
|
## Branch Naming Convention
|
@@ -95,15 +95,15 @@ Branch names begin with either
|
|
95
95
|
|
96
96
|
Branch names are then typically a **verb-noun concatenation** like
|
97
97
|
|
98
|
-
- feature.
|
99
|
-
-
|
100
|
-
- refactor.
|
98
|
+
- feature.copy-paste
|
99
|
+
- bug.login-error
|
100
|
+
- refactor.cucumber-features
|
101
101
|
|
102
|
-
##
|
102
|
+
## git push to github.com/devops4me/safedb.net
|
103
103
|
|
104
104
|
Those with priveleges to release to safedb.net will have a private key to push pull requests into the repository.
|
105
105
|
|
106
|
-
|
106
|
+
Described here is setting up the **ssh config**, the **pem private key**, then cloning the repository with https, creating a branch, merging and finally pusing using **git ssh**.
|
107
107
|
|
108
108
|
```
|
109
109
|
safe login safe.ecosystem
|
@@ -114,9 +114,21 @@ safe eject safedb.code.private.key
|
|
114
114
|
chmod 600 safedb.code.private.key
|
115
115
|
cd <<repositories-folder>>
|
116
116
|
ssh -i ~/.ssh/safedb.code.private.key.pem -vT git@safedb.code
|
117
|
-
git clone
|
117
|
+
git clone https://github.com/devops4me/safedb.net safedb.net
|
118
|
+
git remote set-url --push origin git@safedb.code:devops4me/safedb.net.git
|
118
119
|
```
|
119
120
|
|
120
121
|
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.
|
121
122
|
|
123
|
+
## Continuous Integration using Jenkins 2.0 Docker Pipeline
|
124
|
+
|
125
|
+
safedb.net has Dockerfiles through which the Cucumber/Aruba BDD (behaviour driven development) tests are run within
|
126
|
+
|
127
|
+
- **Ubuntu 16.04 and 18.04**
|
128
|
+
- Raspbian
|
129
|
+
- **RedHat Enterprise Linux (RHEL)**
|
130
|
+
- CoreOS containers
|
131
|
+
|
132
|
+
### CI/CD Pipeline from Git to RubyGems.org
|
122
133
|
|
134
|
+
The Jenkinsfile template used is in the RubyGem category so succesful builds, quality inspection and tests result in a new version of the software being released to RubyGems.org
|
data/README.md
CHANGED
@@ -503,41 +503,81 @@ Again you can configure 1 to 32 which guarantees that the generated password seq
|
|
503
503
|
|
504
504
|
There are 62 alpha-numerics which is the starting point and smallest source pool of usable choosable characters for a printable character sequence.
|
505
505
|
|
506
|
+
|
507
|
+
## Password Strength vs Password Length
|
508
|
+
|
509
|
+
Strength indicates the number of possible printable characters to choose from whilst median length indicates the approximate size of the generated secret. Both strengths and lengths run from 1 to 32. The defaults are
|
510
|
+
|
511
|
+
- a weighted strength of 12 (a bucket of 70 characters)
|
512
|
+
- a weighted length of 12 (a median length of 22 characters)
|
513
|
+
|
514
|
+
## Including and Excluding Characters
|
515
|
+
|
516
|
+
The stated strength indicates the characters that can appear in the password. This can be configured to
|
517
|
+
|
518
|
+
- <tt>exclude</tt> characters inside of the stated strength
|
519
|
+
- <tt>include</tt> characters outside of the stated strength
|
520
|
+
|
521
|
+
```
|
522
|
+
safe secret # generate with default strength and length
|
523
|
+
safe secret --length=4 # generate secret between 10 and 16 characters
|
524
|
+
safe secret --strength=6 # include alpha-numerics, underscore, period and hyphens
|
525
|
+
```
|
526
|
+
|
527
|
+
To adjust the secret's character bucket we can include and exclude characters.
|
528
|
+
|
529
|
+
```
|
530
|
+
safe secret --length 16 --strength 12 --include ampersand,dollar --exclude hat,period
|
531
|
+
safe secret -l=16 -s=12 -i=ampersand,dollar -e=hat,period
|
532
|
+
```
|
533
|
+
|
534
|
+
## Config Levels Reminder
|
535
|
+
|
536
|
+
If you open a verse and then use set to add configuraion, the config scope will cover just that verse. You can move to chapter and/or to book level.
|
537
|
+
|
538
|
+
Configuration can be
|
539
|
+
|
540
|
+
- command scoped (in command options)
|
541
|
+
- session scoped (in session indices or environment variables)
|
542
|
+
- book, chapter or verse scoped ( in book indices)
|
543
|
+
- database scoped (within master indices)
|
544
|
+
|
545
|
+
|
506
546
|
- ---------------------- | -------------------- - --------- -
|
507
|
-
| Password
|
547
|
+
| Password Strength | # | Char Name | Character |
|
508
548
|
| ---------------------- | -----| ------------- | --------- |
|
509
|
-
| 1 |
|
549
|
+
| 1 | 26 | lowercase | a-z |
|
550
|
+
| 1 | 36 | digits | 0-9 |
|
551
|
+
| 1 | 62 | uppercase | A-Z |
|
510
552
|
| 2 | 63 | underscore | _ |
|
511
553
|
| 3 | 64 | period | . |
|
512
554
|
| 4 | 65 | hyphen | - |
|
513
|
-
| 5 | 66 | at
|
555
|
+
| 5 | 66 | at | @ |
|
514
556
|
| 6 | 67 | squiggle | ~ |
|
515
|
-
| 7 | 68 |
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
| 13 | 74 | hat
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
| 31 | 92 | dollar sign | $ |
|
540
|
-
| 32 | 93 | back tick | ` |
|
557
|
+
| 7 | 68 | plus | + |
|
558
|
+
| 26 | 87 | comma | , |
|
559
|
+
| 24 | 85 | colon | : |
|
560
|
+
| 25 | 86 | semicolon | ; |
|
561
|
+
| 8 | 69 | percent | % |
|
562
|
+
| 9 | 70 | equals | = |
|
563
|
+
| 13 | 74 | hat | ^ |
|
564
|
+
| 10 | 71 | pipe | | |
|
565
|
+
| 12 | 73 | fwdslash | / |
|
566
|
+
| 14 | 75 | softopen | ( |
|
567
|
+
| 15 | 76 | softclose | ) |
|
568
|
+
| 16 | 77 | squareopen | [ |
|
569
|
+
| 17 | 78 | squareclose | ] |
|
570
|
+
| 18 | 79 | curlyopen | { |
|
571
|
+
| 19 | 80 | curlyclose | } |
|
572
|
+
| 20 | 81 | angleopen | < |
|
573
|
+
| 21 | 82 | angleclose | > |
|
574
|
+
| 22 | 83 | hash | # |
|
575
|
+
| 23 | 84 | question | ? |
|
576
|
+
| 27 | 88 | asterix | * |
|
577
|
+
| 28 | 89 | ampersand | & |
|
578
|
+
| 29 | 90 | exclamation | ! |
|
579
|
+
| 30 | 91 | dollar | $ |
|
580
|
+
| 31 | 92 | backtick | ` |
|
541
581
|
| ---------------------- | -----| ------------- | --------- |
|
542
582
|
|
543
583
|
Use the full set of **93 printable characters** when protecting high value assets like databases.
|
data/lib/cli.rb
CHANGED
@@ -109,13 +109,19 @@ class CLI < Thor
|
|
109
109
|
# inaccessible or the call originates from non-interactive software.
|
110
110
|
option :password, :aliases => '-p'
|
111
111
|
|
112
|
+
# The <tt>--clip</tt> option says the password is to be read from the
|
113
|
+
# clipboard. Usually one needs to just highlight the text without
|
114
|
+
# actually copying it with the mouse or Ctrl-c
|
115
|
+
################ method_option :clip, :type => :boolean, :aliases => "-c"
|
116
|
+
|
112
117
|
# Login in order to securely interact with your safe credentials.
|
113
118
|
# @param book_name [String] the name of the credentials book to login to
|
114
119
|
def login( book_name = nil )
|
115
|
-
log.info(x) { "login to the safe
|
120
|
+
log.info(x) { "login attempt to the safe book called [#{book_name}]." }
|
116
121
|
login_uc = SafeDb::Login.new
|
117
122
|
login_uc.book_name = book_name unless book_name.nil?
|
118
123
|
login_uc.password = options[ :password ] if options[ :password ]
|
124
|
+
################### login_uc.clip = true if options[ :clip ]
|
119
125
|
login_uc.flow()
|
120
126
|
end
|
121
127
|
|
@@ -198,19 +204,19 @@ class CLI < Thor
|
|
198
204
|
|
199
205
|
|
200
206
|
# Description of the diff use case command from the point of view
|
201
|
-
# of either a
|
207
|
+
# of either a refresh from master to branch, a commit from branch
|
202
208
|
# to master or a diff listing prophesying about both.
|
203
|
-
desc "diff", "master and branch diff with --
|
209
|
+
desc "diff", "master and branch diff with --commit (-i), --refresh (-o) or both."
|
204
210
|
|
205
|
-
# A
|
206
|
-
# like the merging
|
211
|
+
# A commit is basically a copy-overwrite operation which does not finesse
|
212
|
+
# like the merging refresh does. The diff report illustrates that the master
|
207
213
|
# will essentially reflect the working branch's current state.
|
208
|
-
method_option :
|
214
|
+
method_option :commit, :type => :boolean, :aliases => "-c"
|
209
215
|
|
210
|
-
# A
|
211
|
-
# structure into the working branch. With
|
216
|
+
# A refresh is effectively an incoming merge of the master's data
|
217
|
+
# structure into the working branch. With refreshs nothing ever gets
|
212
218
|
# deleted.
|
213
|
-
method_option :
|
219
|
+
method_option :refresh, :type => :boolean, :aliases => "-r"
|
214
220
|
|
215
221
|
# The <b>diff use case</b> spells out the key differences between the safe book
|
216
222
|
# on the master line the one on the current working branch.
|
@@ -218,37 +224,37 @@ class CLI < Thor
|
|
218
224
|
# By default when conflicts occur, priority is given to the current working branch.
|
219
225
|
# No parameters are required to perform a diff.
|
220
226
|
def diff
|
221
|
-
log.info(x) { "prophesy list of
|
227
|
+
log.info(x) { "prophesy list of refresh and/or commit actions. CLI options are #{options.to_s()}" }
|
222
228
|
diff_uc = SafeDb::Diff.new()
|
223
|
-
diff_uc.
|
224
|
-
diff_uc.
|
229
|
+
diff_uc.commit = true if options[ :commit ]
|
230
|
+
diff_uc.refresh = true if options[ :refresh ]
|
225
231
|
diff_uc.flow()
|
226
232
|
end
|
227
233
|
|
228
234
|
|
229
235
|
|
230
|
-
# Description of the
|
231
|
-
desc "
|
236
|
+
# Description of the commit use case command.
|
237
|
+
desc "commit", "commit (save) the branch changes by putting them into master."
|
232
238
|
|
233
|
-
# The <b>
|
239
|
+
# The <b>commit use case</b> commits any changes made to the safe book into
|
234
240
|
# master. This is straightforward if the master's state has not been forwarded
|
235
241
|
# by a ckeckin from another (shell) branch.
|
236
|
-
def
|
242
|
+
def commit
|
237
243
|
log.info(x) { "commit (save) any changes made to this branch into the master." }
|
238
|
-
SafeDb::
|
244
|
+
SafeDb::Commit.new.flow()
|
239
245
|
end
|
240
246
|
|
241
247
|
|
242
248
|
|
243
|
-
# Description of the
|
244
|
-
desc "
|
249
|
+
# Description of the refresh use case command.
|
250
|
+
desc "refresh", "refresh (update) the working branch with changes from the master."
|
245
251
|
|
246
|
-
# The <b>
|
252
|
+
# The <b>refresh use case</b> commits any changes made to the safe book into
|
247
253
|
# master. This is straightforward if the master's state has not been forwarded
|
248
254
|
# by a ckeckin from another (shell) branch.
|
249
|
-
def
|
255
|
+
def refresh
|
250
256
|
log.info(x) { "refresh (update) the working branch with changes from the master." }
|
251
|
-
SafeDb::
|
257
|
+
SafeDb::Refresh.new.flow()
|
252
258
|
end
|
253
259
|
|
254
260
|
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
module SafeDb
|
4
|
+
|
5
|
+
# The <b>commit use case</b> commits any changes made to the safe book into
|
6
|
+
# master. This is straightforward if the master's state has not been forwarded
|
7
|
+
# by a ckeckin from another (shell) branch.
|
8
|
+
#
|
9
|
+
# The mechanics of a simple in-sync commit is to
|
10
|
+
#
|
11
|
+
# - sync the master crypts to exactly mimic the branch crypts
|
12
|
+
# - tell master the content id of the book index file
|
13
|
+
# - tell master what the current random iv (initialization vector) is
|
14
|
+
# - create a new commit ID and set it on both master and branch
|
15
|
+
# - set the master's last updated date and time
|
16
|
+
#
|
17
|
+
class Commit < Controller
|
18
|
+
|
19
|
+
|
20
|
+
# The <b>commit use case</b> commits any changes made to the safe book into
|
21
|
+
# master. This is straightforward if the master's state has not been forwarded
|
22
|
+
# by a ckeckin from another (shell) branch.
|
23
|
+
def execute
|
24
|
+
|
25
|
+
@book.print_book_mark()
|
26
|
+
|
27
|
+
unless @book.can_commit?()
|
28
|
+
|
29
|
+
puts "Cannot commit as master has moved forward."
|
30
|
+
puts "First see the difference, then refresh, and then commit."
|
31
|
+
puts ""
|
32
|
+
puts " safe diff"
|
33
|
+
puts " safe refresh"
|
34
|
+
puts " safe commit"
|
35
|
+
puts ""
|
36
|
+
return
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
StateMigrate.commit( @book )
|
41
|
+
|
42
|
+
puts "The commit was on #{KeyNow.readable()}\n"
|
43
|
+
puts "Commit from branch to master was successful.\n"
|
44
|
+
puts ""
|
45
|
+
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
end
|
@@ -4,12 +4,12 @@ module SafeDb
|
|
4
4
|
|
5
5
|
# The <b>diff use case</b> spells out the key differences between the safe book
|
6
6
|
# on the master line the one on the current working branch. There are two types
|
7
|
-
# of diff - a
|
7
|
+
# of diff - a refresh diff or a commit diff.
|
8
8
|
#
|
9
|
-
# == a
|
9
|
+
# == a refresh diff
|
10
10
|
#
|
11
|
-
# A
|
12
|
-
# structure into the working branch. With
|
11
|
+
# A refresh is effectively an incoming merge of the master's data
|
12
|
+
# structure into the working branch. With refreshs nothing ever gets
|
13
13
|
# deleted.
|
14
14
|
#
|
15
15
|
# No delete is self-evident in this list of only <tt>4 prophetic</tt>
|
@@ -20,50 +20,48 @@ module SafeDb
|
|
20
20
|
# - this line will be added
|
21
21
|
# - this branch's line value will be overwritten with the value from master
|
22
22
|
#
|
23
|
-
# == a
|
23
|
+
# == a commit diff
|
24
24
|
#
|
25
|
-
# A
|
25
|
+
# A refresh merges whilst a commit is effectively a hard copy that destroys
|
26
26
|
# whatever is on the master making it exactly reflect the branch's current state.
|
27
27
|
#
|
28
|
-
# The three addition state changes prophesized by a
|
29
|
-
#
|
28
|
+
# The three addition state changes prophesized by a refresh can also occur on
|
29
|
+
# commits. However commits can also prophesize that
|
30
30
|
#
|
31
31
|
# - this master's line value will be overwritten with the branch's value
|
32
32
|
# - this chapter will be removed
|
33
33
|
# - this verse will be removed
|
34
34
|
# - this line will be removed
|
35
35
|
#
|
36
|
-
class Diff <
|
36
|
+
class Diff < Controller
|
37
37
|
|
38
|
-
# The
|
39
|
-
attr_writer :
|
38
|
+
# The commit and refresh boolean flags that signal which way round to do the diff
|
39
|
+
attr_writer :commit, :refresh
|
40
40
|
|
41
41
|
# The <b>diff use case</b> compares the database state of the branch with
|
42
42
|
# that of the master and displays the results without masking sensitive
|
43
43
|
# credentials.
|
44
44
|
def execute
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
print_checkin = !@checkin.nil?() || print_both
|
50
|
-
print_checkout = !@checkout.nil?() || print_both
|
46
|
+
print_both = @commit.nil?() && @refresh.nil?()
|
47
|
+
print_commit = !@commit.nil?() || print_both
|
48
|
+
print_refresh = !@refresh.nil?() || print_both
|
51
49
|
|
52
50
|
puts ""
|
53
|
-
puts " == Birth Day := #{book.init_time()}\n"
|
54
|
-
puts " == Book Name := #{book.book_name()} [#{book.book_id}]\n"
|
55
|
-
puts " == Book Mark := #{book.get_open_chapter_name()}/#{book.get_open_verse_name()}\n" if book.is_opened?()
|
51
|
+
puts " == Birth Day := #{@book.init_time()}\n"
|
52
|
+
puts " == Book Name := #{@book.book_name()} [#{@book.book_id}]\n"
|
53
|
+
puts " == Book Mark := #{@book.get_open_chapter_name()}/#{@book.get_open_verse_name()}\n" if @book.is_opened?()
|
56
54
|
puts ""
|
57
55
|
|
58
|
-
master_data = book.to_master_data()
|
59
|
-
branch_data = book.to_branch_data()
|
56
|
+
master_data = @book.to_master_data()
|
57
|
+
branch_data = @book.to_branch_data()
|
60
58
|
|
61
|
-
StateInspect.
|
62
|
-
StateInspect.
|
59
|
+
StateInspect.refresh_prophecies( master_data, branch_data ) if print_refresh
|
60
|
+
StateInspect.commit_prophecies( master_data, branch_data ) if print_commit
|
63
61
|
|
64
62
|
puts ""
|
65
|
-
puts " master has #{master_data.length()} chapters, and #{book.get_master_verse_count()} verses.\n"
|
66
|
-
puts " branch has #{branch_data.length()} chapters, and #{book.get_branch_verse_count()} verses.\n"
|
63
|
+
puts " master has #{master_data.length()} chapters, and #{@book.get_master_verse_count()} verses.\n"
|
64
|
+
puts " branch has #{branch_data.length()} chapters, and #{@book.get_branch_verse_count()} verses.\n"
|
67
65
|
puts ""
|
68
66
|
|
69
67
|
end
|
@@ -8,30 +8,28 @@ module SafeDb
|
|
8
8
|
#
|
9
9
|
# The --print flag demands that the exported text goes to stdout otherwise it
|
10
10
|
# will be placed in an aptly named file in the present working directory.
|
11
|
-
class Export <
|
11
|
+
class Export < Controller
|
12
12
|
|
13
13
|
def execute
|
14
14
|
|
15
|
-
book = Book.new()
|
16
|
-
|
17
15
|
puts ""
|
18
16
|
puts "### #############################################################\n"
|
19
17
|
puts "--- --------------------------------------------------------------\n"
|
20
18
|
puts ""
|
21
|
-
puts " The Birthday := #{book.init_time()}\n"
|
22
|
-
puts " Book Name := #{book.book_name()}\n"
|
23
|
-
puts " Book Id := #{book.book_id()}\n"
|
24
|
-
puts " Open Chapter := #{book.get_open_chapter_name()}\n" if book.has_open_chapter_name?()
|
25
|
-
puts " Open Verse := #{book.get_open_verse_name()}\n" if book.has_open_verse_name?()
|
19
|
+
puts " The Birthday := #{@book.init_time()}\n"
|
20
|
+
puts " Book Name := #{@book.book_name()}\n"
|
21
|
+
puts " Book Id := #{@book.book_id()}\n"
|
22
|
+
puts " Open Chapter := #{@book.get_open_chapter_name()}\n" if @book.has_open_chapter_name?()
|
23
|
+
puts " Open Verse := #{@book.get_open_verse_name()}\n" if @book.has_open_verse_name?()
|
26
24
|
puts ""
|
27
25
|
|
28
|
-
export_filename = "safedb.#{KeyNow.yyjjj_hhmm_ss_nanosec()}.#{book.book_id()}.json"
|
26
|
+
export_filename = "safedb.#{KeyNow.yyjjj_hhmm_ss_nanosec()}.#{@book.book_id()}.json"
|
29
27
|
export_filepath = File.join( Dir.pwd, export_filename )
|
30
28
|
|
31
29
|
exported_struct = {}
|
32
30
|
verse_count = 0
|
33
31
|
|
34
|
-
book.branch_chapter_keys().each_pair do | chapter_name, chapter_keys |
|
32
|
+
@book.branch_chapter_keys().each_pair do | chapter_name, chapter_keys |
|
35
33
|
|
36
34
|
chapter_data = Content.unlock_branch_chapter( chapter_keys )
|
37
35
|
verse_count += chapter_data.length
|
@@ -42,7 +40,7 @@ module SafeDb
|
|
42
40
|
File.write( export_filepath, JSON.pretty_generate( exported_struct ) + "\n" )
|
43
41
|
|
44
42
|
puts ""
|
45
|
-
puts "Number of chapters exported >> #{book.chapter_count()}"
|
43
|
+
puts "Number of chapters exported >> #{@book.chapter_count()}"
|
46
44
|
puts "Number of verses exported >> #{verse_count}"
|
47
45
|
puts "The export filename is #{export_filename}"
|
48
46
|
puts "The Present Working Directory is #{Dir.pwd}"
|
@@ -12,7 +12,7 @@ module SafeDb
|
|
12
12
|
# Goto with the number effectively shortcuts the open pinpointer.
|
13
13
|
# Show prints out the verse lines at the opened path but masks any secrets.
|
14
14
|
# Tell also prints out the verse lines but unabashedly displays secrets.
|
15
|
-
class Goto <
|
15
|
+
class Goto < Controller
|
16
16
|
|
17
17
|
# The index (number) starting with 1 of the envelope and key-path
|
18
18
|
# combination that should be opened.
|
@@ -20,9 +20,8 @@ module SafeDb
|
|
20
20
|
|
21
21
|
def execute
|
22
22
|
|
23
|
-
book = Book.new()
|
24
23
|
goto_location = 0
|
25
|
-
book.branch_chapter_keys().each_pair do | chapter_name, chapter_keys |
|
24
|
+
@book.branch_chapter_keys().each_pair do | chapter_name, chapter_keys |
|
26
25
|
|
27
26
|
chapter_data = Content.unlock_branch_chapter( chapter_keys )
|
28
27
|
chapter_data.each_key do | verse_name |
|
@@ -7,7 +7,7 @@ module SafeDb
|
|
7
7
|
# chapter of the source JSON structure into the corresponding chapter of
|
8
8
|
# the destination, handling duplicate key/value pairs in a sensible way.
|
9
9
|
#
|
10
|
-
class Import <
|
10
|
+
class Import < Controller
|
11
11
|
|
12
12
|
attr_writer :import_filepath
|
13
13
|
|
@@ -17,16 +17,14 @@ module SafeDb
|
|
17
17
|
# the destination, handling duplicate key/value pairs in a sensible way.
|
18
18
|
def execute
|
19
19
|
|
20
|
-
book = Book.new()
|
21
|
-
|
22
20
|
abort "Cannot find the import file at path #{@import_filepath}" unless File.exists?( @import_filepath )
|
23
21
|
|
24
22
|
puts ""
|
25
23
|
puts "### #############################################################\n"
|
26
24
|
puts "--- -------------------------------------------------------------\n"
|
27
25
|
puts ""
|
28
|
-
puts " Book Name := #{book.book_name()}\n"
|
29
|
-
puts " Book Id := #{book.book_id()}\n"
|
26
|
+
puts " Book Name := #{@book.book_name()}\n"
|
27
|
+
puts " Book Id := #{@book.book_id()}\n"
|
30
28
|
puts " Import from := #{@import_filepath}\n"
|
31
29
|
puts " Import time := #{KeyNow.readable()}\n"
|
32
30
|
puts ""
|
@@ -34,11 +32,11 @@ module SafeDb
|
|
34
32
|
new_verse_count = 0
|
35
33
|
data_store = DataStore.from_json( File.read( @import_filepath ) )
|
36
34
|
data_store.each_pair do | chapter_name, chapter_data |
|
37
|
-
book.import_chapter( chapter_name, chapter_data )
|
35
|
+
@book.import_chapter( chapter_name, chapter_data )
|
38
36
|
new_verse_count += chapter_data.length()
|
39
37
|
end
|
40
38
|
|
41
|
-
book.write()
|
39
|
+
@book.write()
|
42
40
|
|
43
41
|
puts ""
|
44
42
|
puts "#{data_store.length()} chapters and #{new_verse_count} verses were successfully imported.\n"
|
@@ -15,8 +15,21 @@ module SafeDb
|
|
15
15
|
# - you can call it with a --with=password switch
|
16
16
|
# - a space before the command prevents it being logged in .bash_history
|
17
17
|
# - you can deliver the password in multiple ways
|
18
|
+
|
19
|
+
# - an environment variable
|
20
|
+
# - the system clipboard (cleared after reading)
|
21
|
+
# - a file whose path is a command parameter
|
22
|
+
# - a file in a pre-agreed location
|
23
|
+
# - a file in the present directory (with a pre-agreed name)
|
24
|
+
# - a URL from a parameter or pre-agreed
|
25
|
+
# - the shell's secure password reader
|
18
26
|
class Login < AccessUc
|
19
27
|
|
28
|
+
# If the clip switch is present it signifies that the password should
|
29
|
+
# be read in from the clipboard. Any text selection puts text into the
|
30
|
+
# the clipboard - no need specifically to use Ctrl-c (copy).
|
31
|
+
attr_writer :clip
|
32
|
+
|
20
33
|
def execute
|
21
34
|
|
22
35
|
# @todo => in parent class Auth validate the book name
|
@@ -36,8 +49,9 @@ module SafeDb
|
|
36
49
|
|
37
50
|
# @todo => search for password in environment variable
|
38
51
|
|
39
|
-
book_password =
|
40
|
-
book_password = @password
|
52
|
+
#### book_password = Clipboard.read_password() if @clip
|
53
|
+
book_password = KeyPass.password_from_shell( false ) if( @password.nil?() && @clip.nil?() )
|
54
|
+
book_password = @password unless @password.nil?()
|
41
55
|
|
42
56
|
# @todo => if password is correct - if not print out an error.
|
43
57
|
|
@@ -12,17 +12,16 @@ module SafeDb
|
|
12
12
|
# exists you use the <tt>safe reopen</tt> command. This command produces an error
|
13
13
|
# if it cannot find specified chapter and verse.
|
14
14
|
#
|
15
|
-
class Open <
|
15
|
+
class Open < Controller
|
16
16
|
|
17
17
|
# The chapter and verse of this book that are to be opened.
|
18
18
|
attr_writer :chapter, :verse
|
19
19
|
|
20
20
|
def execute
|
21
21
|
|
22
|
-
book
|
23
|
-
book.
|
24
|
-
book.
|
25
|
-
book.write()
|
22
|
+
@book.set_open_chapter_name( @chapter )
|
23
|
+
@book.set_open_verse_name( @verse )
|
24
|
+
@book.write()
|
26
25
|
|
27
26
|
# Show the mini dictionary at the opened chapter and verse location
|
28
27
|
# More work is needed when for when only the chapter is opened in
|