safedb 0.01.0001
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.yardopts +3 -0
- data/Gemfile +10 -0
- data/LICENSE +21 -0
- data/README.md +793 -0
- data/Rakefile +16 -0
- data/bin/safe +5 -0
- data/lib/configs/README.md +58 -0
- data/lib/extension/array.rb +162 -0
- data/lib/extension/dir.rb +35 -0
- data/lib/extension/file.rb +123 -0
- data/lib/extension/hash.rb +33 -0
- data/lib/extension/string.rb +572 -0
- data/lib/factbase/facts.safedb.net.ini +38 -0
- data/lib/interprete.rb +462 -0
- data/lib/keytools/PRODUCE_RAND_SEQ_USING_DEV_URANDOM.txt +0 -0
- data/lib/keytools/kdf.api.rb +243 -0
- data/lib/keytools/kdf.bcrypt.rb +265 -0
- data/lib/keytools/kdf.pbkdf2.rb +262 -0
- data/lib/keytools/kdf.scrypt.rb +190 -0
- data/lib/keytools/key.64.rb +326 -0
- data/lib/keytools/key.algo.rb +109 -0
- data/lib/keytools/key.api.rb +1391 -0
- data/lib/keytools/key.db.rb +330 -0
- data/lib/keytools/key.docs.rb +195 -0
- data/lib/keytools/key.error.rb +110 -0
- data/lib/keytools/key.id.rb +271 -0
- data/lib/keytools/key.ident.rb +243 -0
- data/lib/keytools/key.iv.rb +107 -0
- data/lib/keytools/key.local.rb +259 -0
- data/lib/keytools/key.now.rb +402 -0
- data/lib/keytools/key.pair.rb +259 -0
- data/lib/keytools/key.pass.rb +120 -0
- data/lib/keytools/key.rb +585 -0
- data/lib/logging/gem.logging.rb +132 -0
- data/lib/modules/README.md +43 -0
- data/lib/modules/cryptology/aes-256.rb +154 -0
- data/lib/modules/cryptology/amalgam.rb +70 -0
- data/lib/modules/cryptology/blowfish.rb +130 -0
- data/lib/modules/cryptology/cipher.rb +207 -0
- data/lib/modules/cryptology/collect.rb +138 -0
- data/lib/modules/cryptology/crypt.io.rb +225 -0
- data/lib/modules/cryptology/engineer.rb +99 -0
- data/lib/modules/mappers/dictionary.rb +288 -0
- data/lib/modules/storage/coldstore.rb +186 -0
- data/lib/modules/storage/git.store.rb +399 -0
- data/lib/session/fact.finder.rb +334 -0
- data/lib/session/require.gem.rb +112 -0
- data/lib/session/time.stamp.rb +340 -0
- data/lib/session/user.home.rb +49 -0
- data/lib/usecase/cmd.rb +487 -0
- data/lib/usecase/config/README.md +57 -0
- data/lib/usecase/docker/README.md +146 -0
- data/lib/usecase/docker/docker.rb +49 -0
- data/lib/usecase/edit/README.md +43 -0
- data/lib/usecase/edit/delete.rb +46 -0
- data/lib/usecase/export.rb +40 -0
- data/lib/usecase/files/README.md +37 -0
- data/lib/usecase/files/eject.rb +56 -0
- data/lib/usecase/files/file_me.rb +78 -0
- data/lib/usecase/files/read.rb +169 -0
- data/lib/usecase/files/write.rb +89 -0
- data/lib/usecase/goto.rb +57 -0
- data/lib/usecase/id.rb +36 -0
- data/lib/usecase/import.rb +157 -0
- data/lib/usecase/init.rb +63 -0
- data/lib/usecase/jenkins/README.md +146 -0
- data/lib/usecase/jenkins/jenkins.rb +208 -0
- data/lib/usecase/login.rb +71 -0
- data/lib/usecase/logout.rb +28 -0
- data/lib/usecase/open.rb +71 -0
- data/lib/usecase/print.rb +40 -0
- data/lib/usecase/put.rb +81 -0
- data/lib/usecase/set.rb +44 -0
- data/lib/usecase/show.rb +138 -0
- data/lib/usecase/terraform/README.md +91 -0
- data/lib/usecase/terraform/terraform.rb +121 -0
- data/lib/usecase/token.rb +35 -0
- data/lib/usecase/update/README.md +55 -0
- data/lib/usecase/update/rename.rb +180 -0
- data/lib/usecase/use.rb +41 -0
- data/lib/usecase/verse.rb +20 -0
- data/lib/usecase/view.rb +71 -0
- data/lib/usecase/vpn/README.md +150 -0
- data/lib/usecase/vpn/vpn.ini +31 -0
- data/lib/usecase/vpn/vpn.rb +54 -0
- data/lib/version.rb +3 -0
- data/safedb.gemspec +34 -0
- metadata +193 -0
@@ -0,0 +1,340 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
module OpenSession
|
4
|
+
|
5
|
+
require 'singleton'
|
6
|
+
|
7
|
+
# This stamp sits at the centre of a fundamental DevOps pattern concerned
|
8
|
+
# with infrastructure provisioning and configuraion management.
|
9
|
+
#
|
10
|
+
# The central idea behind the pattern is to link every infrastructure
|
11
|
+
# object created during a session with a reference accurate to the nearest
|
12
|
+
# centi-second denoting the moment the software runtime (session) began.
|
13
|
+
class Stamp
|
14
|
+
include Singleton
|
15
|
+
|
16
|
+
attr_reader :time_now
|
17
|
+
|
18
|
+
# Return two digit [mo] month index from 01 to 12.
|
19
|
+
# @example 02 => in February
|
20
|
+
def self.mo
|
21
|
+
return Stamp.instance.time_now.strftime "%m"
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
# Return three character abbreviated month name.
|
26
|
+
# @example feb => in February
|
27
|
+
def self.mmm
|
28
|
+
return Stamp.instance.time_now.strftime( "%b" ).downcase
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
# Return three character abbreviated day of week.
|
33
|
+
# @example tue => on Tuesday
|
34
|
+
def self.ddd
|
35
|
+
return Stamp.instance.time_now.strftime( "%a" ).downcase
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
# Return two digit (character) hour of day from 00 to 23.
|
40
|
+
# @example 22 => between 22.00.00 and 22.59.59 inclusive
|
41
|
+
def self.hh
|
42
|
+
return Stamp.instance.time_now.strftime "%H"
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
# Return two digit minute of hour from [00] to [59].
|
47
|
+
def self.mm
|
48
|
+
return Stamp.instance.time_now.strftime "%M"
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
# Return two digit second of minute from [00] to [59].
|
53
|
+
def self.ss
|
54
|
+
return Stamp.instance.time_now.strftime "%S"
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
# Return a [3 digit] second and tenth of second
|
59
|
+
# representation.
|
60
|
+
#
|
61
|
+
# The final digit is derived from the 1000 sliced
|
62
|
+
# millisecond of second running from 000 to 999.
|
63
|
+
#
|
64
|
+
# <tt>Truncation (Not Rounding)</tt>
|
65
|
+
#
|
66
|
+
# The [final] digit is acquired by TRUNCATING
|
67
|
+
# (chopping off) the last 2 of the 3 millisecond
|
68
|
+
# digits. No rounding is applied.
|
69
|
+
#
|
70
|
+
# The 3 returned digits comprise of the
|
71
|
+
#
|
72
|
+
# - second of minute => 2 digits | [00] to [59] (and)
|
73
|
+
# - tenth of second => 1 digit from [0] to [9]
|
74
|
+
#
|
75
|
+
# @example
|
76
|
+
#
|
77
|
+
# => The time at the 562nd millisecond of the 49th
|
78
|
+
# second of the minute.
|
79
|
+
#
|
80
|
+
# => 3 chars
|
81
|
+
# => 495
|
82
|
+
def self.sst
|
83
|
+
millisec_string = Stamp.instance.time_now.strftime "%L"
|
84
|
+
return "#{ss}#{millisec_string[0]}"
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
# Return the [two] digit year (eg 19 for 2019).
|
89
|
+
# that we are currently in.
|
90
|
+
def self.yy
|
91
|
+
return Stamp.instance.time_now.strftime("%Y")[2..-1]
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
# Return the [four] digit year (eg 2019)
|
96
|
+
# that we are currently in.
|
97
|
+
def self.yyyy
|
98
|
+
return Stamp.instance.time_now.strftime("%Y")
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
# Return 3 digit julian day of year [001] to [366].
|
103
|
+
def self.jjj
|
104
|
+
return Stamp.instance.time_now.strftime "%j"
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
# [yymo_mmm] returns an amalgam of
|
109
|
+
#
|
110
|
+
# => the two-digit year
|
111
|
+
# => the two-digit month index (starting at 01)
|
112
|
+
# => a period (separator)
|
113
|
+
# => the abbreviated month name
|
114
|
+
#
|
115
|
+
# @example
|
116
|
+
# => 1908.aug
|
117
|
+
# => for August 2019
|
118
|
+
#
|
119
|
+
def self.yymo_mmm
|
120
|
+
return "#{yy}#{mo}.#{mmm}"
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
# Given two integer parameters (month index and 4 digit year) representing
|
125
|
+
# the month in question this method returns the [PREVIOUS MONTHS] character
|
126
|
+
# amalgam in the format [yymo_mmm] where
|
127
|
+
#
|
128
|
+
# => yy | previous month's two-digit year
|
129
|
+
# => mo | previous month's two-digit month index
|
130
|
+
# => . | a period (separator)
|
131
|
+
# => mmm | previous month's abbreviated month name
|
132
|
+
#
|
133
|
+
# -------------------
|
134
|
+
# Example 1 (Simple)
|
135
|
+
# -------------------
|
136
|
+
#
|
137
|
+
# returns char => 1907.jul
|
138
|
+
# 4 parameters => 8, 2019
|
139
|
+
# representing => August, 2019
|
140
|
+
#
|
141
|
+
# ----------------------
|
142
|
+
# Example 2 (Last Year)
|
143
|
+
# ----------------------
|
144
|
+
#
|
145
|
+
# returns char => 1812.dec
|
146
|
+
# 4 parameters => 1, 2019
|
147
|
+
# representing => January, 2019
|
148
|
+
def self.previous_month_chars this_month_index, this_4digit_year
|
149
|
+
|
150
|
+
prev_month_index = this_month_index == 1 ? 12 : ( this_month_index - 1 )
|
151
|
+
prev_2dig_mn_pad = sprintf '%02d', prev_month_index
|
152
|
+
prev_4digit_year = this_month_index == 1 ? ( this_4digit_year - 1 ) : this_4digit_year
|
153
|
+
prev_twodigit_yr = "#{prev_4digit_year.to_s}"[2..-1]
|
154
|
+
prev_months_name = Date::ABBR_MONTHNAMES[prev_month_index].downcase
|
155
|
+
|
156
|
+
return "#{prev_twodigit_yr}#{prev_2dig_mn_pad}.#{prev_months_name}"
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
# Using the current class time this method returns
|
161
|
+
# the character amalgam for the [PREVIOUS MONTH] in
|
162
|
+
# the format [yymo_mmm] where
|
163
|
+
#
|
164
|
+
# => yy | last month's two-digit year
|
165
|
+
# => mo | last month's two-digit month index
|
166
|
+
# => . | a period (separator)
|
167
|
+
# => mmm | last month's abbreviated month name
|
168
|
+
#
|
169
|
+
# -------------------
|
170
|
+
# Example 1 (Simple)
|
171
|
+
# -------------------
|
172
|
+
#
|
173
|
+
# returns => 1907.jul
|
174
|
+
# if this month is => August 2019
|
175
|
+
#
|
176
|
+
# ----------------------
|
177
|
+
# Example 2 (Last Year)
|
178
|
+
# ----------------------
|
179
|
+
#
|
180
|
+
# returns => 1812.dec
|
181
|
+
# if this month is => January 2019
|
182
|
+
def self.yymo_mmm_prev
|
183
|
+
return previous_month_chars mo.to_i, yyyy.to_i
|
184
|
+
end
|
185
|
+
|
186
|
+
|
187
|
+
# Return 5 digit amalgam of year and julian day.
|
188
|
+
# eg [19003] for [January 3rd 2019]
|
189
|
+
def self.yyjjj
|
190
|
+
return "#{yy}#{jjj}"
|
191
|
+
end
|
192
|
+
|
193
|
+
|
194
|
+
# Return the 4 digit amalgam of the hour and minute
|
195
|
+
# using the 24 hour clock.
|
196
|
+
#
|
197
|
+
# @example
|
198
|
+
# => 1525
|
199
|
+
# => 03:25 pm
|
200
|
+
def self.hhmm
|
201
|
+
return "#{hh}#{mm}"
|
202
|
+
end
|
203
|
+
|
204
|
+
|
205
|
+
# Return the time of day to a TENTH of a second accuracy.
|
206
|
+
# [8] characters will always be returned with the 5th one
|
207
|
+
# being the (period) separator.
|
208
|
+
#
|
209
|
+
# The first (separated) segment delivers a hhmm 24 hour
|
210
|
+
# clock representation of the stamped time.
|
211
|
+
#
|
212
|
+
# The 3 digits of the second segment comprise of
|
213
|
+
#
|
214
|
+
# second of minute => 2 digits | [00] to [59]
|
215
|
+
# tenth of second => 1 digit from [0] to [9]
|
216
|
+
#
|
217
|
+
# @example
|
218
|
+
# => The time at the 562nd millisecond of the 49th
|
219
|
+
# second of the 23rd minute of the 17th hour of
|
220
|
+
# the day ( 17:23:49.562 )
|
221
|
+
#
|
222
|
+
# => 8 chars
|
223
|
+
# => 1723.495
|
224
|
+
def self.hhmm_sst
|
225
|
+
return "#{hhmm}.#{sst}"
|
226
|
+
end
|
227
|
+
|
228
|
+
|
229
|
+
# Return a string timestampt that is a period separated
|
230
|
+
# amalgam of the 2 digit year, 3 digit julian day, 2 digit
|
231
|
+
# hour, 2 digit minute, 2 digit second and 1 digit rounded
|
232
|
+
# down tenth of second.
|
233
|
+
#
|
234
|
+
# @example
|
235
|
+
# => 19003.1025
|
236
|
+
# => 10:25 am on January 3rd 2019
|
237
|
+
#
|
238
|
+
#
|
239
|
+
# Return the time of day to a TENTH of a second accuracy.
|
240
|
+
# [8] characters will always be returned with the 5th one
|
241
|
+
# being the (period) separator.
|
242
|
+
#
|
243
|
+
# The first (separated) segment delivers a hhmm 24 hour
|
244
|
+
# clock representation of the stamped time.
|
245
|
+
#
|
246
|
+
# The 3 digits of the second segment comprise of
|
247
|
+
#
|
248
|
+
# - second of minute => 2 digits | [00] to [59]
|
249
|
+
# - tenth of second => 1 digit from [0] to [9]
|
250
|
+
#
|
251
|
+
# @example
|
252
|
+
# => The time at the 562nd millisecond of the 49th
|
253
|
+
# second of the 23rd minute of the 17th hour of
|
254
|
+
# the day ( 17:23:49.562 )
|
255
|
+
#
|
256
|
+
# => 8 chars
|
257
|
+
# => 1723.495
|
258
|
+
def self.yyjjj_hhmm_sst
|
259
|
+
return "#{yyjjj}.#{hhmm}.#{sst}"
|
260
|
+
end
|
261
|
+
|
262
|
+
|
263
|
+
# Return a string timestampt that is a period separated
|
264
|
+
# amalgam of the 2 digit year, 3 digit julian day, 2 digit
|
265
|
+
# hour, 2 digit minute, 2 digit second and <b>9 digit</b>
|
266
|
+
# nanosecond.
|
267
|
+
#
|
268
|
+
# @example
|
269
|
+
# return => 19003.1725.42.836592034
|
270
|
+
# 4 time => 17:25:42 am on January 3rd 2019
|
271
|
+
#
|
272
|
+
# As per the above example, the time returned
|
273
|
+
#
|
274
|
+
# - is the 836592034 <b>nanosecond</b>
|
275
|
+
# - of the 42nd <b>second</b>
|
276
|
+
# - of the 25th <b>minute</b>
|
277
|
+
# - of the 17th <b>hour</b>
|
278
|
+
# - of the 3rd <b>day</b>
|
279
|
+
# - of the 20th <b>year</b>
|
280
|
+
# - of the 21st <b>century</b>
|
281
|
+
#
|
282
|
+
# @return [String]
|
283
|
+
# Return the time of day to nanosecond accuracy.
|
284
|
+
# 23 characters are always returned with three (3) period
|
285
|
+
# separators at the 6th, 11th and 14th positions.
|
286
|
+
def self.yyjjj_hhmm_ss_nanosec
|
287
|
+
nanosec_str = Stamp.instance.time_now.strftime "%9N"
|
288
|
+
return "#{yyjjj}.#{hhmm}.#{ss}.#{nanosec_str}"
|
289
|
+
end
|
290
|
+
|
291
|
+
|
292
|
+
# Return the Rubyfied time zone being used.
|
293
|
+
def self.zone
|
294
|
+
return Stamp.instance.time_now.zone
|
295
|
+
end
|
296
|
+
|
297
|
+
|
298
|
+
# Log segments of time pertaining to the time stamp.
|
299
|
+
# @todo
|
300
|
+
# move method contents into test class
|
301
|
+
def self.log_instance_time
|
302
|
+
|
303
|
+
log.info(x) { "[stamp] -------------- => -------------------------------- #" }
|
304
|
+
log.info(x) { "[stamp] eco time stamp => [#{Stamp.instance.time_now.ctime}]" }
|
305
|
+
log.info(x) { "[stamp] -------------- => -------------------------------- #" }
|
306
|
+
log.info(x) { "[stamp] Univ Time Zone => #{zone}" }
|
307
|
+
log.info(x) { "[stamp] Month Index is => #{mo}" }
|
308
|
+
log.info(x) { "[stamp] Month Name is => #{mmm}" }
|
309
|
+
log.info(x) { "[stamp] Day Of Week is => #{ddd}" }
|
310
|
+
log.info(x) { "[stamp] -------------- => -------------------------------- #" }
|
311
|
+
log.info(x) { "[stamp] Two Digit Year => #{yy}" }
|
312
|
+
log.info(x) { "[stamp] Julian Cal Day => #{jjj}" }
|
313
|
+
log.info(x) { "[stamp] Yr and Jul Day => #{yyjjj}" }
|
314
|
+
log.info(x) { "[stamp] Hour of Theday => #{hh}" }
|
315
|
+
log.info(x) { "[stamp] Minute of Hour => #{mm}" }
|
316
|
+
log.info(x) { "[stamp] Hour + Minute => #{hhmm}" }
|
317
|
+
log.info(x) { "[stamp] Second of Min => #{ss}" }
|
318
|
+
log.info(x) { "[stamp] 600 Min Slices => #{sst}" }
|
319
|
+
log.info(x) { "[stamp] -------------- => -------------------------------- #" }
|
320
|
+
log.info(x) { "[stamp] The Time Stamp => #{yyjjj_hhmm_sst}" }
|
321
|
+
log.info(x) { "[stamp] -------------- => -------------------------------- #" }
|
322
|
+
|
323
|
+
end
|
324
|
+
|
325
|
+
|
326
|
+
# This singleton (one instance) class sets the time just once.
|
327
|
+
def initialize
|
328
|
+
|
329
|
+
@time_now = Time.now;
|
330
|
+
|
331
|
+
end
|
332
|
+
|
333
|
+
|
334
|
+
############ Stamp.log_instance_time
|
335
|
+
|
336
|
+
|
337
|
+
end
|
338
|
+
|
339
|
+
|
340
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# coding: utf-8
|
4
|
+
|
5
|
+
# opensession contains basic behaviour for managing a client only
|
6
|
+
# (serverless) session. Configuration directives are read and written
|
7
|
+
# from an INI off the home directory that is created when the session
|
8
|
+
# is first initiated.
|
9
|
+
module OpenSession
|
10
|
+
|
11
|
+
# This singleton class ascertains the users home folder in a manner
|
12
|
+
# agnositic to whether the software is running on Linux or Windows.
|
13
|
+
class Home
|
14
|
+
include Singleton
|
15
|
+
|
16
|
+
# This static behaviour reads the [home folder] just once.
|
17
|
+
def self.dir
|
18
|
+
return Home.instance.folder
|
19
|
+
end
|
20
|
+
|
21
|
+
# This static behaviour reads the [username] just once.
|
22
|
+
def self.usr
|
23
|
+
return Home.instance.username
|
24
|
+
end
|
25
|
+
|
26
|
+
attr_reader :folder
|
27
|
+
attr_reader :username
|
28
|
+
|
29
|
+
# Ascertain the home folder location.
|
30
|
+
def initialize
|
31
|
+
|
32
|
+
# On Windows the home folder may end with [AppData/Roaming].
|
33
|
+
extraneous_path = "/AppData/Roaming"
|
34
|
+
|
35
|
+
@folder = Dir.home
|
36
|
+
@username = @folder.split("/").last
|
37
|
+
return unless Dir.home.end_with? extraneous_path
|
38
|
+
|
39
|
+
# Remove the tail [AppData/Roaming] from the home path.
|
40
|
+
@folder = Dir.home.gsub extraneous_path, ""
|
41
|
+
@username = @folder.split("/").last
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
end
|