neetob 0.4.33 → 0.4.34

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
  SHA256:
3
- metadata.gz: d832b3f555d9e9776dcfb2645f93023a9d43f4845df6ee63c85742878aa85a6d
4
- data.tar.gz: f573e47a3669da7ee284fb2fa6bc03f39e355279b66b06b350d1c3583ccf4f15
3
+ metadata.gz: 78e73a253fbab45e8cd147b1a783421486613b2818edc38ab6048fe54b6e43d3
4
+ data.tar.gz: '0868e84a96f5f912dff66d7dbeef750f3fed0e60da492224e4467dbb963f3e92'
5
5
  SHA512:
6
- metadata.gz: db03c80217f2ea428fc801d47612aaee5a7dc03a1f952c034b712a58a92e73e3779bbf3d1ef70cf9fd3543e40404117d3683ae31d3815ff5708edbb33bd70e26
7
- data.tar.gz: 0de813b09a1ecd3b73526c6579a968f4736a8c335dea39448697e006a2dc8f0bc5d99b5758fbfee72bac14e4aab99cce92624af3138b89b41b7f10d407516dc1
6
+ metadata.gz: 21f07001d1aefde155e8896c94fbe598c906be486402d08a598702c2c7d37862125800eda6a67c85c8a52a6bd9b6db238a2eb4617404a7cb94fea9d1b402361d
7
+ data.tar.gz: 7de4699f76ef98e7ef33aa508ad0db92ba7c86ea89b24bb31f7dcb132a7ac6ddc58c33987692ddbcf418401ee9951bd35c37418feb2ef477e7d3bbadcaf128a2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- neetob (0.4.33)
4
+ neetob (0.4.34)
5
5
  brakeman (~> 5.0)
6
6
  chronic
7
7
  dotenv (~> 2.8.1)
@@ -15,13 +15,18 @@ PATH
15
15
  GEM
16
16
  remote: https://O6Ts9-SVDaUZpHMRs2CpJp22RwbETDE@gems.neeto.com/
17
17
  specs:
18
- neeto-commons-backend (1.0.272)
18
+ neeto-commons-backend (1.6.42)
19
19
  actionview
20
20
  bullet
21
+ colorize
21
22
  database_cleaner
22
23
  honeybadger
23
- kaminari
24
+ htmlentities
25
+ intercom-rails
26
+ mixpanel-ruby
27
+ multipart-post
24
28
  omniauth-google-oauth2
29
+ pagy
25
30
  premailer-rails
26
31
  public_suffix
27
32
  pundit
@@ -32,9 +37,11 @@ GEM
32
37
  rails_email_preview
33
38
  rake
34
39
  redis
40
+ rinku
35
41
  sidekiq
36
42
  sidekiq-cron
37
43
  sidekiq-failures
44
+ solid_cache
38
45
  webmock
39
46
  neeto-compliance (1.1.114)
40
47
  colorize
@@ -45,78 +52,89 @@ GEM
45
52
  GEM
46
53
  remote: https://rubygems.org/
47
54
  specs:
48
- actioncable (7.0.8.1)
49
- actionpack (= 7.0.8.1)
50
- activesupport (= 7.0.8.1)
55
+ actioncable (7.1.3.4)
56
+ actionpack (= 7.1.3.4)
57
+ activesupport (= 7.1.3.4)
51
58
  nio4r (~> 2.0)
52
59
  websocket-driver (>= 0.6.1)
53
- actionmailbox (7.0.8.1)
54
- actionpack (= 7.0.8.1)
55
- activejob (= 7.0.8.1)
56
- activerecord (= 7.0.8.1)
57
- activestorage (= 7.0.8.1)
58
- activesupport (= 7.0.8.1)
60
+ zeitwerk (~> 2.6)
61
+ actionmailbox (7.1.3.4)
62
+ actionpack (= 7.1.3.4)
63
+ activejob (= 7.1.3.4)
64
+ activerecord (= 7.1.3.4)
65
+ activestorage (= 7.1.3.4)
66
+ activesupport (= 7.1.3.4)
59
67
  mail (>= 2.7.1)
60
68
  net-imap
61
69
  net-pop
62
70
  net-smtp
63
- actionmailer (7.0.8.1)
64
- actionpack (= 7.0.8.1)
65
- actionview (= 7.0.8.1)
66
- activejob (= 7.0.8.1)
67
- activesupport (= 7.0.8.1)
71
+ actionmailer (7.1.3.4)
72
+ actionpack (= 7.1.3.4)
73
+ actionview (= 7.1.3.4)
74
+ activejob (= 7.1.3.4)
75
+ activesupport (= 7.1.3.4)
68
76
  mail (~> 2.5, >= 2.5.4)
69
77
  net-imap
70
78
  net-pop
71
79
  net-smtp
72
- rails-dom-testing (~> 2.0)
73
- actionpack (7.0.8.1)
74
- actionview (= 7.0.8.1)
75
- activesupport (= 7.0.8.1)
76
- rack (~> 2.0, >= 2.2.4)
80
+ rails-dom-testing (~> 2.2)
81
+ actionpack (7.1.3.4)
82
+ actionview (= 7.1.3.4)
83
+ activesupport (= 7.1.3.4)
84
+ nokogiri (>= 1.8.5)
85
+ racc
86
+ rack (>= 2.2.4)
87
+ rack-session (>= 1.0.1)
77
88
  rack-test (>= 0.6.3)
78
- rails-dom-testing (~> 2.0)
79
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
80
- actiontext (7.0.8.1)
81
- actionpack (= 7.0.8.1)
82
- activerecord (= 7.0.8.1)
83
- activestorage (= 7.0.8.1)
84
- activesupport (= 7.0.8.1)
89
+ rails-dom-testing (~> 2.2)
90
+ rails-html-sanitizer (~> 1.6)
91
+ actiontext (7.1.3.4)
92
+ actionpack (= 7.1.3.4)
93
+ activerecord (= 7.1.3.4)
94
+ activestorage (= 7.1.3.4)
95
+ activesupport (= 7.1.3.4)
85
96
  globalid (>= 0.6.0)
86
97
  nokogiri (>= 1.8.5)
87
- actionview (7.0.8.1)
88
- activesupport (= 7.0.8.1)
98
+ actionview (7.1.3.4)
99
+ activesupport (= 7.1.3.4)
89
100
  builder (~> 3.1)
90
- erubi (~> 1.4)
91
- rails-dom-testing (~> 2.0)
92
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
93
- activejob (7.0.8.1)
94
- activesupport (= 7.0.8.1)
101
+ erubi (~> 1.11)
102
+ rails-dom-testing (~> 2.2)
103
+ rails-html-sanitizer (~> 1.6)
104
+ activejob (7.1.3.4)
105
+ activesupport (= 7.1.3.4)
95
106
  globalid (>= 0.3.6)
96
- activemodel (7.0.8.1)
97
- activesupport (= 7.0.8.1)
98
- activerecord (7.0.8.1)
99
- activemodel (= 7.0.8.1)
100
- activesupport (= 7.0.8.1)
101
- activestorage (7.0.8.1)
102
- actionpack (= 7.0.8.1)
103
- activejob (= 7.0.8.1)
104
- activerecord (= 7.0.8.1)
105
- activesupport (= 7.0.8.1)
107
+ activemodel (7.1.3.4)
108
+ activesupport (= 7.1.3.4)
109
+ activerecord (7.1.3.4)
110
+ activemodel (= 7.1.3.4)
111
+ activesupport (= 7.1.3.4)
112
+ timeout (>= 0.4.0)
113
+ activestorage (7.1.3.4)
114
+ actionpack (= 7.1.3.4)
115
+ activejob (= 7.1.3.4)
116
+ activerecord (= 7.1.3.4)
117
+ activesupport (= 7.1.3.4)
106
118
  marcel (~> 1.0)
107
- mini_mime (>= 1.1.0)
108
- activesupport (7.0.8.1)
119
+ activesupport (7.1.3.4)
120
+ base64
121
+ bigdecimal
109
122
  concurrent-ruby (~> 1.0, >= 1.0.2)
123
+ connection_pool (>= 2.2.5)
124
+ drb
110
125
  i18n (>= 1.6, < 2)
111
126
  minitest (>= 5.1)
127
+ mutex_m
112
128
  tzinfo (~> 2.0)
113
129
  addressable (2.8.6)
114
130
  public_suffix (>= 2.0.2, < 6.0)
115
131
  ansi (1.5.0)
116
132
  ast (2.4.2)
133
+ base64 (0.2.0)
134
+ bigdecimal (3.1.8)
117
135
  brakeman (5.4.1)
118
- builder (3.2.4)
119
- bullet (7.1.1)
136
+ builder (3.3.0)
137
+ bullet (7.1.6)
120
138
  activesupport (>= 3.0.0)
121
139
  uniform_notifier (~> 1.11)
122
140
  byebug (11.1.3)
@@ -124,12 +142,12 @@ GEM
124
142
  chronic (0.10.2)
125
143
  coderay (1.1.3)
126
144
  colorize (1.1.0)
127
- concurrent-ruby (1.2.3)
145
+ concurrent-ruby (1.3.1)
128
146
  connection_pool (2.4.1)
129
147
  crack (0.4.5)
130
148
  rexml
131
149
  crass (1.0.6)
132
- css_parser (1.16.0)
150
+ css_parser (1.17.1)
133
151
  addressable
134
152
  database_cleaner (2.0.2)
135
153
  database_cleaner-active_record (>= 2, < 3)
@@ -140,8 +158,9 @@ GEM
140
158
  date (3.3.4)
141
159
  docile (1.4.0)
142
160
  dotenv (2.8.1)
161
+ drb (2.2.1)
143
162
  erubi (1.12.0)
144
- et-orbi (1.2.7)
163
+ et-orbi (1.2.11)
145
164
  tzinfo
146
165
  event_emitter (0.2.6)
147
166
  faraday (2.7.1)
@@ -150,9 +169,11 @@ GEM
150
169
  faraday-net_http (3.0.2)
151
170
  faraday-retry (2.0.0)
152
171
  faraday (~> 2.0)
153
- ffi (1.16.3)
154
- fugit (1.8.1)
155
- et-orbi (~> 1, >= 1.2.7)
172
+ ffi (1.17.0)
173
+ ffi (1.17.0-x86_64-darwin)
174
+ ffi (1.17.0-x86_64-linux-gnu)
175
+ fugit (1.11.0)
176
+ et-orbi (~> 1, >= 1.2.11)
156
177
  raabro (~> 1.4)
157
178
  fury (0.0.1)
158
179
  globalid (1.2.1)
@@ -160,28 +181,23 @@ GEM
160
181
  hash-deep-merge (0.1.1)
161
182
  hashdiff (1.1.0)
162
183
  hashie (5.0.0)
163
- honeybadger (5.2.1)
184
+ honeybadger (5.13.0)
164
185
  htmlentities (4.3.4)
165
186
  httparty (0.21.0)
166
187
  mini_mime (>= 1.0.0)
167
188
  multi_xml (>= 0.5.2)
168
- i18n (1.14.1)
189
+ i18n (1.14.5)
169
190
  concurrent-ruby (~> 1.0)
170
191
  iniparse (1.5.0)
192
+ intercom-rails (1.0.1)
193
+ activesupport (> 4.0)
194
+ io-console (0.7.2)
195
+ irb (1.13.1)
196
+ rdoc (>= 4.0.0)
197
+ reline (>= 0.4.2)
171
198
  json (2.6.3)
172
- jwt (2.7.1)
173
- kaminari (1.2.2)
174
- activesupport (>= 4.1.0)
175
- kaminari-actionview (= 1.2.2)
176
- kaminari-activerecord (= 1.2.2)
177
- kaminari-core (= 1.2.2)
178
- kaminari-actionview (1.2.2)
179
- actionview
180
- kaminari-core (= 1.2.2)
181
- kaminari-activerecord (1.2.2)
182
- activerecord
183
- kaminari-core (= 1.2.2)
184
- kaminari-core (1.2.2)
199
+ jwt (2.8.2)
200
+ base64
185
201
  launchy (2.5.2)
186
202
  addressable (~> 2.8)
187
203
  loofah (2.22.0)
@@ -195,16 +211,19 @@ GEM
195
211
  marcel (1.0.4)
196
212
  method_source (1.0.0)
197
213
  mini_mime (1.1.5)
198
- mini_portile2 (2.8.6)
214
+ mini_portile2 (2.8.7)
199
215
  minitest (5.16.3)
200
216
  minitest-reporters (1.5.0)
201
217
  ansi
202
218
  builder
203
219
  minitest (>= 5.0)
204
220
  ruby-progressbar
221
+ mixpanel-ruby (2.3.0)
205
222
  mocha (2.0.2)
206
223
  ruby2_keywords (>= 0.0.5)
207
224
  multi_xml (0.6.0)
225
+ multipart-post (2.4.1)
226
+ mutex_m (0.2.0)
208
227
  neetodeploy (1.1.5)
209
228
  colorize
210
229
  dotenv (~> 2.8.1)
@@ -241,15 +260,15 @@ GEM
241
260
  octokit (4.25.1)
242
261
  faraday (>= 1, < 3)
243
262
  sawyer (~> 0.9)
244
- omniauth (2.1.1)
263
+ omniauth (2.1.2)
245
264
  hashie (>= 3.4.6)
246
265
  rack (>= 2.2.3)
247
266
  rack-protection
248
- omniauth-google-oauth2 (1.1.1)
267
+ omniauth-google-oauth2 (1.1.2)
249
268
  jwt (>= 2.0)
250
- oauth2 (~> 2.0.6)
269
+ oauth2 (~> 2.0)
251
270
  omniauth (~> 2.0)
252
- omniauth-oauth2 (~> 1.8.0)
271
+ omniauth-oauth2 (~> 1.8)
253
272
  omniauth-oauth2 (1.8.0)
254
273
  oauth2 (>= 1.4, < 3)
255
274
  omniauth (~> 2.0)
@@ -257,10 +276,11 @@ GEM
257
276
  childprocess (>= 0.6.3, < 5)
258
277
  iniparse (~> 1.4)
259
278
  rexml (~> 3.2)
279
+ pagy (8.5.0)
260
280
  parallel (1.22.1)
261
281
  parser (3.1.3.0)
262
282
  ast (~> 2.4.1)
263
- premailer (1.21.0)
283
+ premailer (1.23.0)
264
284
  addressable
265
285
  css_parser (>= 1.12.0)
266
286
  htmlentities (>= 4.0.0)
@@ -271,37 +291,45 @@ GEM
271
291
  pry (0.14.1)
272
292
  coderay (~> 1.1)
273
293
  method_source (~> 1.0)
294
+ psych (5.1.2)
295
+ stringio
274
296
  public_suffix (5.0.5)
275
- pundit (2.3.1)
297
+ pundit (2.3.2)
276
298
  activesupport (>= 3.0.0)
277
299
  raabro (1.4.0)
278
- racc (1.7.3)
279
- rack (2.2.8.1)
300
+ racc (1.8.0)
301
+ rack (2.2.9)
280
302
  rack-attack (6.7.0)
281
303
  rack (>= 1.0, < 4)
282
304
  rack-cors (2.0.2)
283
305
  rack (>= 2.0.0)
284
- rack-mini-profiler (3.1.1)
306
+ rack-mini-profiler (3.3.1)
285
307
  rack (>= 1.2.0)
286
- rack-protection (3.1.0)
308
+ rack-protection (3.2.0)
309
+ base64 (>= 0.1.0)
287
310
  rack (~> 2.2, >= 2.2.4)
311
+ rack-session (1.0.2)
312
+ rack (< 3)
288
313
  rack-test (2.1.0)
289
314
  rack (>= 1.3)
290
- rack-timeout (0.6.3)
291
- rails (7.0.8.1)
292
- actioncable (= 7.0.8.1)
293
- actionmailbox (= 7.0.8.1)
294
- actionmailer (= 7.0.8.1)
295
- actionpack (= 7.0.8.1)
296
- actiontext (= 7.0.8.1)
297
- actionview (= 7.0.8.1)
298
- activejob (= 7.0.8.1)
299
- activemodel (= 7.0.8.1)
300
- activerecord (= 7.0.8.1)
301
- activestorage (= 7.0.8.1)
302
- activesupport (= 7.0.8.1)
315
+ rack-timeout (0.7.0)
316
+ rackup (1.0.0)
317
+ rack (< 3)
318
+ webrick
319
+ rails (7.1.3.4)
320
+ actioncable (= 7.1.3.4)
321
+ actionmailbox (= 7.1.3.4)
322
+ actionmailer (= 7.1.3.4)
323
+ actionpack (= 7.1.3.4)
324
+ actiontext (= 7.1.3.4)
325
+ actionview (= 7.1.3.4)
326
+ activejob (= 7.1.3.4)
327
+ activemodel (= 7.1.3.4)
328
+ activerecord (= 7.1.3.4)
329
+ activestorage (= 7.1.3.4)
330
+ activesupport (= 7.1.3.4)
303
331
  bundler (>= 1.15.0)
304
- railties (= 7.0.8.1)
332
+ railties (= 7.1.3.4)
305
333
  rails-dom-testing (2.2.0)
306
334
  activesupport (>= 5.0.0)
307
335
  minitest
@@ -314,24 +342,30 @@ GEM
314
342
  request_store
315
343
  sassc-rails (>= 2.0.0)
316
344
  turbolinks
317
- railties (7.0.8.1)
318
- actionpack (= 7.0.8.1)
319
- activesupport (= 7.0.8.1)
320
- method_source
345
+ railties (7.1.3.4)
346
+ actionpack (= 7.1.3.4)
347
+ activesupport (= 7.1.3.4)
348
+ irb
349
+ rackup (>= 1.0.0)
321
350
  rake (>= 12.2)
322
- thor (~> 1.0)
323
- zeitwerk (~> 2.5)
351
+ thor (~> 1.0, >= 1.2.2)
352
+ zeitwerk (~> 2.6)
324
353
  rainbow (3.1.1)
325
354
  rake (13.0.6)
326
- redis (5.0.7)
327
- redis-client (>= 0.9.0)
328
- redis-client (0.17.0)
355
+ rdoc (6.7.0)
356
+ psych (>= 4.0.0)
357
+ redis (5.2.0)
358
+ redis-client (>= 0.22.0)
359
+ redis-client (0.22.2)
329
360
  connection_pool
330
361
  regexp_parser (2.6.1)
331
- request_store (1.5.1)
362
+ reline (0.5.8)
363
+ io-console (~> 0.5)
364
+ request_store (1.7.0)
332
365
  rack (>= 1.4)
333
366
  rexml (3.2.8)
334
367
  strscan (>= 3.0.9)
368
+ rinku (2.0.6)
335
369
  rubocop (1.39.0)
336
370
  json (~> 2.3)
337
371
  parallel (~> 1.10)
@@ -357,12 +391,12 @@ GEM
357
391
  sawyer (0.9.2)
358
392
  addressable (>= 2.3.5)
359
393
  faraday (>= 0.17.3, < 3)
360
- sidekiq (7.1.6)
394
+ sidekiq (7.2.4)
361
395
  concurrent-ruby (< 2)
362
396
  connection_pool (>= 2.3.0)
363
397
  rack (>= 2.2.4)
364
- redis-client (>= 0.14.0)
365
- sidekiq-cron (1.10.1)
398
+ redis-client (>= 0.19.0)
399
+ sidekiq-cron (1.12.0)
366
400
  fugit (~> 1.8)
367
401
  globalid (>= 1.0.1)
368
402
  sidekiq (>= 6)
@@ -377,13 +411,18 @@ GEM
377
411
  snaky_hash (2.0.1)
378
412
  hashie
379
413
  version_gem (~> 1.1, >= 1.1.1)
414
+ solid_cache (0.6.0)
415
+ activejob (>= 7)
416
+ activerecord (>= 7)
417
+ railties (>= 7)
380
418
  sprockets (4.2.1)
381
419
  concurrent-ruby (~> 1.0)
382
420
  rack (>= 2.2.4, < 4)
383
- sprockets-rails (3.4.2)
384
- actionpack (>= 5.2)
385
- activesupport (>= 5.2)
421
+ sprockets-rails (3.5.1)
422
+ actionpack (>= 6.1)
423
+ activesupport (>= 6.1)
386
424
  sprockets (>= 3.0.0)
425
+ stringio (3.1.0)
387
426
  strscan (3.1.0)
388
427
  terminal-table (3.0.2)
389
428
  unicode-display_width (>= 1.1.1, < 3)
@@ -400,11 +439,12 @@ GEM
400
439
  concurrent-ruby (~> 1.0)
401
440
  unicode-display_width (2.5.0)
402
441
  uniform_notifier (1.16.0)
403
- version_gem (1.1.3)
442
+ version_gem (1.1.4)
404
443
  webmock (3.18.1)
405
444
  addressable (>= 2.8.0)
406
445
  crack (>= 0.3.2)
407
446
  hashdiff (>= 0.4.0, < 2.0.0)
447
+ webrick (1.8.1)
408
448
  websocket (1.2.10)
409
449
  websocket-client-simple (0.8.0)
410
450
  event_emitter
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base"
4
+
5
+ module Neetob
6
+ class CLI
7
+ module Cloudflare
8
+ class BotFightMode < Base
9
+ attr_accessor :domain
10
+
11
+ def initialize(domain)
12
+ super()
13
+ @domain = domain
14
+ end
15
+
16
+ def run
17
+ zone_id = ZONE_IDS[domain.to_sym]
18
+ raise(StandardError, "Domain '#{domain}' not found.") if zone_id.nil?
19
+
20
+ url = create_url(zone_id, "bot_management")
21
+ response = get(url)
22
+ ui.info("Bot fight mode is turned #{response[:result][:fight_mode] ? "on" : "off"}")
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -6,6 +6,7 @@ require_relative "min_tls_version"
6
6
  require_relative "always_use_https"
7
7
  require_relative "dns_proxy_status"
8
8
  require_relative "ensure_cloudflare_cdn"
9
+ require_relative "bot_fight_mode"
9
10
 
10
11
  module Neetob
11
12
  class CLI
@@ -40,6 +41,12 @@ module Neetob
40
41
  def ensure_cloudflare_cdn
41
42
  EnsureCloudflareCdn.new(options[:app]).process
42
43
  end
44
+
45
+ desc "bot_fight_mode", "Check if a domain has bot fight mode turned on or not."
46
+ option :domain, type: :string, aliases: "-d", required: true, description: "Domain name"
47
+ def bot_fight_mode
48
+ BotFightMode.new(options[:domain]).process
49
+ end
43
50
  end
44
51
  end
45
52
  end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "zlib"
4
+ require "stringio"
5
+
6
+ require_relative "../base"
7
+
8
+ module Neetob
9
+ class CLI
10
+ module Heroku
11
+ class AutoscalingConfig < Base
12
+ attr_accessor :app
13
+
14
+ def initialize(app)
15
+ super()
16
+ @app = app
17
+ end
18
+
19
+ def run
20
+ raise(StandardError, "HEROKU_API_KEY is not given") if ENV["HEROKU_API_KEY"].nil?
21
+
22
+ url = create_url(app)
23
+ response = get(url)
24
+ if response.any? { |addon| addon[:addon_service][:name] == "judoscale" }
25
+ ui.success("Judoscale addon is enabled for #{app}")
26
+ else
27
+ ui.error("Judoscale not present for #{app}")
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def create_url(app)
34
+ "https://api.heroku.com/apps/#{app}/addons"
35
+ end
36
+
37
+ def parse_response(http_result)
38
+ case http_result
39
+ when Net::HTTPSuccess
40
+ compressed_string = StringIO.new(http_result.body)
41
+ response = Zlib::GzipReader.new(compressed_string).read
42
+ JSON.parse(response, symbolize_names: true)
43
+ else
44
+ error_message = JSON.parse(http_result.body)["message"]
45
+ raise(StandardError, "Request failed with status code #{http_result.code}: #{error_message}")
46
+ end
47
+ end
48
+
49
+ def get(url,
50
+ headers: { "Accept" => "application/vnd.heroku+json; version=3", "Authorization" => "Bearer #{ENV["HEROKU_API_KEY"]}" })
51
+ uri = URI(url)
52
+ request = Net::HTTP::Get.new(uri)
53
+ headers.each { |key, value| request[key] = value }
54
+
55
+ response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
56
+ http.request(request)
57
+ end
58
+
59
+ parse_response(response)
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -4,6 +4,9 @@ require "thor"
4
4
  require_relative "config_vars/commands"
5
5
  require_relative "access/commands"
6
6
  require_relative "execute"
7
+ require_relative "stack"
8
+ require_relative "autoscaling_config"
9
+ require_relative "maintenance_window"
7
10
 
8
11
  module Neetob
9
12
  class CLI
@@ -22,6 +25,24 @@ module Neetob
22
25
 
23
26
  desc "access", "Interact with the users of the Heroku apps"
24
27
  subcommand "access", Access::Commands
28
+
29
+ desc "stack", "Check the stack of the app on Heroku"
30
+ option :app, type: :string, aliases: "-a", required: "true", desc: "Name of your app in Heroku"
31
+ def stack
32
+ Stack.new(options[:app]).process
33
+ end
34
+
35
+ desc "autoscaling_config", "Check the stack of the app on Heroku"
36
+ option :app, type: :string, aliases: "-a", required: "true", desc: "Name of your app in Heroku"
37
+ def autoscaling_config
38
+ AutoscalingConfig.new(options[:app]).process
39
+ end
40
+
41
+ desc "maintenance_window", "Check the maintenance windows of addons of an app in Heroku"
42
+ option :app, type: :string, aliases: "-a", required: "true", desc: "Name of your app in Heroku"
43
+ def maintenance_window
44
+ MaintenanceWindow.new(options[:app]).process
45
+ end
25
46
  end
26
47
  end
27
48
  end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../base"
4
+
5
+ module Neetob
6
+ class CLI
7
+ module Heroku
8
+ class MaintenanceWindow < Base
9
+ attr_accessor :app
10
+
11
+ def initialize(app)
12
+ super()
13
+ @app = app
14
+ end
15
+
16
+ def run
17
+ redis_maintenance_modes =
18
+ `heroku redis:info -a #{app} |
19
+ awk '/^===/ {addon=$2} /Maintenance window:/ {print addon ":", $3, $4, $5, $6, $7}'`
20
+ redis_succeeded = $?.success?
21
+ pg_maintenance_modes =
22
+ `heroku pg:info -a #{app} |
23
+ awk '/^===/ {url=$2; gsub(",", "", url)} /Maintenance window:/ {print url ":", $3, $4, $5, $6, $7}'`
24
+ pg_succeeded = $?.success?
25
+
26
+ unless redis_succeeded || pg_succeeded
27
+ ui.error("There is a problem in accessing the app with name \"#{app}\" in your account.")
28
+ ui.error("Please check the specified app name and ensure you're authorized to view that app.")
29
+ end
30
+
31
+ unless redis_maintenance_modes.empty?
32
+ ui.success("Redis maintenance windows:")
33
+ ui.info(redis_maintenance_modes)
34
+ end
35
+
36
+ unless pg_maintenance_modes.empty?
37
+ ui.success("PostgreSQL maintenance windows:")
38
+ ui.info(pg_maintenance_modes)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../base"
4
+
5
+ module Neetob
6
+ class CLI
7
+ module Heroku
8
+ class Stack < Base
9
+ attr_accessor :app
10
+
11
+ def initialize(app)
12
+ super()
13
+ @app = app
14
+ end
15
+
16
+ def run
17
+ raise(StandardError, "HEROKU_API_KEY is not given") if ENV["HEROKU_API_KEY"].nil?
18
+
19
+ url = create_url(app)
20
+ response = get(url)
21
+ ui.success(response[:build_stack][:name])
22
+ end
23
+
24
+ private
25
+
26
+ def create_url(app)
27
+ "https://api.heroku.com/apps/#{app}"
28
+ end
29
+
30
+ def parse_response(http_result)
31
+ case http_result
32
+ when Net::HTTPSuccess
33
+ JSON.parse(http_result.body, symbolize_names: true)
34
+ else
35
+ error_message = JSON.parse(http_result.body)["message"]
36
+ raise(StandardError, "Request failed with status code #{http_result.code}: #{error_message}")
37
+ end
38
+ end
39
+
40
+ def get(url,
41
+ headers: { "Accept" => "application/vnd.heroku+json; version=3", "Authorization" => "Bearer #{ENV["HEROKU_API_KEY"]}" })
42
+ uri = URI(url)
43
+ request = Net::HTTP::Get.new(uri)
44
+ headers.each { |key, value| request[key] = value }
45
+
46
+ response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
47
+ http.request(request)
48
+ end
49
+
50
+ parse_response(response)
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neetob
4
+ class CLI
5
+ module NeetoDeploy
6
+ class AutoscalingConfig < CLI::Base
7
+ attr_accessor :app
8
+
9
+ def initialize(app)
10
+ super()
11
+ @app = app
12
+ end
13
+
14
+ def run
15
+ ui.success(`neetodeploy autoscaling_config list -a #{app}`)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -2,6 +2,8 @@
2
2
 
3
3
  require "thor"
4
4
  require_relative "config_vars/commands"
5
+ require_relative "./autoscaling_config"
6
+ require_relative "./scheduled_exports"
5
7
 
6
8
  module Neetob
7
9
  class CLI
@@ -9,6 +11,18 @@ module Neetob
9
11
  class Commands < Thor
10
12
  desc "config_vars", "Interact with the config(env) variables on neetoDeploy apps"
11
13
  subcommand "config_vars", ConfigVars::Commands
14
+
15
+ desc "autoscaling_config", "Get the autoscaling config of an app deployed on NeetoDeploy"
16
+ option :app, type: :string, aliases: :a, desc: "App name"
17
+ def autoscaling_config
18
+ AutoscalingConfig.new(options[:app]).run
19
+ end
20
+
21
+ desc "scheduled_exports", "Get the scheduled exports setting of an app's primary database deployed on NeetoDeploy"
22
+ option :app, type: :string, aliases: :a, desc: "App name"
23
+ def scheduled_exports
24
+ ScheduledExports.new(options[:app]).run
25
+ end
12
26
  end
13
27
  end
14
28
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neetob
4
+ class CLI
5
+ module NeetoDeploy
6
+ class ScheduledExports < CLI::Base
7
+ attr_accessor :app
8
+
9
+ def initialize(app)
10
+ super()
11
+ @app = app
12
+ end
13
+
14
+ def run
15
+ ui.success(`neetodeploy addon scheduled_exports_enabled -a #{app}`)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../base"
4
+
5
+ module Neetob
6
+ class CLI
7
+ module Sre
8
+ class Base < CLI::Base
9
+ APPS_LIST = {
10
+ "heroku": [
11
+ "neeto-auth-web-production",
12
+ "neeto-chat-web-production",
13
+ "neeto-cal-web-production",
14
+ "neeto-desk-web-production",
15
+ "neeto-kb-web-production",
16
+ "neeto-invoice-web-production",
17
+ "neeto-form-web-production",
18
+ "neeto-runner-web-production",
19
+ "neeto-course-web-production",
20
+ "neeto-deploy-web-production"
21
+ ],
22
+ "neetodeploy": [
23
+ "neeto-auth-web-staging",
24
+ "neeto-chat-web-staging",
25
+ "neeto-cal-web-staging",
26
+ "neeto-desk-web-staging",
27
+ "neeto-kb-web-staging",
28
+ "neeto-invoice-web-staging",
29
+ "neeto-form-web-staging",
30
+ "neeto-runner-web-staging",
31
+ "neeto-course-web-staging",
32
+ "neeto-ci-web-production",
33
+ "neeto-code-web-production",
34
+ "neeto-code-web-staging",
35
+ "neeto-crm-web-production",
36
+ "neeto-crm-web-staging",
37
+ "neeto-git-web-production",
38
+ "neeto-git-web-staging",
39
+ "neeto-invisible-web-production",
40
+ "neeto-invisible-web-staging",
41
+ "neeto-planner-web-production",
42
+ "neeto-planner-web-staging",
43
+ "neeto-quiz-web-production",
44
+ "neeto-quiz-web-staging",
45
+ "neeto-record-web-production",
46
+ "neeto-record-web-staging",
47
+ "neeto-replay-web-production",
48
+ "neeto-replay-web-staging",
49
+ "neeto-site-web-production",
50
+ "neeto-site-web-staging",
51
+ "neeto-testify-web-production",
52
+ "neeto-testify-web-staging",
53
+ "neeto-tower-web-production",
54
+ "neeto-tower-web-staging",
55
+ "neeto-trail-web-production",
56
+ "neeto-trail-web-staging",
57
+ "neeto-wireframe-web-production",
58
+ "neeto-wireframe-web-staging"
59
+ ]
60
+ }
61
+
62
+ def initialize
63
+ super()
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base"
4
+
5
+ module Neetob
6
+ class CLI
7
+ module Sre
8
+ class CheckEssentialEnv < Base
9
+ REQUIRED_KEYS = [
10
+ "RAILS_ENV",
11
+ "RAILS_LOG_TO_STDOUT",
12
+ "RACK_ENV",
13
+ "RAILS_SERVE_STATIC_FILES",
14
+ "HONEYBADGER_API_KEY",
15
+ "HONEYBADGER_JS_API_KEY",
16
+ "NODE_MODULES_CACHE",
17
+ "YARN_CACHE",
18
+ "YARN_PRODUCTION"
19
+ ]
20
+
21
+ REQUIRED_KEYS_HEROKU = [
22
+ "HEROKU_APP_NAME"
23
+ ]
24
+
25
+ REQUIRED_KEYS_NEETODEPLOY = [
26
+ "NODE_OPTIONS",
27
+ "NEETODEPLOY_APP_NAME"
28
+ ]
29
+
30
+ def initialize
31
+ super()
32
+ end
33
+
34
+ def run
35
+ APPS_LIST[:heroku].each do |app|
36
+ check_envs_heroku(app)
37
+ end
38
+ APPS_LIST[:neetodeploy].each do |app|
39
+ check_envs_neetodeploy(app)
40
+ end
41
+ end
42
+
43
+ private
44
+
45
+ def check_envs_heroku(app)
46
+ begin
47
+ envs = JSON.parse(`heroku config -a #{app} --json`)
48
+ required_keys = REQUIRED_KEYS + REQUIRED_KEYS_HEROKU
49
+ compare_envs(required_keys, envs, app)
50
+ rescue => exception
51
+ ui.error(exception.message)
52
+ end
53
+ end
54
+
55
+ def check_envs_neetodeploy(app)
56
+ # TODO: Optimize once github.com/bigbinary/neeto-deploy-web/issues/3745 is done
57
+ begin
58
+ env_table = `neetodeploy env list -a #{app}`
59
+ envs = {}
60
+ env_table.each_line do |line|
61
+ match = line.match(/^\| (\w+) +\| (.+?) +\|$/)
62
+ envs[match[1]] = match[2] if match
63
+ end
64
+ required_keys = REQUIRED_KEYS + REQUIRED_KEYS_NEETODEPLOY
65
+ compare_envs(required_keys, envs, app)
66
+ rescue => exception
67
+ ui.error(exception.message)
68
+ end
69
+ end
70
+
71
+ def compare_envs(required_keys, envs, app)
72
+ all_keys_present = required_keys.all? { |key| envs.has_key?(key) }
73
+ all_keys_present ?
74
+ ui.success("#{app} has all required envs") :
75
+ ui.error("#{app} doesn't have all required envs. Missing #{required_keys - envs.keys}")
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "thor"
4
+
5
+ require_relative "check_essential_env"
6
+
7
+ module Neetob
8
+ class CLI
9
+ module Sre
10
+ class Commands < Thor
11
+ desc "check_essential_env", "Confirm whether essential environment variables are set for all Neeto apps"
12
+ def check_essential_env
13
+ CheckEssentialEnv.new.run
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
data/lib/neetob/cli.rb CHANGED
@@ -6,6 +6,7 @@ module Neetob
6
6
  class CLI < Thor
7
7
  require_relative "cli/heroku/commands"
8
8
  require_relative "cli/cloudflare/commands"
9
+ require_relative "cli/sre/commands"
9
10
  require_relative "cli/github/commands"
10
11
  require_relative "cli/users/commands"
11
12
  require_relative "cli/fetchorupdate_repos/execute"
@@ -32,6 +33,9 @@ module Neetob
32
33
  desc "cloudflare", "Interact with any resource in Cloudflare"
33
34
  subcommand "cloudflare", Cloudflare::Commands
34
35
 
36
+ desc "sre", "Commands related to the SRE checklist"
37
+ subcommand "sre", Sre::Commands
38
+
35
39
  desc "neetodeploy", "Interact with resources in neetoDeploy"
36
40
  subcommand "neetodeploy", NeetoDeploy::Commands
37
41
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Neetob
4
- VERSION = "0.4.33"
4
+ VERSION = "0.4.34"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neetob
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.33
4
+ version: 0.4.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Udai Gupta
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-24 00:00:00.000000000 Z
11
+ date: 2024-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -173,6 +173,7 @@ files:
173
173
  - lib/neetob/cli/base.rb
174
174
  - lib/neetob/cli/cloudflare/always_use_https.rb
175
175
  - lib/neetob/cli/cloudflare/base.rb
176
+ - lib/neetob/cli/cloudflare/bot_fight_mode.rb
176
177
  - lib/neetob/cli/cloudflare/commands.rb
177
178
  - lib/neetob/cli/cloudflare/dns_proxy_status.rb
178
179
  - lib/neetob/cli/cloudflare/ensure_cloudflare_cdn.rb
@@ -208,6 +209,7 @@ files:
208
209
  - lib/neetob/cli/heroku/access/commands.rb
209
210
  - lib/neetob/cli/heroku/access/list.rb
210
211
  - lib/neetob/cli/heroku/access/remove.rb
212
+ - lib/neetob/cli/heroku/autoscaling_config.rb
211
213
  - lib/neetob/cli/heroku/base.rb
212
214
  - lib/neetob/cli/heroku/commands.rb
213
215
  - lib/neetob/cli/heroku/config_vars/audit.rb
@@ -217,14 +219,21 @@ files:
217
219
  - lib/neetob/cli/heroku/config_vars/remove.rb
218
220
  - lib/neetob/cli/heroku/config_vars/upsert.rb
219
221
  - lib/neetob/cli/heroku/execute.rb
222
+ - lib/neetob/cli/heroku/maintenance_window.rb
223
+ - lib/neetob/cli/heroku/stack.rb
220
224
  - lib/neetob/cli/local/commands.rb
221
225
  - lib/neetob/cli/local/ls.rb
226
+ - lib/neetob/cli/neeto_deploy/autoscaling_config.rb
222
227
  - lib/neetob/cli/neeto_deploy/commands.rb
223
228
  - lib/neetob/cli/neeto_deploy/config_vars/base.rb
224
229
  - lib/neetob/cli/neeto_deploy/config_vars/commands.rb
225
230
  - lib/neetob/cli/neeto_deploy/config_vars/list.rb
226
231
  - lib/neetob/cli/neeto_deploy/config_vars/remove.rb
227
232
  - lib/neetob/cli/neeto_deploy/config_vars/upsert.rb
233
+ - lib/neetob/cli/neeto_deploy/scheduled_exports.rb
234
+ - lib/neetob/cli/sre/base.rb
235
+ - lib/neetob/cli/sre/check_essential_env.rb
236
+ - lib/neetob/cli/sre/commands.rb
228
237
  - lib/neetob/cli/sub_command_base.rb
229
238
  - lib/neetob/cli/ui.rb
230
239
  - lib/neetob/cli/users/audit.rb