opensecret 0.0.8 → 0.0.913

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e67c23773cbe174123307c2867d43bb87eadeb52
4
- data.tar.gz: a609ac281671d31a31347f3b4b495624a0943627
3
+ metadata.gz: 26149681c5b0cbb089a8c9d82953c4e8981147c1
4
+ data.tar.gz: 3a2cac8d536acc786fbd1343a694f14ff2b0d73e
5
5
  SHA512:
6
- metadata.gz: 5a4ad46b55c31d1ee53b712d16614a1bc037e5530ade7a3cee1d1f36ac7a810ab24acfd477a80f1ae8f61a0b304fcf6fb6a00a93138b9c92eee7ec1feec8a56a
7
- data.tar.gz: d234147703779a54e450edd86dacb66dc47f2fa651d8ff310d4baf32813a3a7e3dd632d1da2abe917b090d552fafe0f9196edfb56c94188687dda0d29c633c8a
6
+ metadata.gz: 79409037388746addf1d6574813a84ab3dedb19761009c56f447b24cfc0ad36262859cf7832f3ff3366847abb912fb81e412893466c9f2489f13e837e6058ea9
7
+ data.tar.gz: 79eb02b2befae0c6c0432ed1d065be7b7ea960dc43c64767062ab68419ee49036414376acba0e40047b2d1731422bbd9f9179fc7c6a04a4d8ff92177babdbf9c
data/README.md CHANGED
@@ -4,9 +4,9 @@ opensecret [![Build Status](https://secure.travis-ci.org/TwP/inifile.png)](http:
4
4
  Description
5
5
  -----------
6
6
 
7
- +opensecret+ stashes uncrackable secrets into your +Git+, +S3+, DropBox, Google Drive and filesystems backends. You interface with its intuitive Linux, Windows, iOS front ends and it offers SDKs and plugins for +Ruby+, +Python+, +Go+, +Java+, Jenkins, CodeShip, Ansible, Terraform, Puppet and Chef. Soon, support will be added for database and keystore backends such as +MySQL+, +MongoDB+, +PostgreSQL+, Redis, Memcached and etcd.
7
+ opensecret stashes uncrackable secrets into your Git, S3, DropBox, Google Drive and filesystems backends. You interface with its intuitive Linux, Windows, iOS front ends and it offers SDKs and plugins for Ruby, Python, Go, Java, Jenkins, CodeShip, Ansible, Terraform, Puppet and Chef. Soon, support will be added for database and keystore backends such as MySQL, MongoDB, PostgreSQL, Redis, Memcached and etcd.
8
8
 
9
- opensecret never accesses the cloud for anything - it is designed to operate on a single non-networked laptop if you so wish. opensecret takes a fresh approach to security and challenges common misconceptions - in order to deliver a simple, highly secure credentials management system.
9
+ **opensecret never accesses the cloud.** It can operate on a wee non-networked laptop if you so wish. opensecret takes a fresh approach to security and challenges common misconceptions - in order to deliver a simple, highly secure credentials management system.
10
10
 
11
11
 
12
12
  ### opensecret | Install It
@@ -1,8 +1,10 @@
1
- require "opensecret/version"
2
- require "opensecret/plugins.io/cipher/crypto"
3
1
  require "thor"
2
+ require "session/time.stamp"
3
+ require "session/session"
4
4
 
5
- # ### This command line processor will
5
+ #
6
+ # This command line processor extends Thor's functionality in
7
+ # order to
6
8
  #
7
9
  # - read the posted commands, options and switches
8
10
  # - maps the incoming string data to objects
@@ -11,17 +13,58 @@ require "thor"
11
13
  # - ensure that the parameter values are in range
12
14
  # - delegate processing to the registered handlers
13
15
  #
14
- # @note the Thor ruby gem is used for the heavy lifting
15
- #
16
- # @example opensecret initdomain create friends.joebloggs --secure
17
- # @example opensecret user create id=joe email=joebloggs@opensecret.io
18
- # @example opensecret user create id=joe email=joebloggs@opensecret.io
19
- #
20
- #
21
16
  class CommandProcessor < Thor
22
17
 
23
- desc "init DOMAIN", "DOMAIN eg lecturers@harvard names your friends, family or work group."
24
- desc "init STORE_URL", "STORE_URL is backend Git/S3/SSH crypt store. Use https://www.eco-platform.co.uk/crypt.store.git"
18
+ #
19
+ # This class option allows every CLI call the option to include
20
+ # a --debug boolean switch which will up the verbosity of the
21
+ # content logged to the file .opensecret/opensecret.log
22
+ #
23
+ class_option :debug, :type => :boolean
24
+
25
+ #
26
+ # Thor method describing the mandatory directory path parameter
27
+ # in the keydir cli interface call.
28
+ #
29
+ desc "keydir KEYPATH", "KEYPATH path to USB key for storing private keys"
30
+
31
+ #
32
+ # A USB key drive is the ideal store for the encrypted private
33
+ # key and the tamper proof configuration file. This method collects
34
+ # the usb drive path and then
35
+ #
36
+ # - checks the path exists
37
+ # - if not, it attempts to create the path
38
+ # - if successful it's written into HOME/.opensecret/opensecret.keydir.txt
39
+ #
40
+ # @example opensecret keydir /path/to/usb/key/dir
41
+ #
42
+ # Alternate Use Case Flows
43
+ #
44
+ # - if file exists with equal (case sensitive) content this is logged
45
+ # - if file exists with different content that content is logged and changed
46
+ #
47
+ # @param keypath [String] the path to USB key for storing private keys
48
+ #
49
+ def keydir keypath
50
+
51
+ if( File.exists?( keypath ) && !(File.directory? keypath) )
52
+ abort "The path cannot be a file => #{keypath}"
53
+ end
54
+
55
+ FileUtils.mkdir_p keypath unless File.exists? keypath
56
+
57
+ secret_session = OpenSession::Session.new
58
+ secret_session.write_keyvalue "opensecret", "key_folder", keypath
59
+ session_file = secret_session.get_filepath "opensecret"
60
+
61
+ puts ""
62
+ puts "private key directory => [ #{keypath} ]"
63
+ puts "session configuration => [ #{session_file} ]"
64
+ puts "session time stamp is => [ #{OpenSession::Stamp.yyjjj_hhmm_sst} ]"
65
+ puts ""
66
+
67
+ end
25
68
 
26
69
  #
27
70
  # Initialize (configure) two fundamental crypt pointers
@@ -38,15 +81,15 @@ class CommandProcessor < Thor
38
81
  # @param domain [String] the DOMAIN eg lecturers@harvard for your family or work group.
39
82
  # @param store_url [String] the STORE_URL for connecting to the backend storage service
40
83
  #
41
- def init domain, store_url
84
+ # ---> def init domain, store_url
42
85
 
43
- OpenSecret::Crypto.register_domain domain, store_url
86
+ # ---> OpenSecret::Crypto.register_domain domain, store_url
44
87
 
45
- puts ""
46
- puts "New domain configured => [ #{domain} ]"
47
- puts "Crypt store configured => [ #{store_url} ]"
48
- puts ""
88
+ # ---> puts ""
89
+ # ---> puts "New domain configured => [ #{domain} ]"
90
+ # ---> puts "Crypt store configured => [ #{store_url} ]"
91
+ # ---> puts ""
49
92
 
50
- end
93
+ # ---> end
51
94
 
52
95
  end
@@ -0,0 +1,219 @@
1
+ #!/usr/bin/ruby
2
+ # coding: utf-8
3
+
4
+ # opensession contains basic behaviour for managing a client only
5
+ # (serverless) session. Configuration directives are read and written
6
+ # from an INI off the home directory that is created when the session
7
+ # is first initiated.
8
+ #
9
+ # The session is expected to be formally closed down and that is
10
+ # reflected by explicitly deleting the configuration file. If this
11
+ # "session over" command is not issued a reasonable time limit is
12
+ # then invoked when the next session command is issued.
13
+ #
14
+ # This "session awakening" wipes the slate clean and starts afresh
15
+ # with regard to the two dimensional array of configuration directive
16
+ # pointers.
17
+ module OpenSession
18
+
19
+ require 'inifile'
20
+
21
+
22
+ ## ---> Cleaning User Input - Use Me
23
+ ## ---> Cleaning User Input - Use Me
24
+ ## ---> Cleaning User Input - Use Me
25
+ ## ---> Cleaning User Input - Use Me
26
+ ## ---> Cleaning User Input - Use Me
27
+ ## ---> Cleaning User Input - Use Me
28
+ ## ---> Cleaning User Input - Use Me
29
+ ## ---> Cleaning User Input - Use Me
30
+ ## ---> Cleaning User Input - Use Me
31
+ ## ---> Cleaning User Input - Use Me
32
+ ## ---> Cleaning User Input - Use Me
33
+ ## ---> Cleaning User Input - Use Me
34
+
35
+
36
+ def generate_username(fullname)
37
+ ActiveSupport::Inflector.transliterate(fullname) # change ñ => n
38
+ .downcase # only lower case
39
+ .strip # remove spaces around the string
40
+ .gsub(/[^a-z]/, '_') # any character that is not a letter or a number will be _
41
+ .gsub(/\A_+/, '') # remove underscores at the beginning
42
+ .gsub(/_+\Z/, '') # remove underscores at the end
43
+ .gsub(/_+/, '_') # maximum an underscore in a row
44
+ end
45
+
46
+
47
+ ## ---> Cleaning User Input - Did You Use Me?
48
+ ## ---> Cleaning User Input - Did You Use Me?
49
+ ## ---> Cleaning User Input - Did You Use Me?
50
+ ## ---> Cleaning User Input - Did You Use Me?
51
+ ## ---> Cleaning User Input - Did You Use Me?
52
+ ## ---> Cleaning User Input - Did You Use Me?
53
+ ## ---> Cleaning User Input - Did You Use Me?
54
+ ## ---> Cleaning User Input - Did You Use Me?
55
+ ## ---> Cleaning User Input - Did You Use Me?
56
+ ## ---> Cleaning User Input - Did You Use Me?
57
+ ## ---> Cleaning User Input - Did You Use Me?
58
+ ## ---> Cleaning User Input - Did You Use Me?
59
+ ## ---> Cleaning User Input - Did You Use Me?
60
+ ## ---> Cleaning User Input - Did You Use Me?
61
+
62
+
63
+ # opensession contains basic behaviour for managing a client only
64
+ # (serverless) session. Configuration directives are read and written
65
+ # from an INI off the home directory that is created when the session
66
+ # is first initiated.
67
+ #
68
+ # The session is expected to be formally closed down and that is
69
+ # reflected by explicitly deleting the configuration file. If this
70
+ # "session over" command is not issued a reasonable time limit is
71
+ # then invoked when the next session command is issued.
72
+ #
73
+ # This "session awakening" wipes the slate clean and starts afresh
74
+ # with regard to the two dimensional array of configuration directive
75
+ # pointers.
76
+ class Session
77
+
78
+
79
+ @@filename_tail = "-session.ini"
80
+ attr_reader :time_stamp
81
+
82
+
83
+ # This singleton (one instance) class initializes by getting
84
+ # the current timestamp.
85
+ def initialize
86
+
87
+ @time_stamp = OpenSession::Stamp.instance
88
+
89
+ end
90
+
91
+
92
+ #
93
+ # Write the key/value pair in the parameter into the session's
94
+ # configuration INI file that lives in a context-named folder
95
+ # off the home directory.
96
+ #
97
+ # The session file will be in a folder whose name is simply
98
+ # the dot prefixed context_name. The session file itself will
99
+ # be named using context_name + @@filename_tail
100
+ #
101
+ # @example ~/.openbox/openbox-session.ini is the filepath for context "openbox"
102
+ #
103
+ # If neither the folder nor file exist, both are created.
104
+ # If the file did not exist a new one will with the contents
105
+ # (if the key is length and the value is 2m).
106
+ #
107
+ # [openbox]
108
+ # length = 2m
109
+ #
110
+ # If the file does already exist, an appropriate merge will be
111
+ # performed to create or update the section name, key name and
112
+ # value. The file may end up looking like
113
+ #
114
+ # [closedbox]
115
+ # shape = cuboid
116
+ # color = blue
117
+ #
118
+ # [openbox]
119
+ # length = 2m
120
+ # width = 3m
121
+ #
122
+ # @param context_name [String] name of program writing a session attribute
123
+ # @param key [String] the key name of config directive to be written into the file
124
+ # @param value [String] value of the config directive to be written into the file
125
+ #
126
+ def write_keyvalue context_name, key, value
127
+
128
+ config_file_dir = get_filedir(context_name)
129
+ FileUtils.mkdir_p config_file_dir unless File.exists? config_file_dir
130
+ config_filepath = get_filepath(context_name)
131
+
132
+ config_map = IniFile.new( :filename => config_filepath, :encoding => 'UTF-8' )
133
+ config_map = IniFile.load( config_filepath ) if File.exists? config_filepath
134
+
135
+ config_map[context_name][key] = value
136
+ config_map.write
137
+
138
+ end
139
+
140
+
141
+ #
142
+ # Get the path to the session context file.
143
+ # This file will be in a folder whose name is simply the dot
144
+ # prefixed context_name. The session context file itself will
145
+ # be named using context_name + @@filename_tail
146
+ #
147
+ # @example ~/.openbox/openbox-session.ini is the filepath for context "openbox"
148
+ #
149
+ # @param context_name [String] name of program writing a session attribute
150
+ #
151
+ def get_filepath context_name
152
+
153
+ return File.join( get_filedir(context_name), "#{context_name}#{@@filename_tail}" )
154
+
155
+ end
156
+
157
+
158
+ #
159
+ # Get the directory that the session context file either does
160
+ # or will sit inside.
161
+ #
162
+ # The directory hangs off the home directory and is named simply
163
+ # as the dot prefixed context_name.
164
+ #
165
+ # @example ~/.openbox is the directory for context "openbox"
166
+ #
167
+ # @param context_name [String] name of program (or use case) context
168
+ #
169
+ def get_filedir context_name
170
+
171
+ return File.join home_directory, ".#{context_name}"
172
+
173
+ end
174
+
175
+
176
+ #
177
+ # On non-windows systems the home directory is defined
178
+ # perfectly by Ruby's Dir object.
179
+ #
180
+ # On Windows we sometimes get /AppData/Roaming appended
181
+ # onto the actual home directory. In these cases this
182
+ # method removes it.
183
+ #
184
+ def home_directory
185
+
186
+ return Dir.home unless Gem.win_platform?
187
+
188
+ extraneous_path = "/AppData/Roaming"
189
+ if Dir.home.end_with? extraneous_path then
190
+ return Dir.home.gsub( extraneous_path, "" )
191
+ end
192
+
193
+ return Dir.home
194
+
195
+ end
196
+
197
+
198
+ #
199
+ # Get the username of the logged in user. This name should
200
+ # not contain spaces (and should be just alphanumeric).
201
+ #
202
+ # The current implementation uses environment variables and
203
+ # crudely states that the username is
204
+ #
205
+ # - ENV['USERNAME'] for the Windows platform
206
+ # - ENV['USER'] for Linux (and everything else)
207
+ #
208
+ def username
209
+
210
+ return ENV['USERNAME'] if Gem.win_platform?
211
+ return ENV['USER']
212
+
213
+ end
214
+
215
+
216
+ end
217
+
218
+
219
+ end
@@ -0,0 +1,384 @@
1
+ #!/usr/bin/ruby
2
+
3
+ module OpenSession
4
+
5
+ require 'singleton'
6
+
7
+ #
8
+ # This stamp sits at the centre of a fundamental DevOps pattern concerned
9
+ # with infrastructure provisioning and configuraion management.
10
+ #
11
+ # The central idea behind the pattern is to link every infrastructure
12
+ # object created for an eco-system with an embedded reference that
13
+ # contains time stamps that are accurate to the nearest
14
+ #
15
+ # - month
16
+ # - day
17
+ # - hour of day
18
+ # - minute
19
+ # - second
20
+ # - tenth of second
21
+ # - hundredth of second
22
+ # - thousandth of second
23
+ #
24
+ # Which newly created or updated infrastructure objects are stamped?
25
+ #
26
+ # - files and folders
27
+ # - database user names
28
+ # - Docker containers
29
+ # - virtual machines
30
+ # - s3 buckets and their contents
31
+ # - aws ec2 machines
32
+ # - aws acl lists
33
+ # - hostnames and urls
34
+ #
35
+ class Stamp
36
+ include Singleton
37
+
38
+ attr_reader :time_now
39
+
40
+ #
41
+ # Return two digit [mo] month index from 01 to 12.
42
+ # @example 02 => in February
43
+ #
44
+ def self.mo
45
+ return Stamp.instance.time_now.strftime "%m"
46
+ end
47
+
48
+
49
+ #
50
+ # Return three character abbreviated month name.
51
+ # @example feb => in February
52
+ #
53
+ def self.mmm
54
+ return Stamp.instance.time_now.strftime( "%b" ).downcase
55
+ end
56
+
57
+
58
+ #
59
+ # Return three character abbreviated day of week.
60
+ # @example tue => on Tuesday
61
+ #
62
+ def self.ddd
63
+ return Stamp.instance.time_now.strftime( "%a" ).downcase
64
+ end
65
+
66
+
67
+ #
68
+ # Return two digit (character) hour of day from 00 to 23.
69
+ # @example 22 => between 22.00.00 and 22.59.59 inclusive
70
+ #
71
+ def self.hh
72
+ return Stamp.instance.time_now.strftime "%H"
73
+ end
74
+
75
+
76
+ #
77
+ # Return two digit minute of hour from [00] to [59].
78
+ #
79
+ def self.mm
80
+ return Stamp.instance.time_now.strftime "%M"
81
+ end
82
+
83
+
84
+ #
85
+ # Return two digit second of minute from [00] to [59].
86
+ #
87
+ def self.ss
88
+ return Stamp.instance.time_now.strftime "%S"
89
+ end
90
+
91
+
92
+ #
93
+ # Return a [3 digit] second and tenth of second
94
+ # representation.
95
+ #
96
+ # The final digit is derived from the 1000 sliced
97
+ # millisecond of second running from 000 to 999.
98
+ #
99
+ # ---------------------------
100
+ # Truncation (Not Rounding)
101
+ # ---------------------------
102
+ #
103
+ # The [final] digit is acquired by TRUNCATING
104
+ # (chopping off) the last 2 of the 3 millisecond
105
+ # digits. No rounding is applied.
106
+ #
107
+ # The 3 returned digits comprise of the
108
+ #
109
+ # - second of minute => 2 digits | [00] to [59] (and)
110
+ # - tenth of second => 1 digit from [0] to [9]
111
+ #
112
+ # ---------
113
+ # Example
114
+ # ---------
115
+ # => The time at the 562nd millisecond of the 49th
116
+ # second of the minute.
117
+ #
118
+ # => 3 chars
119
+ # => 495
120
+ #
121
+ #
122
+ def self.sst
123
+ millisec_string = Stamp.instance.time_now.strftime "%L"
124
+ return "#{ss}#{millisec_string[0]}"
125
+ end
126
+
127
+
128
+ #
129
+ # Return the [two] digit year (eg 19 for 2019).
130
+ # that we are currently in.
131
+ #
132
+ def self.yy
133
+ return Stamp.instance.time_now.strftime("%Y")[2..-1]
134
+ end
135
+
136
+
137
+ #
138
+ # Return the [four] digit year (eg 2019)
139
+ # that we are currently in.
140
+ #
141
+ def self.yyyy
142
+ return Stamp.instance.time_now.strftime("%Y")
143
+ end
144
+
145
+
146
+ # ------------------------------------------------- -- #
147
+ # Return 3 digit julian day of year [001] to [366]. -- #
148
+ # ------------------------------------------------- -- #
149
+ def self.jjj
150
+ return Stamp.instance.time_now.strftime "%j"
151
+ end
152
+
153
+
154
+ #
155
+ # [yymo_mmm] returns an amalgam of
156
+ #
157
+ # => the two-digit year
158
+ # => the two-digit month index (starting at 01)
159
+ # => a period (separator)
160
+ # => the abbreviated month name
161
+ #
162
+ # ---------
163
+ # Example
164
+ # ---------
165
+ # => 1908.aug
166
+ # => for August 2019
167
+ #
168
+ def self.yymo_mmm
169
+ return "#{yy}#{mo}.#{mmm}"
170
+ end
171
+
172
+
173
+ #
174
+ # Given two integer parameters (month index and 4 digit year) representing
175
+ # the month in question this method returns the [PREVIOUS MONTHS] character
176
+ # amalgam in the format [yymo_mmm] where
177
+ #
178
+ # => yy | previous month's two-digit year
179
+ # => mo | previous month's two-digit month index
180
+ # => . | a period (separator)
181
+ # => mmm | previous month's abbreviated month name
182
+ #
183
+ # -------------------
184
+ # Example 1 (Simple)
185
+ # -------------------
186
+ #
187
+ # returns char => 1907.jul
188
+ # 4 parameters => 8, 2019
189
+ # representing => August, 2019
190
+ #
191
+ # ----------------------
192
+ # Example 2 (Last Year)
193
+ # ----------------------
194
+ #
195
+ # returns char => 1812.dec
196
+ # 4 parameters => 1, 2019
197
+ # representing => January, 2019
198
+ #
199
+ def self.previous_month_chars this_month_index, this_4digit_year
200
+
201
+ prev_month_index = this_month_index == 1 ? 12 : ( this_month_index - 1 )
202
+ prev_2dig_mn_pad = sprintf '%02d', prev_month_index
203
+ prev_4digit_year = this_month_index == 1 ? ( this_4digit_year - 1 ) : this_4digit_year
204
+ prev_twodigit_yr = "#{prev_4digit_year.to_s}"[2..-1]
205
+ prev_months_name = Date::ABBR_MONTHNAMES[prev_month_index].downcase
206
+
207
+ return "#{prev_twodigit_yr}#{prev_2dig_mn_pad}.#{prev_months_name}"
208
+
209
+ end
210
+
211
+ #
212
+ # Using the current class time this method returns
213
+ # the character amalgam for the [PREVIOUS MONTH] in
214
+ # the format [yymo_mmm] where
215
+ #
216
+ # => yy | last month's two-digit year
217
+ # => mo | last month's two-digit month index
218
+ # => . | a period (separator)
219
+ # => mmm | last month's abbreviated month name
220
+ #
221
+ # -------------------
222
+ # Example 1 (Simple)
223
+ # -------------------
224
+ #
225
+ # returns => 1907.jul
226
+ # if this month is => August 2019
227
+ #
228
+ # ----------------------
229
+ # Example 2 (Last Year)
230
+ # ----------------------
231
+ #
232
+ # returns => 1812.dec
233
+ # if this month is => January 2019
234
+ #
235
+ def self.yymo_mmm_prev
236
+ return previous_month_chars mo.to_i, yyyy.to_i
237
+ end
238
+
239
+
240
+ # ---------------------------------------------- -- #
241
+ # Return 5 digit amalgam of year and julian day. -- #
242
+ # eg [19003] for [January 3rd 2019] -- #
243
+ # ---------------------------------------------- -- #
244
+ def self.yyjjj
245
+ return "#{yy}#{jjj}"
246
+ end
247
+
248
+
249
+ #
250
+ # Return the 4 digit amalgam of the hour and minute
251
+ # using the 24 hour clock.
252
+ #
253
+ # ---------
254
+ # Example
255
+ # ---------
256
+ # => 1525
257
+ # => 03:25 pm
258
+ #
259
+ def self.hhmm
260
+ return "#{hh}#{mm}"
261
+ end
262
+
263
+
264
+ #
265
+ # Return the time of day to a TENTH of a second accuracy.
266
+ # [8] characters will always be returned with the 5th one
267
+ # being the (period) separator.
268
+ #
269
+ # The first (separated) segment delivers a hhmm 24 hour
270
+ # clock representation of the stamped time.
271
+ #
272
+ # The 3 digits of the second segment comprise of
273
+ #
274
+ # second of minute => 2 digits | [00] to [59]
275
+ # tenth of second => 1 digit from [0] to [9]
276
+ #
277
+ # ---------
278
+ # Example
279
+ # ---------
280
+ # => The time at the 562nd millisecond of the 49th
281
+ # second of the 23rd minute of the 17th hour of
282
+ # the day ( 17:23:49.562 )
283
+ #
284
+ # => 8 chars
285
+ # => 1723.495
286
+ #
287
+ def self.hhmm_sst
288
+ return "#{hhmm}.#{sst}"
289
+ end
290
+
291
+
292
+ #
293
+ # Return a period separated amalgam of the
294
+ #
295
+ # => 2 digit year and 3 digit julian day
296
+ # => 4 digit hour/minute
297
+ #
298
+ # ---------
299
+ # Example
300
+ # ---------
301
+ # => 19003.1025
302
+ # => 10:25 am on January 3rd 2019
303
+ #
304
+ #
305
+ # Return the time of day to a TENTH of a second accuracy.
306
+ # [8] characters will always be returned with the 5th one
307
+ # being the (period) separator.
308
+ #
309
+ # The first (separated) segment delivers a hhmm 24 hour
310
+ # clock representation of the stamped time.
311
+ #
312
+ # The 3 digits of the second segment comprise of
313
+ #
314
+ # second of minute => 2 digits | [00] to [59]
315
+ # tenth of second => 1 digit from [0] to [9]
316
+ #
317
+ # ---------
318
+ # Example
319
+ # ---------
320
+ # => The time at the 562nd millisecond of the 49th
321
+ # second of the 23rd minute of the 17th hour of
322
+ # the day ( 17:23:49.562 )
323
+ #
324
+ # => 8 chars
325
+ # => 1723.495
326
+ #
327
+ def self.yyjjj_hhmm_sst
328
+ return "#{yyjjj}.#{hhmm}.#{sst}"
329
+ end
330
+
331
+
332
+ # ----------------------------------------- -- #
333
+ # Return the Rubyfied time zone being used. -- #
334
+ # ----------------------------------------- -- #
335
+ def self.zone
336
+ return Stamp.instance.time_now.zone
337
+ end
338
+
339
+
340
+ # -------------------------------------------------- -- #
341
+ # Log segments of time pertaining to the time stamp. -- #
342
+ # -------------------------------------------------- -- #
343
+ def self.log_instance_time
344
+
345
+ log.info(ere) { "[stamp] -------------- => -------------------------------- #" }
346
+ log.info(ere) { "[stamp] eco time stamp => [#{Stamp.instance.time_now.ctime}]" }
347
+ log.info(ere) { "[stamp] -------------- => -------------------------------- #" }
348
+ log.info(ere) { "[stamp] Univ Time Zone => #{zone}" }
349
+ log.info(ere) { "[stamp] Month Index is => #{mo}" }
350
+ log.info(ere) { "[stamp] Month Name is => #{mmm}" }
351
+ log.info(ere) { "[stamp] Day Of Week is => #{ddd}" }
352
+ log.info(ere) { "[stamp] -------------- => -------------------------------- #" }
353
+ log.info(ere) { "[stamp] Two Digit Year => #{yy}" }
354
+ log.info(ere) { "[stamp] Julian Cal Day => #{jjj}" }
355
+ log.info(ere) { "[stamp] Yr and Jul Day => #{yyjjj}" }
356
+ log.info(ere) { "[stamp] Hour of Theday => #{hh}" }
357
+ log.info(ere) { "[stamp] Minute of Hour => #{mm}" }
358
+ log.info(ere) { "[stamp] Hour + Minute => #{hhmm}" }
359
+ log.info(ere) { "[stamp] Second of Min => #{ss}" }
360
+ log.info(ere) { "[stamp] 600 Min Slices => #{sst}" }
361
+ log.info(ere) { "[stamp] -------------- => -------------------------------- #" }
362
+ log.info(ere) { "[stamp] The Time Stamp => #{yyjjj_hhmm_sst}" }
363
+ log.info(ere) { "[stamp] -------------- => -------------------------------- #" }
364
+
365
+ end
366
+
367
+
368
+ # ------------------------------------------------------------ -- #
369
+ # This singleton (one instance) class sets the time just once. -- #
370
+ # ------------------------------------------------------------ -- #
371
+ def initialize
372
+
373
+ @time_now = Time.now;
374
+
375
+ end
376
+
377
+
378
+ ############ Stamp.log_instance_time
379
+
380
+
381
+ end
382
+
383
+
384
+ end
@@ -1,3 +1,3 @@
1
1
  module OpenSecret
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.913"
3
3
  end
@@ -1,8 +1,7 @@
1
1
  lib = File.expand_path("../lib", __FILE__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
- require 'opensecret/version'
5
- require 'opensecret/delegate'
4
+ require 'version'
6
5
 
7
6
  Gem::Specification.new do |spec|
8
7
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opensecret
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.913
5
5
  platform: ruby
6
6
  authors:
7
7
  - Apollo Akora
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-10 00:00:00.000000000 Z
11
+ date: 2018-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inifile
@@ -108,7 +108,6 @@ files:
108
108
  - lib/opensecret/commons/eco.faculty.rb
109
109
  - lib/opensecret/commons/eco.system.rb
110
110
  - lib/opensecret/commons/eco.systems.rb
111
- - lib/opensecret/delegate.rb
112
111
  - lib/opensecret/eco.do.rb
113
112
  - lib/opensecret/executors/crypt.keys/crypt.keys.ini
114
113
  - lib/opensecret/executors/crypt.keys/crypt.keys.rb
@@ -135,8 +134,9 @@ files:
135
134
  - lib/opensecret/plugins.io/git/git.flow.rb
136
135
  - lib/opensecret/plugins.io/logs/log.object.rb
137
136
  - lib/opensecret/plugins.io/logs/logging.rb
138
- - lib/opensecret/plugins.io/time/time.stamp.rb
139
- - lib/opensecret/version.rb
137
+ - lib/session/session.rb
138
+ - lib/session/time.stamp.rb
139
+ - lib/version.rb
140
140
  - opensecret.gemspec
141
141
  homepage: https://www.eco-platform.co.uk
142
142
  licenses:
@@ -1,20 +0,0 @@
1
-
2
- module OpenSecret
3
-
4
- class Delegate
5
-
6
- def command
7
-
8
- return "hello world"
9
-
10
- time = Time.now
11
- minute = time.min
12
- hour = time.hour % 12
13
- meridian_indicator = time.hour < 12 ? 'AM' : 'PM'
14
- "You locked me at #{minute} minutes past #{hour} o'clock, #{meridian_indicator}"
15
-
16
- end
17
-
18
- end
19
-
20
- end
@@ -1,425 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- # -- ----------------------------------------------------------------- -- #
4
- # -- the eco stamp -- #
5
- # -- ---------------------------------------------------------- -- #
6
- # -- -- #
7
- # -- The eco-system stamp is at the centre of a fundamental iaas pattern. -- #
8
- # -- known as the "infrastructure provisioning reference pattern (iprp)". -- #
9
- # -- The central idea behind the pattern is to link every infrastructure -- #
10
- # -- object created for an eco-system with an embedded reference that -- #
11
- # -- contains a "minute accurate" time. -- #
12
- # -- -- #
13
- # -- ---------------------------------------------------------- -- #
14
- # -- which infrastructure [objects] are eco-stamped? -- #
15
- # -- ---------------------------------------------------------- -- #
16
- # -- eco-system stamps are used when referencing provisioned -- #
17
- # -- - files and folders -- #
18
- # -- - database user names -- #
19
- # -- - Docker containers -- #
20
- # -- - virtual machines -- #
21
- # -- - s3 buckets and their contents -- #
22
- # -- - aws ec2 machines -- #
23
- # -- - aws acl lists -- #
24
- # -- - hostnames and urls -- #
25
- # --
26
- # -- --------------------------
27
- # -- the eco-stamp [segments]
28
- # -- --------------------------
29
- # --
30
- # -- Typical eco-system stamps comprise of a few of the [segments] that
31
- # -- are listed below. Periods (and at times underscores) are used to
32
- # -- delineate each segment.
33
- # --
34
- # -- | mo | months index | from 01 to 12 | 2 |
35
- # -- | mmm | abbrv month name | eg feb | 3 |
36
- # -- | ddd | abbrv day of week | eg tue | 3 |
37
- # -- | yy | two digit year | eg 19 for 2019 | 2 |
38
- # -- | jjj | julian day | from 001 to 366 | 3 |
39
- # -- | hh | hour of day | from 001 to 366 | 2 |
40
- # -- | mm | minute of hour | from 00 to 59 | 2 |
41
- # --
42
- # -- -----------------------------------
43
- # -- eco-stamp [prefix] and [postfix]
44
- # -- -----------------------------------
45
- # --
46
- # -- eco stamps are not just about time. Yes time is at the core but
47
- # -- the eco reference will usually be pre or post-fixed with
48
- # --
49
- # -- - an eco plugin descriptor
50
- # -- - a repository [revision]
51
- # -- - the executors [username]
52
- # -- - the machine's [hostname]
53
- # -- - middleware service name
54
- # --
55
- class Stamp
56
- include Singleton
57
-
58
- attr_reader :time_now
59
-
60
- # --
61
- # -- Return two digit [mo] month index from [01] to [12].
62
- # --
63
- def self.mo
64
- return Stamp.instance.time_now.strftime "%m"
65
- end
66
-
67
-
68
- # -- ------------------------------------------------------- -- #
69
- # -- Return three character abbreviated month name (eg feb). -- #
70
- # -- ------------------------------------------------------- -- #
71
- def self.mmm
72
- return Stamp.instance.time_now.strftime( "%b" ).downcase
73
- end
74
-
75
-
76
- # -- -------------------------------------------------------- -- #
77
- # -- Return three character abbreviated day of week (eg wed). -- #
78
- # -- -------------------------------------------------------- -- #
79
- def self.ddd
80
- return Stamp.instance.time_now.strftime( "%a" ).downcase
81
- end
82
-
83
-
84
- # --
85
- # -- Return two digit hour of day from [00] to [23].
86
- # --
87
- def self.hh
88
- return Stamp.instance.time_now.strftime "%H"
89
- end
90
-
91
-
92
- # --
93
- # -- Return two digit minute of hour from [00] to [59].
94
- # --
95
- def self.mm
96
- return Stamp.instance.time_now.strftime "%M"
97
- end
98
-
99
-
100
- # --
101
- # -- Return two digit second of minute from [00] to [59].
102
- # --
103
- def self.ss
104
- return Stamp.instance.time_now.strftime "%S"
105
- end
106
-
107
-
108
- # --
109
- # -- Return a [3 digit] second and tenth of second
110
- # -- representation.
111
- # --
112
- # -- The final digit is derived from the 1000 sliced
113
- # -- millisecond of second running from 000 to 999.
114
- # --
115
- # -- ---------------------------
116
- # -- Truncation (Not Rounding)
117
- # -- ---------------------------
118
- # --
119
- # -- The [final] digit is acquired by TRUNCATING
120
- # -- (chopping off) the last 2 of the 3 millisecond
121
- # -- digits. No rounding is applied.
122
- # --
123
- # -- The 3 returned digits comprise of the
124
- # --
125
- # -- - second of minute => 2 digits | [00] to [59] (and)
126
- # -- - tenth of second => 1 digit from [0] to [9]
127
- # --
128
- # -- ---------
129
- # -- Example
130
- # -- ---------
131
- # -- => The time at the 562nd millisecond of the 49th
132
- # -- second of the minute.
133
- # --
134
- # -- => 3 chars
135
- # -- => 495
136
- # --
137
- # --
138
- def self.sst
139
- millisec_string = Stamp.instance.time_now.strftime "%L"
140
- return "#{ss}#{millisec_string[0]}"
141
- end
142
-
143
-
144
- # --
145
- # -- Return the [two] digit year (eg 19 for 2019).
146
- # -- that we are currently in.
147
- # --
148
- def self.yy
149
- return Stamp.instance.time_now.strftime("%Y")[2..-1]
150
- end
151
-
152
-
153
- # --
154
- # -- Return the [four] digit year (eg 2019)
155
- # -- that we are currently in.
156
- # --
157
- def self.yyyy
158
- return Stamp.instance.time_now.strftime("%Y")
159
- end
160
-
161
-
162
- # -- ------------------------------------------------- -- #
163
- # -- Return 3 digit julian day of year [001] to [366]. -- #
164
- # -- ------------------------------------------------- -- #
165
- def self.jjj
166
- return Stamp.instance.time_now.strftime "%j"
167
- end
168
-
169
-
170
- # --
171
- # -- [yymo_mmm] returns an amalgam of
172
- # --
173
- # -- => the two-digit year
174
- # -- => the two-digit month index (starting at 01)
175
- # -- => a period (separator)
176
- # -- => the abbreviated month name
177
- # --
178
- # -- ---------
179
- # -- Example
180
- # -- ---------
181
- # -- => 1908.aug
182
- # -- => for August 2019
183
- # --
184
- def self.yymo_mmm
185
- return "#{yy}#{mo}.#{mmm}"
186
- end
187
-
188
-
189
- # --
190
- # -- Given two integer parameters (month index and 4 digit year) representing
191
- # -- the month in question this method returns the [PREVIOUS MONTHS] character
192
- # -- amalgam in the format [yymo_mmm] where
193
- # --
194
- # -- => yy | previous month's two-digit year
195
- # -- => mo | previous month's two-digit month index
196
- # -- => . | a period (separator)
197
- # -- => mmm | previous month's abbreviated month name
198
- # --
199
- # -- -------------------
200
- # -- Example 1 (Simple)
201
- # -- -------------------
202
- # --
203
- # -- returns char => 1907.jul
204
- # -- 4 parameters => 8, 2019
205
- # -- representing => August, 2019
206
- # --
207
- # -- ----------------------
208
- # -- Example 2 (Last Year)
209
- # -- ----------------------
210
- # --
211
- # -- returns char => 1812.dec
212
- # -- 4 parameters => 1, 2019
213
- # -- representing => January, 2019
214
- # --
215
- def self.previous_month_chars this_month_index, this_4digit_year
216
-
217
- prev_month_index = this_month_index == 1 ? 12 : ( this_month_index - 1 )
218
- prev_2dig_mn_pad = sprintf '%02d', prev_month_index
219
- prev_4digit_year = this_month_index == 1 ? ( this_4digit_year - 1 ) : this_4digit_year
220
- prev_twodigit_yr = "#{prev_4digit_year.to_s}"[2..-1]
221
- prev_months_name = Date::ABBR_MONTHNAMES[prev_month_index].downcase
222
-
223
- return "#{prev_twodigit_yr}#{prev_2dig_mn_pad}.#{prev_months_name}"
224
-
225
- end
226
-
227
- # --
228
- # -- Using the current class time this method returns
229
- # -- the character amalgam for the [PREVIOUS MONTH] in
230
- # -- the format [yymo_mmm] where
231
- # --
232
- # -- => yy | last month's two-digit year
233
- # -- => mo | last month's two-digit month index
234
- # -- => . | a period (separator)
235
- # -- => mmm | last month's abbreviated month name
236
- # --
237
- # -- -------------------
238
- # -- Example 1 (Simple)
239
- # -- -------------------
240
- # --
241
- # -- returns => 1907.jul
242
- # -- if this month is => August 2019
243
- # --
244
- # -- ----------------------
245
- # -- Example 2 (Last Year)
246
- # -- ----------------------
247
- # --
248
- # -- returns => 1812.dec
249
- # -- if this month is => January 2019
250
- # --
251
- def self.yymo_mmm_prev
252
- return previous_month_chars mo.to_i, yyyy.to_i
253
- end
254
-
255
-
256
- # -- ---------------------------------------------- -- #
257
- # -- Return 5 digit amalgam of year and julian day. -- #
258
- # -- eg [19003] for [January 3rd 2019] -- #
259
- # -- ---------------------------------------------- -- #
260
- def self.yyjjj
261
- return "#{yy}#{jjj}"
262
- end
263
-
264
-
265
- # --
266
- # -- Return the 4 digit amalgam of the hour and minute
267
- # -- using the 24 hour clock.
268
- # --
269
- # -- ---------
270
- # -- Example
271
- # -- ---------
272
- # -- => 1525
273
- # -- => 03:25 pm
274
- # --
275
- def self.hhmm
276
- return "#{hh}#{mm}"
277
- end
278
-
279
-
280
- # --
281
- # -- Return the time of day to a TENTH of a second accuracy.
282
- # -- [8] characters will always be returned with the 5th one
283
- # -- being the (period) separator.
284
- # --
285
- # -- The first (separated) segment delivers a hhmm 24 hour
286
- # -- clock representation of the stamped time.
287
- # --
288
- # -- The 3 digits of the second segment comprise of
289
- # --
290
- # -- second of minute => 2 digits | [00] to [59]
291
- # -- tenth of second => 1 digit from [0] to [9]
292
- # --
293
- # -- ---------
294
- # -- Example
295
- # -- ---------
296
- # -- => The time at the 562nd millisecond of the 49th
297
- # -- second of the 23rd minute of the 17th hour of
298
- # -- the day ( 17:23:49.562 )
299
- # --
300
- # -- => 8 chars
301
- # -- => 1723.495
302
- # --
303
- def self.hhmm_sst
304
- return "#{hhmm}.#{sst}"
305
- end
306
-
307
-
308
- # --
309
- # -- Return a period separated amalgam of the
310
- # --
311
- # -- => 2 digit year and 3 digit julian day
312
- # -- => 4 digit hour/minute
313
- # --
314
- # -- ---------
315
- # -- Example
316
- # -- ---------
317
- # -- => 19003.1025
318
- # -- => 10:25 am on January 3rd 2019
319
- # --
320
- # --
321
- # -- Return the time of day to a TENTH of a second accuracy.
322
- # -- [8] characters will always be returned with the 5th one
323
- # -- being the (period) separator.
324
- # --
325
- # -- The first (separated) segment delivers a hhmm 24 hour
326
- # -- clock representation of the stamped time.
327
- # --
328
- # -- The 3 digits of the second segment comprise of
329
- # --
330
- # -- second of minute => 2 digits | [00] to [59]
331
- # -- tenth of second => 1 digit from [0] to [9]
332
- # --
333
- # -- ---------
334
- # -- Example
335
- # -- ---------
336
- # -- => The time at the 562nd millisecond of the 49th
337
- # -- second of the 23rd minute of the 17th hour of
338
- # -- the day ( 17:23:49.562 )
339
- # --
340
- # -- => 8 chars
341
- # -- => 1723.495
342
- # --
343
- def self.yyjjj_hhmm_sst
344
- return "#{yyjjj}.#{hhmm}.#{sst}"
345
- end
346
-
347
-
348
- # -- ----------------------------------------- -- #
349
- # -- Return the Rubyfied time zone being used. -- #
350
- # -- ----------------------------------------- -- #
351
- def self.zone
352
- return Stamp.instance.time_now.zone
353
- end
354
-
355
-
356
- # -- -------------------------------------------------- -- #
357
- # -- Log segments of time pertaining to the time stamp. -- #
358
- # -- -------------------------------------------------- -- #
359
- def self.log_instance_time
360
-
361
- log.info(ere) { "[stamp] -------------- => -------------------------------- #" }
362
- log.info(ere) { "[stamp] eco time stamp => [#{Stamp.instance.time_now.ctime}]" }
363
- log.info(ere) { "[stamp] -------------- => -------------------------------- #" }
364
- log.info(ere) { "[stamp] Univ Time Zone => #{zone}" }
365
- log.info(ere) { "[stamp] Month Index is => #{mo}" }
366
- log.info(ere) { "[stamp] Month Name is => #{mmm}" }
367
- log.info(ere) { "[stamp] Day Of Week is => #{ddd}" }
368
- log.info(ere) { "[stamp] -------------- => -------------------------------- #" }
369
- log.info(ere) { "[stamp] Two Digit Year => #{yy}" }
370
- log.info(ere) { "[stamp] Julian Cal Day => #{jjj}" }
371
- log.info(ere) { "[stamp] Yr and Jul Day => #{yyjjj}" }
372
- log.info(ere) { "[stamp] Hour of Theday => #{hh}" }
373
- log.info(ere) { "[stamp] Minute of Hour => #{mm}" }
374
- log.info(ere) { "[stamp] Hour + Minute => #{hhmm}" }
375
- log.info(ere) { "[stamp] Second of Min => #{ss}" }
376
- log.info(ere) { "[stamp] 600 Min Slices => #{sst}" }
377
- log.info(ere) { "[stamp] -------------- => -------------------------------- #" }
378
- log.info(ere) { "[stamp] The Time Stamp => #{yyjjj_hhmm_sst}" }
379
- log.info(ere) { "[stamp] -------------- => -------------------------------- #" }
380
-
381
- end
382
-
383
-
384
- # -- ------------------------------------------------------------ -- #
385
- # -- This singleton (one instance) class sets the time just once. -- #
386
- # -- ------------------------------------------------------------ -- #
387
- def initialize
388
-
389
- @time_now = Time.now;
390
-
391
- end
392
-
393
-
394
- # --
395
- # -- This method tests the previous month behaviour.
396
- # -- Simply set the year index to the desired integer and roll.
397
- # --
398
- # -- Example Call
399
- # --
400
- # -- Stamp.test_previous_month 2015
401
- # --
402
- def self.test_previous_month year_index
403
-
404
- month_index = 1
405
-
406
- log.info(ere) { "This Month Char Amalgam => #{yymo_mmm}" }
407
- log.info(ere) { "Prev Month Char Amalgam => #{yymo_mmm_prev}" }
408
-
409
- until month_index == 13 do
410
- prev_month_chars = Stamp.previous_month_chars month_index, year_index
411
- log.info(ere) { "Char Amalgam | #{prev_month_chars} => month #{month_index} | year #{year_index}" }
412
- month_index +=1
413
- end
414
-
415
- end
416
-
417
-
418
- # -- -------------------------------------------------------------------- -- #
419
- # -- [Cold Call Pattern] - If class has no [internal] dependencies it can -- #
420
- # -- initialize itself ignoring any require [order] -- #
421
- # -- -------------------------------------------------------------------- -- #
422
- Stamp.log_instance_time
423
- Stamp.test_previous_month yyyy.to_i
424
-
425
- end