safedb 0.5.1005 → 0.7.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 +1 -1
- data/genius-decision.txt +25 -0
- data/lib/cli.rb +155 -8
- data/lib/controller/{admin/auth.rb → abstract/authenticate.rb} +1 -2
- data/lib/controller/{controller.rb → abstract/controller.rb} +45 -24
- data/lib/controller/{edit/editverse.rb → abstract/edit_verse.rb} +0 -0
- data/lib/controller/{query/queryverse.rb → abstract/query_verse.rb} +0 -0
- data/lib/controller/{admin → access}/README.md +0 -0
- data/lib/controller/access/banner.txt +6 -0
- data/lib/controller/{admin → access}/init.rb +4 -4
- data/lib/controller/{admin → access}/login.rb +28 -23
- data/lib/controller/{admin → access}/logout.rb +0 -0
- data/lib/controller/{admin → access}/token.rb +0 -0
- data/lib/controller/{admin → access}/use.rb +0 -0
- data/lib/controller/api/docker/docker.rb +4 -22
- data/lib/controller/api/git/git.rb +104 -0
- data/lib/controller/api/terraform/README.md +23 -2
- data/lib/controller/api/terraform/terraform.rb +38 -7
- data/lib/controller/{admin → book}/commit.rb +2 -3
- data/lib/controller/{admin → book}/diff.rb +0 -0
- data/lib/controller/{admin → book}/export.rb +0 -0
- data/lib/controller/{admin → book}/import.rb +0 -0
- data/lib/controller/{admin → book}/refresh.rb +2 -2
- data/lib/controller/{admin → book}/view.rb +0 -0
- data/lib/{modules/storage/git.store.rb → controller/db/model_git_service.rb} +0 -0
- data/lib/controller/db/pull.rb +69 -0
- data/lib/controller/db/push.rb +352 -0
- data/lib/controller/db/remote.rb +108 -0
- data/lib/controller/edit/generate.rb +1 -1
- data/lib/controller/edit/keys.rb +72 -0
- data/lib/controller/edit/paste.rb +36 -0
- data/lib/controller/files/write.rb +11 -3
- data/lib/controller/misc/wipe.rb +23 -0
- data/lib/controller/navigate/at.rb +42 -0
- data/lib/controller/{admin → navigate}/goto.rb +0 -0
- data/lib/controller/{admin → navigate}/open.rb +0 -0
- data/lib/controller/query/copy.rb +32 -95
- data/lib/controller/query/tell.rb +36 -0
- data/lib/controller/requirer.rb +4 -4
- data/lib/controller/visit/README.md +34 -0
- data/lib/controller/visit/visit.rb +33 -0
- data/lib/manual/copy-paste.md +19 -2
- data/lib/{modules/README.md → manual/crypto-math.md} +0 -0
- data/lib/manual/push-pull.md +46 -0
- data/lib/manual/remote.md +62 -0
- data/lib/model/coordinates.rb +59 -0
- data/lib/model/{safe_tree.rb → file_tree.rb} +11 -6
- data/lib/model/indices.rb +113 -8
- data/lib/model/master.rb +40 -0
- data/lib/model/{state.migrate.rb → state_evolve.rb} +13 -5
- data/lib/model/{state.inspect.rb → state_query.rb} +5 -1
- data/lib/plugin/github.rb +53 -0
- data/lib/{modules/cryptology → utils/ciphers}/aes-256.rb +0 -0
- data/lib/{modules/cryptology → utils/ciphers}/blowfish.rb +0 -0
- data/lib/{modules/cryptology → utils/ciphers}/cipher.rb +0 -0
- data/lib/{modules/cryptology → utils/ciphers}/crypt.io.rb +0 -0
- data/lib/utils/keys/key.rb +44 -0
- data/lib/utils/keys/keypair.rb +52 -0
- data/lib/utils/logs/logger.rb +1 -1
- data/lib/utils/store/datastore.rb +1 -1
- data/lib/utils/store/github.rb +27 -0
- data/lib/utils/time/timestamp.rb +91 -0
- data/lib/version.rb +1 -1
- data/safedb.gemspec +2 -0
- metadata +75 -32
- data/lib/controller/verse.rb +0 -20
- data/lib/modules/storage/coldstore.rb +0 -186
- data/lib/utils/store/test-commands.sh +0 -24
@@ -0,0 +1,108 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
module SafeDb
|
4
|
+
|
5
|
+
# We want to provision (create) the safe's remote (github) backend.
|
6
|
+
#
|
7
|
+
# A number of setup tasks are executed when you ask that the backend repository be created.
|
8
|
+
#
|
9
|
+
# - a repository is created in github
|
10
|
+
# - the git fetch (https) and git push (ssh) urls are fabricated
|
11
|
+
# - the fetch url is written into the master keys file
|
12
|
+
# - the push url is written to the configured chapter/verse location
|
13
|
+
# - a ssh public/private keypair (using EC25519) is created
|
14
|
+
# - the private and public keys are placed within the chapter/verse
|
15
|
+
# - the public (deploy) key is registered with the github repository
|
16
|
+
#
|
17
|
+
class Remote < EditVerse
|
18
|
+
|
19
|
+
attr_writer :provision
|
20
|
+
|
21
|
+
# We want to provision (create) the safe's remote (github) backend.
|
22
|
+
# A number of setup tasks are executed when you ask that the backend repository be created.
|
23
|
+
def edit_verse()
|
24
|
+
|
25
|
+
return unless @provision
|
26
|
+
|
27
|
+
github_access_token = @verse[ Indices::GITHUB_ACCESS_TOKEN ]
|
28
|
+
return unless is_github_access_token_valid( github_access_token )
|
29
|
+
|
30
|
+
repository_name = "safedb-crypts-#{TimeStamp.yyjjj_hhmm_sst()}"
|
31
|
+
@verse.store( Indices::GIT_REPOSITORY_NAME_KEYNAME, repository_name )
|
32
|
+
private_key_simple_filename = "safe.#{@book.get_open_chapter_name()}.#{@book.get_open_verse_name()}.#{TimeStamp.yyjjj_hhmm_sst()}"
|
33
|
+
@verse.store( Indices::REMOTE_PRIVATE_KEY_KEYNAME, "#{private_key_simple_filename}.pem" )
|
34
|
+
@verse.store( Indices::REMOTE_MIRROR_SSH_HOST_KEYNAME, "safe-#{TimeStamp.yyjjjhhmmsst()}" )
|
35
|
+
|
36
|
+
remote_mirror_page = "#{@book.book_id()}/#{@book.get_open_chapter_name()}/#{@book.get_open_verse_name()}"
|
37
|
+
Master.new().set_backend_coordinates( remote_mirror_page )
|
38
|
+
|
39
|
+
key_creator = Keys.new()
|
40
|
+
key_creator.set_verse( @verse )
|
41
|
+
key_creator.keyfile_name = private_key_simple_filename
|
42
|
+
key_creator.edit_verse()
|
43
|
+
repo_public_key = @verse[ Indices::PUBLIC_KEY_DEFAULT_KEY_NAME ]
|
44
|
+
|
45
|
+
# @todo - refactor into GitHub integration class
|
46
|
+
# @todo - refactor into GitHub integration class
|
47
|
+
# @todo - refactor into GitHub integration class
|
48
|
+
# @todo - refactor into GitHub integration class
|
49
|
+
# @todo - refactor into GitHub integration class
|
50
|
+
# @todo - refactor into GitHub integration class
|
51
|
+
# @todo - refactor into GitHub integration class
|
52
|
+
|
53
|
+
require "etc"
|
54
|
+
require "socket"
|
55
|
+
require "octokit"
|
56
|
+
|
57
|
+
github_client = Octokit::Client.new( :access_token => github_access_token )
|
58
|
+
github_user = github_client.user
|
59
|
+
repo_creator = "#{Etc.getlogin()}@#{Socket.gethostname()}"
|
60
|
+
repo_description = "This github repository was auto-created by safedb.net to be a remote database backend on behalf of #{repo_creator} on #{TimeStamp.readable()}."
|
61
|
+
repo_homepage = "https://github.com/devops4me/safedb.net/"
|
62
|
+
repository_id = "#{github_user[:login]}/#{repository_name}"
|
63
|
+
@verse.store( Indices::GIT_REPOSITORY_USER_KEYNAME, github_user[:login] )
|
64
|
+
|
65
|
+
puts ""
|
66
|
+
puts "Repository Name => #{repository_id}"
|
67
|
+
puts "Github Company => #{github_user[:company]}"
|
68
|
+
puts "Account Owner => #{github_user[:name]}"
|
69
|
+
puts "Github User ID => #{github_user[:id]}"
|
70
|
+
puts "Github Username => #{github_user[:login]}"
|
71
|
+
puts "SSH Public Key => #{repo_public_key[0..40]}..."
|
72
|
+
|
73
|
+
puts "Creation Entity => #{repo_creator}"
|
74
|
+
puts "Repo Descriptor => #{repo_description}"
|
75
|
+
puts "Repo Homepage => #{repo_homepage}"
|
76
|
+
puts ""
|
77
|
+
|
78
|
+
options_hash = {
|
79
|
+
:description => repo_description,
|
80
|
+
:repo_homepage => repo_homepage,
|
81
|
+
:private => false,
|
82
|
+
:has_issues => false,
|
83
|
+
:has_wiki => false,
|
84
|
+
:has_downloads => false,
|
85
|
+
:auto_init => true
|
86
|
+
}
|
87
|
+
|
88
|
+
github_client.create_repository( repository_name, options_hash )
|
89
|
+
github_client.add_deploy_key( repository_id, "your safe crypts deployment key with ID #{TimeStamp.yyjjj_hhmm_sst()}", repo_public_key )
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
def is_github_access_token_valid( github_access_token )
|
95
|
+
|
96
|
+
is_invalid = github_access_token.nil?() || github_access_token.strip().length() < GITHUB_TOKEN_MIN_LENGTH
|
97
|
+
puts "No valid github access token found." if is_invalid
|
98
|
+
return !is_invalid
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
GITHUB_TOKEN_MIN_LENGTH = 7
|
103
|
+
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
end
|
@@ -31,7 +31,7 @@ module SafeDb
|
|
31
31
|
# that can be produced by this class. The lower bound is the median
|
32
32
|
# length less give or take, the upper bound is the median length
|
33
33
|
# plus the give or take size.
|
34
|
-
LENGTH_RANGE = (MEDIAN_LENGTH - GIVE_OR_TAKE_SIZE) .. ( MEDIAN_LENGTH + GIVE_OR_TAKE_SIZE)
|
34
|
+
LENGTH_RANGE = (MEDIAN_LENGTH - GIVE_OR_TAKE_SIZE) .. ( MEDIAN_LENGTH + GIVE_OR_TAKE_SIZE )
|
35
35
|
|
36
36
|
# The super strong non alpha-numeric character set has a large
|
37
37
|
# set of characters configured for the most secure credentials
|
@@ -0,0 +1,72 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
module SafeDb
|
4
|
+
|
5
|
+
# The default action of the <b>keys use case</b> is to create a private and
|
6
|
+
# public keypair and store them within the open chapter and verse.
|
7
|
+
#
|
8
|
+
# The optional keypair name parameter (if given) is used as a prefix to compose
|
9
|
+
# the private and public key keynames. The prefix and descriptors will be period
|
10
|
+
# separated.
|
11
|
+
#
|
12
|
+
# Currently the only algorithm used is the super secure EC (eliptic curve)
|
13
|
+
# with 384 bits.
|
14
|
+
#
|
15
|
+
# == Generating Public Key for Unit Test
|
16
|
+
#
|
17
|
+
# To validate public key generation for SSH we can use the below command that
|
18
|
+
# points to an on-disk private key file. The -y flag produces the magic.
|
19
|
+
#
|
20
|
+
# ssh-keygen -f /path/to/private/key.pem -y
|
21
|
+
#
|
22
|
+
class Keys < EditVerse
|
23
|
+
|
24
|
+
|
25
|
+
# To insert MORE THAN ONE KEY in the same verse you send the keypair_name.
|
26
|
+
# The keypair name fashions the key name of the embodied private key file.
|
27
|
+
# Omit it and it will be simply set to "private.key".
|
28
|
+
attr_writer :keypair_name
|
29
|
+
|
30
|
+
# Set the keyfile_name to fashion the name of the private key file that will
|
31
|
+
# be ejected (in the future) into the `~/.ssh` folder. Omit it and the filename
|
32
|
+
# will be formatted with the book, chapter and verse name followed by a .pem
|
33
|
+
attr_writer :keyfile_name
|
34
|
+
|
35
|
+
|
36
|
+
# The <b>keypair use case</b> creates a private and public keypair and stores
|
37
|
+
# them within the open chapter and verse.
|
38
|
+
def edit_verse()
|
39
|
+
|
40
|
+
keypair = Keypair.new()
|
41
|
+
|
42
|
+
keyname_postfix = "" unless @keypair_name
|
43
|
+
keyname_postfix = ".#{@keypair_name}" if @keypair_name
|
44
|
+
bcv_name = "#{@book.book_name()}.#{@book.get_open_chapter_name()}.#{@book.get_open_verse_name()}#{keyname_postfix}"
|
45
|
+
filename_prefix = bcv_name unless @keyfile_name
|
46
|
+
filename_prefix = @keyfile_name if @keyfile_name
|
47
|
+
|
48
|
+
private_key_filename = "#{filename_prefix}.pem"
|
49
|
+
private_key_keyname = "#{Indices::PRIVATE_KEY_DEFAULT_KEY_NAME}#{keyname_postfix}"
|
50
|
+
public_key_keyname = "#{Indices::PUBLIC_KEY_DEFAULT_KEY_NAME}#{keyname_postfix}"
|
51
|
+
|
52
|
+
file_content64 = Base64.urlsafe_encode64( keypair.private_key_pem() )
|
53
|
+
|
54
|
+
log.info(x) { "Keypair prefix => #{@keypair_name}" } if @keypair_name
|
55
|
+
log.info(x) { "The keypair fully qualified name => [ #{private_key_filename} ]" }
|
56
|
+
log.info(x) { "Keynames are [ #{private_key_keyname} ] and [ #{public_key_keyname} ]" }
|
57
|
+
|
58
|
+
filedata_map = {}
|
59
|
+
filedata_map.store( Indices::INGESTED_FILE_BASE_NAME_KEY, private_key_filename )
|
60
|
+
filedata_map.store( Indices::INGESTED_FILE_CONTENT64_KEY, file_content64 )
|
61
|
+
filedata_map.store( Indices::FILE_CHMOD_PERMISSIONS_KEY, "0600" )
|
62
|
+
|
63
|
+
@verse.store( Indices::INGESTED_FILE_LINE_NAME_KEY + private_key_keyname, filedata_map )
|
64
|
+
@verse.store( public_key_keyname, keypair.public_key_ssh() )
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
module SafeDb
|
4
|
+
|
5
|
+
# Paste the current clipboard or selection text into the specified line
|
6
|
+
# at the current book's open chapter and verse.
|
7
|
+
#
|
8
|
+
# Sensitive values now neither need to be put on the commnad line (safe put)
|
9
|
+
# or inputted perhaps with a typo when using (safe input).
|
10
|
+
#
|
11
|
+
# Use <b>safe wipe</b> to wipe (overwrite) any sensitive values that has
|
12
|
+
# been placed on the clipboard.
|
13
|
+
class Paste < EditVerse
|
14
|
+
|
15
|
+
# this entity can point to a book, chapter, verse or line. If no
|
16
|
+
# parameter entity is provided, the --all switch must be present
|
17
|
+
# to avoid an error message.
|
18
|
+
attr_writer :line
|
19
|
+
|
20
|
+
# The paste use case places a string from the clipboard into the
|
21
|
+
# specified line (@password is the default if no line name is specified).
|
22
|
+
def edit_verse()
|
23
|
+
|
24
|
+
@line = "@password" if @line.nil?
|
25
|
+
@verse.store( "#{@line}-#{TimeStamp.yyjjj_hhmm_sst()}", @verse[ @line ] ) if @verse.has_key?( @line )
|
26
|
+
|
27
|
+
clipboard_text = Clipboard.read_line()
|
28
|
+
@verse.store( @line, clipboard_text )
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
end
|
@@ -19,8 +19,6 @@ module SafeDb
|
|
19
19
|
|
20
20
|
bcv_name = "#{@book.book_name()}/#{@book.get_open_chapter_name()}/#{@book.get_open_verse_name()}"
|
21
21
|
|
22
|
-
puts ""
|
23
|
-
puts "book/chapter/verse\n"
|
24
22
|
puts "#{bcv_name} (#{@verse.length()})\n"
|
25
23
|
|
26
24
|
base64_content = @verse[ Indices::INGESTED_FILE_LINE_NAME_KEY + @file_key ][ Indices::INGESTED_FILE_CONTENT64_KEY ]
|
@@ -45,7 +43,17 @@ module SafeDb
|
|
45
43
|
puts "Written File Key = #{@file_key}"
|
46
44
|
puts ""
|
47
45
|
puts "File successfully written from safe to filesystem."
|
48
|
-
|
46
|
+
|
47
|
+
# @todo - if the permissions key is found then change them please
|
48
|
+
# @todo - if the permissions key is found then change them please
|
49
|
+
# @todo - if the permissions key is found then change them please
|
50
|
+
# @todo - if the permissions key is found then change them please
|
51
|
+
|
52
|
+
=begin
|
53
|
+
FileUtils.chmod 0755, 'somecommand'
|
54
|
+
FileUtils.chmod 0644, %w(my.rb your.rb his.rb her.rb)
|
55
|
+
FileUtils.chmod 0755, '/usr/bin/ruby', :verbose => true
|
56
|
+
=end
|
49
57
|
|
50
58
|
File.write( backup_file_path, File.read( file_full_path ) ) if will_clobber
|
51
59
|
::File.write( file_full_path, Base64.urlsafe_decode64( base64_content ) )
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
module SafeDb
|
4
|
+
|
5
|
+
# The wipe use case clears out any sensitive information from the clipboard.
|
6
|
+
# Typically it will be called after the copy use case has placed line values
|
7
|
+
# into both the primary and secondary clipboards (Ctrl-v and middle-click).
|
8
|
+
class Wipe < Controller
|
9
|
+
|
10
|
+
def execute()
|
11
|
+
|
12
|
+
system "printf \"safe wiped the clipboard on #{TimeStamp.readable()}.\" | xclip"
|
13
|
+
system "printf \"safe wiped the clipboard on #{TimeStamp.readable()}.\" | xclip -selection clipbaord"
|
14
|
+
|
15
|
+
puts ""
|
16
|
+
puts "safe has wiped the clipboards."
|
17
|
+
puts ""
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
module SafeDb
|
4
|
+
|
5
|
+
# The <tt>at use case</tt> is all about opening books at the right page.
|
6
|
+
# Its operation is similar to <tt>safe open</tt> and <tt>safe goto</tt>.
|
7
|
+
#
|
8
|
+
# It takes one and only one parameter which can consist of 1, 2 or 3 forward
|
9
|
+
# slash separated parts.
|
10
|
+
#
|
11
|
+
# $ safe at /contacts # login or switch to the contacts book
|
12
|
+
# $ safe at /contacts/friends # go to the friends chapter in contacts
|
13
|
+
# $ safe at /contacts/friends/paul # go to the paul verse in contacts
|
14
|
+
# $ safe at contacts/friends/paul # the same as above
|
15
|
+
# $ safe at mary # if already in friends chapter
|
16
|
+
# $ safe at ../family/mum #
|
17
|
+
#
|
18
|
+
#
|
19
|
+
class At < Controller
|
20
|
+
|
21
|
+
# The chapter and verse of this book that are to be opened.
|
22
|
+
attr_writer :chapter, :verse
|
23
|
+
|
24
|
+
def execute
|
25
|
+
|
26
|
+
@book.set_open_chapter_name( @chapter )
|
27
|
+
@book.set_open_verse_name( @verse )
|
28
|
+
@book.write()
|
29
|
+
|
30
|
+
# Show the mini dictionary at the opened chapter and verse location
|
31
|
+
# More work is needed when for when only the chapter is opened in
|
32
|
+
# which case we should show the list of verses and perhaps the count
|
33
|
+
# of key value pairs each verse contains.
|
34
|
+
Show.new.flow()
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
end
|
File without changes
|
File without changes
|
@@ -15,108 +15,45 @@ module SafeDb
|
|
15
15
|
# this entity can point to a book, chapter, verse or line. If no
|
16
16
|
# parameter entity is provided, the --all switch must be present
|
17
17
|
# to avoid an error message.
|
18
|
-
attr_writer :
|
18
|
+
attr_writer :line
|
19
19
|
|
20
20
|
# The copy use case copies one or more chapters, one or more verses and
|
21
21
|
# one or more lines to the clipboard so Ctrl-v can be used outside the
|
22
22
|
# safe to paste data in (like complex passwords).
|
23
23
|
def query_verse()
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
EXAMPLES
|
32
|
-
I hate man pages without examples!
|
33
|
-
|
34
|
-
uptime | xclip
|
35
|
-
|
36
|
-
Put your uptime in the X selection. Then middle click in an X application to paste.
|
37
|
-
|
38
|
-
xclip -loops 10 -verbose /etc/motd
|
39
|
-
|
40
|
-
Exit after /etc/motd (message of the day) has been pasted 10 times. Show how many selection requests (pastes)
|
41
|
-
have been processed.
|
42
|
-
|
43
|
-
xclip -o > helloworld.c
|
44
|
-
|
45
|
-
Put the contents of the selection into a file.
|
46
|
-
|
47
|
-
xclip -t text/html index.html
|
48
|
-
|
49
|
-
Middle click in an X application supporting HTML to paste the contents of the given file as HTML.
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
7[0;64r8[1A[Japollo@unity:~$ xclip -o
|
54
|
-
Constant Summaryapollo@unity:~$
|
55
|
-
apollo@unity:~$ xclip -o; echo
|
56
|
-
Constant Summary
|
57
|
-
apollo@unity:~$ xclip -o; echo
|
58
|
-
Module: Clipboard::File
|
59
|
-
apollo@unity:~$ xclip -o; echo
|
60
|
-
character of the selection specified
|
61
|
-
apollo@unity:~$ xclip -o; echo
|
62
|
-
long as they remain unambiguous
|
63
|
-
apollo@unity:~$ xclip -o; echo
|
64
|
-
long as they remain unambiguous
|
65
|
-
apollo@unity:~$ xclip -o; echo
|
66
|
-
long as they remain unambiguous
|
67
|
-
apollo@unity:~$ xclip -i ''
|
68
|
-
xclip: : No such file or directory
|
69
|
-
apollo@unity:~$ xclip -o; echo
|
70
|
-
long as they remain unambiguous
|
71
|
-
apollo@unity:~$ xclip ''
|
72
|
-
xclip: : No such file or directory
|
73
|
-
apollo@unity:~$ xclip -o; echo
|
74
|
-
long as they remain unambiguous
|
75
|
-
apollo@unity:~$ xclip -t ''
|
76
|
-
q
|
77
|
-
adsf
|
78
|
-
|
79
|
-
|
80
|
-
apollo@unity:~$
|
81
|
-
apollo@unity:~$
|
82
|
-
apollo@unity:~$ uptime | xclip
|
83
|
-
apollo@unity:~$ xclip -o; echo
|
84
|
-
00:34:46 up 5:10, 1 user, load average: 0.47, 0.52, 0.35
|
85
|
-
|
86
|
-
apollo@unity:~$ uptime
|
87
|
-
00:35:05 up 5:11, 1 user, load average: 0.34, 0.48, 0.34
|
88
|
-
apollo@unity:~$ uptime | xclip
|
89
|
-
apollo@unity:~$ xclip -o
|
90
|
-
00:35:29 up 5:11, 1 user, load average: 0.22, 0.44, 0.33
|
91
|
-
apollo@unity:~$ xclip -o
|
92
|
-
00:35:29 up 5:11, 1 user, load average: 0.22, 0.44, 0.33
|
93
|
-
apollo@unity:~$ xclip -o
|
94
|
-
00:35:29 up 5:11, 1 user, load average: 0.22, 0.44, 0.33
|
95
|
-
apollo@unity:~$ xclip -o
|
96
|
-
Error: target STRING not available
|
97
|
-
apollo@unity:~$ xclip -o
|
98
|
-
Error: target STRING not available
|
99
|
-
apollo@unity:~$ xclip -o
|
100
|
-
Error: target STRING not available
|
101
|
-
apollo@unity:~$ xclip -o
|
102
|
-
apollo@unity:~$
|
103
|
-
apollo@unity:~$ xclip -o; echo
|
104
|
-
|
105
|
-
apollo@unity:~$ xclip -o; echo
|
106
|
-
instead of -display. However, -v couldn't be used because it is ambiguous (it could be short for -verbose or
|
107
|
-
apollo@unity:~$ xclip -o; echo
|
108
|
-
0345 072 5555
|
109
|
-
apollo@unity:~$ echo "safe deleted clipboard contents" | xclip
|
110
|
-
apollo@unity:~$ xclip -o; echo
|
111
|
-
safe deleted clipboard contents
|
112
|
-
|
113
|
-
apollo@unity:~$ xclip -o; echo
|
114
|
-
(traditionally with the middle mouse button
|
115
|
-
apollo@unity:~$ xclip -o; echo
|
116
|
-
safedb.yijx-r7zr.19093.1515.01.676152709.json
|
117
|
-
|
118
|
-
=end
|
25
|
+
@line = "@password" if @line.nil?
|
26
|
+
unless ( @verse.has_key?( @line ) )
|
27
|
+
cannot_copy_line()
|
28
|
+
return
|
29
|
+
end
|
119
30
|
|
31
|
+
system "printf \"#{@verse[ @line ]}\" | xclip"
|
32
|
+
system "printf \"#{@verse[ @line ]}\" | xclip -selection clipbaord"
|
33
|
+
|
34
|
+
line_copied()
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
def line_copied()
|
40
|
+
|
41
|
+
puts ""
|
42
|
+
puts "The value for line \"#{@line}\" has been copied to the clipboard."
|
43
|
+
puts "You can use either Ctrl-v or a mouse middle click to paste it."
|
44
|
+
puts ""
|
45
|
+
puts "Wipe it from the clipboard with $ safe wipe"
|
46
|
+
puts ""
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def cannot_copy_line()
|
52
|
+
|
53
|
+
puts ""
|
54
|
+
puts "No parameter line to copy was given."
|
55
|
+
puts "Also this verse does not have a @password line."
|
56
|
+
puts ""
|
120
57
|
|
121
58
|
end
|
122
59
|
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
module SafeDb
|
4
|
+
|
5
|
+
# Print out the secret key/value pairs. These are the ones with keys that start
|
6
|
+
# with the @ sysmbol.
|
7
|
+
class Tell < QueryVerse
|
8
|
+
|
9
|
+
# Print out the secret key/value pairs. These are the ones with keys that start
|
10
|
+
# with the @ sysmbol.
|
11
|
+
def query_verse()
|
12
|
+
|
13
|
+
@book.print_book_mark()
|
14
|
+
if @verse.empty?()
|
15
|
+
|
16
|
+
puts " No lines in this chapter and verse location."
|
17
|
+
puts ""
|
18
|
+
return
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
show_map = {}
|
23
|
+
@verse.each do | key_str, value |
|
24
|
+
show_map.store( key_str, value ) if( key_str.start_with? "@" )
|
25
|
+
end
|
26
|
+
|
27
|
+
puts JSON.pretty_generate( show_map )
|
28
|
+
puts ""
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
end
|
data/lib/controller/requirer.rb
CHANGED
@@ -86,10 +86,10 @@ module SafeDb
|
|
86
86
|
def self.gems( gem_filepath )
|
87
87
|
|
88
88
|
require_relative "../version"
|
89
|
-
require_relative "../controller/controller"
|
90
|
-
require_relative "../controller/
|
91
|
-
require_relative "../controller/
|
92
|
-
require_relative "../controller/
|
89
|
+
require_relative "../controller/abstract/controller"
|
90
|
+
require_relative "../controller/abstract/authenticate"
|
91
|
+
require_relative "../controller/abstract/edit_verse"
|
92
|
+
require_relative "../controller/abstract/query_verse"
|
93
93
|
|
94
94
|
gem_basepath = File.expand_path "..", gem_filepath
|
95
95
|
Dir["#{gem_basepath}/**/*.rb"].each do |gem_path|
|
@@ -16,6 +16,40 @@ Use **`curl`** to pull down and place the following executable into /usr/local/b
|
|
16
16
|
|
17
17
|
https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz
|
18
18
|
|
19
|
+
``` bash
|
20
|
+
curl -o /tmp/geckodriver https://releases.hashicorp.com/terraform/0.11.13/terraform_0.11.13_linux_amd64.zip
|
21
|
+
sudo unzip /tmp/terraform.zip -d /usr/local/bin
|
22
|
+
sudo chmod a+x /usr/local/bin/terraform
|
23
|
+
rm /tmp/terraform.zip
|
24
|
+
terraform --version
|
25
|
+
```
|
26
|
+
|
27
|
+
```
|
28
|
+
## Geckodriver
|
29
|
+
wget https://github.com/mozilla/geckodriver/releases/download/v0.23.0/geckodriver-v0.23.0-linux64.tar.gz
|
30
|
+
sudo sh -c 'tar -x geckodriver -zf geckodriver-v0.23.0-linux64.tar.gz -O > /usr/bin/geckodriver'
|
31
|
+
sudo chmod +x /usr/bin/geckodriver
|
32
|
+
rm geckodriver-v0.23.0-linux64.tar.gz
|
33
|
+
|
34
|
+
## Chromedriver
|
35
|
+
wget https://chromedriver.storage.googleapis.com/2.29/chromedriver_linux64.zip
|
36
|
+
unzip chromedriver_linux64.zip
|
37
|
+
sudo chmod +x chromedriver
|
38
|
+
sudo mv chromedriver /usr/bin/
|
39
|
+
rm chromedriver_linux64.zip
|
40
|
+
```
|
41
|
+
|
42
|
+
gem install nokogiri
|
43
|
+
|
44
|
+
gem install mini_magick -v 3.5
|
45
|
+
|
46
|
+
gem install watir --no-ri --no-rdoc
|
47
|
+
|
48
|
+
gem install watir-webdriver --no-ri --no-rdoc
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
19
53
|
Now when you run the **`ruby visit.rb`** the browser should pop up and search for our search term.
|
20
54
|
|
21
55
|
### Reading Material
|
@@ -27,3 +27,36 @@ module SafeDb
|
|
27
27
|
|
28
28
|
|
29
29
|
end
|
30
|
+
|
31
|
+
|
32
|
+
=begin
|
33
|
+
|
34
|
+
install python3 and pip3
|
35
|
+
pip3 install selinium
|
36
|
+
then place the below code in a file and run with python <<file-name.py>>
|
37
|
+
note that a logfile called "geckodriver.log" will be created
|
38
|
+
|
39
|
+
-------------------------------------------
|
40
|
+
#!/usr/bin/env python
|
41
|
+
|
42
|
+
from selenium import webdriver
|
43
|
+
from selenium.webdriver.common.keys import Keys
|
44
|
+
|
45
|
+
import time
|
46
|
+
from selenium import webdriver
|
47
|
+
from selenium.webdriver.common.by import By
|
48
|
+
from selenium.webdriver.support.ui import WebDriverWait
|
49
|
+
from selenium.webdriver.support import expected_conditions as EC
|
50
|
+
from selenium.webdriver.common.keys import Keys
|
51
|
+
|
52
|
+
browser = webdriver.Firefox()
|
53
|
+
browser.get('http://www.google.co.uk')
|
54
|
+
|
55
|
+
search = browser.find_element_by_name('q')
|
56
|
+
search.send_keys("sainsburys")
|
57
|
+
search.send_keys(Keys.RETURN)
|
58
|
+
time.sleep(20)
|
59
|
+
browser.quit()
|
60
|
+
|
61
|
+
|
62
|
+
=end
|
data/lib/manual/copy-paste.md
CHANGED
@@ -1,7 +1,24 @@
|
|
1
|
+
<tt>Copy and paste data to and from the **clipboard**</tt>.
|
1
2
|
|
2
|
-
# safe copy | safe paste
|
3
|
+
# safe copy | safe clear | safe paste
|
4
|
+
|
5
|
+
## copy | intro
|
6
|
+
|
7
|
+
Copy into the clipboard the value held by the named line at the current book's open chapter and verse. This is more accurate and more secure than echoing the password and then performing a SELECT then COPY and then PASTE.
|
8
|
+
|
9
|
+
Use <b>safe clear</b> to wipe (overwrite) the sensitive value in the clipboard.
|
10
|
+
|
11
|
+
|
12
|
+
## paste | intro
|
13
|
+
|
14
|
+
Paste does the reverse of copy and also **auto-clears** the clipboard.
|
15
|
+
|
16
|
+
In the external application you select the text to copy, you then switch and type in something like **`safe paste @github.token`** - all verse lines will be displayed with sensitive values masked out. Note the extra line.
|
17
|
+
|
18
|
+
### Overwriting the Line's Value
|
19
|
+
|
20
|
+
If the line already exists and holds a value the paste operation will put the outgoing key/value pair into the **safe recycle bin**. This gives you a restore option.
|
3
21
|
|
4
|
-
<tt>Copy and paste data to and from the **clipboard**</tt>.
|
5
22
|
|
6
23
|
## pre-condition - install xclip
|
7
24
|
|
File without changes
|
@@ -0,0 +1,46 @@
|
|
1
|
+
|
2
|
+
#### Use `safe push` and `safe pull` to remotely store and retrieve your safe books.
|
3
|
+
|
4
|
+
<span style="font-family:Papyrus; font-size:2em;">**`safe remote --provision`** must have been run with access to the Github repository token so that it can **create the git repository backend** and furnish that repository with a public key so that a **`git push`** can occur during a **`safe push`** execution.</span>
|
5
|
+
|
6
|
+
**A push puts your crypt files into remote storage and writes a single file to a (usb key or phone) removable drive. A pull reads the file, accesses the right repository and restores (or refreshes) your safe database.**
|
7
|
+
|
8
|
+
The ***removable.drive*** folder **need not be removable**, but if you are moving from one machine to another, it helps if the path sits on a removable USB key, an external drive, or a smartphone.
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
# safe push --to="/path/to/removable/drive"
|
13
|
+
|
14
|
+
The first time you **`safe push`** on a machine you must provide a path to a folder on a removable drive. This is cached against a reference in the form **`username@<MACHINE_ID>`**.
|
15
|
+
|
16
|
+
Simply provide the **`--to`** option to use a different removable drive folder.
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
## safe push
|
21
|
+
|
22
|
+
You **`safe push`** to synchronize your local and remote safe database.
|
23
|
+
|
24
|
+
```
|
25
|
+
safe login db.admin # once per session (shell)
|
26
|
+
safe push # as often as you like
|
27
|
+
```
|
28
|
+
|
29
|
+
The following will be true after every successful **`safe push`** operation.
|
30
|
+
|
31
|
+
After **`safe push`** notice a file called safe-database.ini within the removable drive folder.
|
32
|
+
|
33
|
+
|
34
|
+
## when to reconfigure the removable drive
|
35
|
+
|
36
|
+
Configure the removable.drive **once per user/machine** combo. You'll need to rerun the command when configuring safedb
|
37
|
+
|
38
|
+
- for **another user** on the same machine
|
39
|
+
- on a **different machine**
|
40
|
+
- to add more **removable drive** paths
|
41
|
+
|
42
|
+
<span style="font-family:Papyrus; font-size:2em;">Currently safe only supports a github backend, but this will be expanded to include s3 buckets, git repositories, ssh and sftp, dropbox, google drive and even key-value stores like etcd, redis and Amazon's dynamo db.</span>
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
# safe pull --from="/path/to/removable/drive"
|