imperituroard 0.5.1 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,297 @@
1
+ require 'imperituroard/add_functions/logger/any_functions'
2
+
3
+ class AddFuncUkaz60_2
4
+
5
+ attr_accessor :add_functions
6
+
7
+ def initialize
8
+ @add_functions = LogAddFunctions_2.new
9
+ end
10
+
11
+ #function for process separate domains
12
+ #for one domain
13
+ def delete_dump_symbols_url(stroka)
14
+ input_params = {:stroka => stroka}
15
+ output_answer = {}
16
+ processed_domain_in_url = ""
17
+ protocol = ""
18
+ type = ""
19
+ domain_only = ""
20
+ begin
21
+
22
+ #p "Step1 stroka: #{stroka}"
23
+
24
+ first_url = stroka.gsub("</", "")
25
+
26
+ if first_url != "-" && first_url != ""
27
+
28
+ #check web protocol (http/https/unknown)
29
+ if stroka.include? "http:"
30
+ protocol = "http"
31
+ elsif stroka.include? "https:"
32
+ protocol = "https"
33
+ else
34
+ protocol = "unknown"
35
+ p "ERROR: delete_dump_symbols_url.unknown protocol"
36
+ end
37
+
38
+ if first_url.include? "http://"
39
+ processed_domain_in_url = first_url.gsub("http://", "")
40
+ else
41
+ processed_domain_in_url = processed_domain_in_url + first_url
42
+ end
43
+
44
+ if processed_domain_in_url.include? "http:///"
45
+ processed_domain_in_url.gsub!("http:///", "")
46
+ end
47
+
48
+ if processed_domain_in_url.include? "http:/"
49
+ processed_domain_in_url.gsub!("http:/", "")
50
+ end
51
+
52
+ if processed_domain_in_url.include? "https://"
53
+ processed_domain_in_url.gsub!("https://", "")
54
+ end
55
+
56
+ if processed_domain_in_url.include? "https:/"
57
+ processed_domain_in_url.gsub!("https:/", "")
58
+ end
59
+
60
+ if processed_domain_in_url.include? " "
61
+ processed_domain_in_url = processed_domain_in_url.gsub!(" ", "")
62
+ end
63
+
64
+ #delete / at the end
65
+ if processed_domain_in_url[processed_domain_in_url.size-1]=="/"
66
+ sss = processed_domain_in_url.size
67
+ processed_domain_in_url = processed_domain_in_url[0..sss-2]
68
+ end
69
+
70
+ #p "Step2 processed_domain_in_url: #{processed_domain_in_url}"
71
+
72
+ if processed_domain_in_url != "-" && processed_domain_in_url != "" && processed_domain_in_url != nil
73
+ #p "Step3 processed_domain_in_url: #{processed_domain_in_url}"
74
+ #if include / then it is url. Else - domain
75
+ if !processed_domain_in_url.include? "/"
76
+ #it is domain. Process domain
77
+ #if it is kirillica then process
78
+ if processed_domain_in_url.match(/а|б|в|г|д|е|ж|ё|Ё|з|и|й|к|л|м|н|о|п|р|с|т|у|ф|х|ц|ч|ш|щ|ь|ы|ъ|э|ю|я|А|Б|В|Г|Д|Е|Ж|З|И|Й|К|Л|М|Н|О|П|Р|С|Т|У|Ф|Х|Ц|Ч|Ш|Щ|Ь|Ы|Ъ|Э|Ю|Я/)
79
+ processed_domain_in_url = SimpleIDN.to_ascii(processed_domain_in_url)
80
+ end
81
+ domain_only = domain_only + processed_domain_in_url
82
+ type = "domain"
83
+ else
84
+ #it is url. process url
85
+ hh = processed_domain_in_url.split("/")
86
+ domain_only = hh[0]
87
+ if domain_only.match(/а|б|в|г|д|е|ж|ё|Ё|з|и|й|к|л|м|н|о|п|р|с|т|у|ф|х|ц|ч|ш|щ|ь|ы|ъ|э|ю|я|А|Б|В|Г|Д|Е|Ж|З|И|Й|К|Л|М|Н|О|П|Р|С|Т|У|Ф|Х|Ц|Ч|Ш|Щ|Ь|Ы|Ъ|Э|Ю|Я/)
88
+ hh[0] = SimpleIDN.to_ascii(domain_only)
89
+ processed_domain_in_url = ""
90
+ for t in hh
91
+ processed_domain_in_url = processed_domain_in_url + t + "/"
92
+ end
93
+ sss1len = processed_domain_in_url.size
94
+ processed_domain_in_url = processed_domain_in_url[0..sss1len-2]
95
+ end
96
+ type = "url"
97
+ end
98
+ else
99
+ type = "empty"
100
+ end
101
+ output_answer = {:code => 200, :result => "Request processed", :ishodnye_dannye => stroka, :first_url => first_url, :processed_domain_in_url => processed_domain_in_url, :domain_only => domain_only, :protocol => protocol, :type => type}
102
+
103
+ else
104
+ output_answer = {:code => 202, :result => "Data not found"}
105
+ end
106
+ rescue
107
+ output_answer = {:code => 507, :result => "Something wrong"}
108
+ end
109
+ output_answer
110
+ end
111
+
112
+
113
+ def ansible_answer_parse(answer_string)
114
+ input_data = {:answer_string => answer_string}
115
+ output_data = {}
116
+
117
+ begin
118
+ answ_ans_parsed = answer_string.gsub("\n", " ")
119
+ result_out = {}
120
+ #result_out = []
121
+ num_ok = 0
122
+ num_failed = 0
123
+ final_checks = /(\S+)\s+:\s+ok=(\d)\s+changed=(\d)\s+unreachable=(\d)\s+failed=(\d)\s+skipped=(\d)\s+rescued=(\d)\s+ignored=(\d)\s+/
124
+
125
+ processed_data = answ_ans_parsed.scan(final_checks)
126
+ if processed_data!=[] && processed_data!=""
127
+ for aaa in processed_data
128
+ begin
129
+ if aaa[1].to_i>0 && aaa[3].to_i==0 && aaa[4].to_i==0 && aaa[5].to_i==0 && aaa[6].to_i==0 && aaa[7].to_i==0
130
+ result_out[aaa[0]] = "Ok"
131
+ #result_out.push({aaa[0] => "Ok"})
132
+ num_ok = num_ok + 1
133
+ else
134
+ result_out[aaa[0]] = "Failed"
135
+ #result_out.push({aaa[0] => "Failed"})
136
+ num_failed = num_failed + 1
137
+ end
138
+ rescue
139
+ result_out["unknown"] = aaa.to_s
140
+ #result_out.push({"unknown" => aaa.to_s})
141
+ num_failed = num_failed + 1
142
+ end
143
+ end
144
+ output_data = {:code => 200, :result => "ansible_answer_parse: Request completed successfully", :body => {:list => result_out, :num_ok => num_ok, :num_failed => num_failed}}
145
+ else
146
+ output_data = {:code => 400, :result => "ansible_answer_parse: Ansible returned empty data"}
147
+ end
148
+ rescue
149
+ output_data = {:code => 507, :result => "ansible_answer_parse: Unknown error"}
150
+ end
151
+ add_functions.printer_texter(output_data, "debug")
152
+ output_data
153
+ end
154
+
155
+
156
+ def https_to_forti_prep(domain)
157
+ f0 = domain.gsub("#", "")
158
+ f1 = f0.gsub("https://", "").split("/")
159
+ f1[0]
160
+ end
161
+
162
+ def http_to_forti_prep(domain)
163
+ domain.gsub("#", "")
164
+ end
165
+
166
+ #result array2-array1
167
+ #array2 - all
168
+ #array1 - blocked
169
+ def array_hash_compare(array1, array2)
170
+ diff = []
171
+ array2.each do |h1|
172
+ if array1.include?(h1)
173
+ nil
174
+ else
175
+ diff.push(h1)
176
+ end
177
+ end
178
+ diff
179
+ end
180
+
181
+
182
+ #procedure for compare http urls from staros and http urls from belgim
183
+ def staros_compare_http(data_staros, data_belgim)
184
+
185
+ notblocked_stat = {}
186
+ alert_unprotected = {}
187
+ alert_unprotected_out = {}
188
+ output_answ = {:body => {:for_block => {}, :for_unblock => {}}}
189
+ for_unblock_tmp = {}
190
+ for_unblock = {}
191
+ for_unblock_stat = {}
192
+
193
+
194
+ begin
195
+ #only for one ECS instance
196
+ data_staros[:mpc_data].each do |star_host|
197
+ alert_unprotected[star_host[:hostname]] = []
198
+ for_unblock_tmp[star_host[:hostname]] = []
199
+
200
+ #check if belgim http url is blocked on STAROS
201
+ data_belgim[:url_all].each do |belg_url|
202
+ blocked = 0
203
+ star_host[:body][:blocked_urls_http].each do |star_dom|
204
+ star_url_curr = star_dom[:url]
205
+ star_dom_len = star_url_curr.length
206
+ star_dom_x = ""
207
+ if star_url_curr[star_dom_len - 1] == "/"
208
+ star_dom_x = star_url_curr[0..star_dom_len - 2]
209
+ else
210
+ star_dom_x = star_url_curr
211
+ end
212
+ if belg_url.include?(star_dom_x)
213
+ blocked = 1
214
+ for_unblock_tmp[star_host[:hostname]].push(star_dom)
215
+ end
216
+ end
217
+ if blocked == 0
218
+ alert_unprotected[star_host[:hostname]].push(belg_url)
219
+ end
220
+ end
221
+ end
222
+
223
+ alert_unprotected.each do |proc_unpro|
224
+ da123 = proc_unpro[1]
225
+ alert_unprotected_out[proc_unpro[0]] = da123.uniq
226
+ notblocked_stat[proc_unpro[0]] = proc_unpro[1].length
227
+ end
228
+
229
+ for_unblock_tmp.each do |tmp_unbl|
230
+ hostname_st = tmp_unbl[0]
231
+ host_data_tmp = tmp_unbl[1].uniq
232
+ staros_all = data_staros[:add_format][hostname_st][:blocked_urls_http].uniq
233
+ da_annn = self.array_hash_compare(host_data_tmp, staros_all)
234
+ for_unblock[hostname_st] = da_annn.uniq
235
+ for_unblock_stat[hostname_st] = da_annn.uniq.length
236
+ end
237
+
238
+ output_answ[:code] = 200
239
+ output_answ[:result] = "Success"
240
+ output_answ[:body][:for_block][:notblocked_stat] = notblocked_stat
241
+ output_answ[:body][:for_block][:not_blocked_belgim] = alert_unprotected_out
242
+ output_answ[:body][:for_unblock][:for_unblock] = for_unblock
243
+ output_answ[:body][:for_unblock][:for_unblock_stat] = for_unblock_stat
244
+
245
+ rescue
246
+ output_answ = {:code => 507, :result => "staros_compare_http: Unknown SDK error"}
247
+ end
248
+ output_answ
249
+ end
250
+
251
+
252
+
253
+
254
+ def format_star_processed_answ(data)
255
+ answ_out = {:body => {:to_message => {:code => 200, :result => "Staros processed", :data => {:block_me => {}, :unblock_me=> {}}}, :config => {}}}
256
+ compa_n = 0
257
+ compa_n_data = ""
258
+ flag = 0
259
+ notbl_equal = 0
260
+ data[:body][:for_block][:notblocked_stat].each do |blo_for|
261
+ if flag == 0
262
+ compa_n = blo_for[1]
263
+ compa_n_data = blo_for[0]
264
+ end
265
+ if compa_n == blo_for[1]
266
+ nil
267
+ else
268
+ notbl_equal = 1
269
+ end
270
+ end
271
+
272
+ p notbl_equal
273
+ if notbl_equal == 0
274
+ block_me = {:for_block_count => data[:body][:for_block][:notblocked_stat][compa_n_data]}
275
+ unblock_me = {:for_unblock_count => data[:body][:for_unblock][:for_unblock_stat][compa_n_data]}
276
+
277
+ if block_me[:for_block_count] != 0 && unblock_me[:for_unblock_count] != 0
278
+ answ_out[:body][:to_message][:code] = 202
279
+ answ_out[:body][:to_message][:result] = "Something not actual"
280
+ else
281
+ answ_out[:body][:to_message][:code] = 200
282
+ answ_out[:body][:to_message][:result] = "Staros processed"
283
+ end
284
+
285
+ answ_out[:body][:to_message][:data][:block_me]= block_me
286
+ answ_out[:body][:to_message][:data][:unblock_me]= unblock_me
287
+ else
288
+ answ_out[:body][:to_message][:data][:block_me] = data[:body][:for_block][:notblocked_stat]
289
+ answ_out[:body][:to_message][:data][:unblock_me] = data[:body][:for_unblock][:for_unblock_stat]
290
+ end
291
+
292
+
293
+
294
+ answ_out
295
+ end
296
+
297
+ end
@@ -0,0 +1,29 @@
1
+
2
+ require 'net/ssh'
3
+
4
+ class EzuevFun_2
5
+
6
+
7
+ def vpn_create_client
8
+ command = "/usr/bin/python3.6 /projects/vpn_test/methods/create_client.py '{\"unp\": \"\", \"company_name\": \"MinskTrans\", \"full_name\":\"MinskTransTest\", \"info\": \"NewYork\", \"profile\": \"IoT\", \"net_type\": \"static\", \"number_sims\": 1024, \"msisdns\": [37529, 37528]}'"
9
+ Net::SSH.start("172.24.157.24", "soapgw", :password => "3g8Yh2Sl7Vz9Nbd358") do |ssh|
10
+ result = ssh.exec!(command)
11
+ p result
12
+ end
13
+ end
14
+
15
+ def vpn_update_client
16
+ command = "/usr/bin/python3.6 /projects/vpn_test/methods/update_client.py '{\"unp\": \"\", \"old_company_name\": \"MinskTrans\", \"new_company_name\": \"MinskTrans1\", \"new_full_name\": \"MinskTransTest1\", \"new_address\": \"NewYork\", \"new_contact_name\": \"1\", \"new_contact_number\": \"1\"}'"
17
+ Net::SSH.start("172.24.157.24", "soapgw", :password => "3g8Yh2Sl7Vz9Nbd358") do |ssh|
18
+ result = ssh.exec!(command)
19
+ p result
20
+ end
21
+ end
22
+
23
+ end
24
+
25
+
26
+ ff = EzuevFun_2.new
27
+ ff.vpn_update_client
28
+
29
+
@@ -1,3 +1,3 @@
1
1
  module Imperituroard
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imperituroard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dzmitry Buynovskiy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-14 00:00:00.000000000 Z
11
+ date: 2020-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -17,7 +17,7 @@ dependencies:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
19
  version: 2.1.4
20
- type: :development
20
+ type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
@@ -31,7 +31,7 @@ dependencies:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
33
  version: 13.0.1
34
- type: :development
34
+ type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
@@ -45,7 +45,7 @@ dependencies:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
47
  version: 4.0.1
48
- type: :development
48
+ type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
@@ -59,7 +59,7 @@ dependencies:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
61
  version: 0.4.10
62
- type: :development
62
+ type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
@@ -73,7 +73,7 @@ dependencies:
73
73
  - - '='
74
74
  - !ruby/object:Gem::Version
75
75
  version: 2.12.0
76
- type: :development
76
+ type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
@@ -87,7 +87,7 @@ dependencies:
87
87
  - - '='
88
88
  - !ruby/object:Gem::Version
89
89
  version: 2.3.0
90
- type: :development
90
+ type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
@@ -101,7 +101,7 @@ dependencies:
101
101
  - - '='
102
102
  - !ruby/object:Gem::Version
103
103
  version: 2.11.4
104
- type: :development
104
+ type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
@@ -115,7 +115,7 @@ dependencies:
115
115
  - - '='
116
116
  - !ruby/object:Gem::Version
117
117
  version: 1.10.9
118
- type: :development
118
+ type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
@@ -129,7 +129,7 @@ dependencies:
129
129
  - - '='
130
130
  - !ruby/object:Gem::Version
131
131
  version: 1.2.2
132
- type: :development
132
+ type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
@@ -143,7 +143,7 @@ dependencies:
143
143
  - - '='
144
144
  - !ruby/object:Gem::Version
145
145
  version: 0.1.1
146
- type: :development
146
+ type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
@@ -157,13 +157,27 @@ dependencies:
157
157
  - - '='
158
158
  - !ruby/object:Gem::Version
159
159
  version: 3.0.0
160
- type: :development
160
+ type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - '='
165
165
  - !ruby/object:Gem::Version
166
166
  version: 3.0.0
167
+ - !ruby/object:Gem::Dependency
168
+ name: rails
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - '='
172
+ - !ruby/object:Gem::Version
173
+ version: 5.2.4.2
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - '='
179
+ - !ruby/object:Gem::Version
180
+ version: 5.2.4.2
167
181
  description: Gem from imperituroard for different actions
168
182
  email:
169
183
  - imperituro.ard@gmail.com
@@ -187,11 +201,13 @@ files:
187
201
  - lib/.DS_Store
188
202
  - lib/imperituroard.rb
189
203
  - lib/imperituroard/.DS_Store
204
+ - lib/imperituroard/add_functions/logger/any_functions.rb
190
205
  - lib/imperituroard/platforms/cps/qps_connector.rb
191
206
  - lib/imperituroard/platforms/cps/request_formatter.rb
192
207
  - lib/imperituroard/platforms/public/telegram.rb
208
+ - lib/imperituroard/platforms/staros/get_data_ssh.rb
209
+ - lib/imperituroard/platforms/staros/staros_parser.rb
193
210
  - lib/imperituroard/projects/dns.rb
194
- - lib/imperituroard/projects/dns/ukaz60/dns_update.rb
195
211
  - lib/imperituroard/projects/iot.rb
196
212
  - lib/imperituroard/projects/iot/add_functions.rb
197
213
  - lib/imperituroard/projects/iot/hua_oceanconnect_adapter.rb
@@ -202,6 +218,14 @@ files:
202
218
  - lib/imperituroard/projects/mhub/sk.rb
203
219
  - lib/imperituroard/projects/mhub/subs/dabrab/dabrab_platform.rb
204
220
  - lib/imperituroard/projects/mhub/subs/dabrab/dabrab_proced.rb
221
+ - lib/imperituroard/projects/ukaz60.rb
222
+ - lib/imperituroard/projects/ukaz60/belgim.rb
223
+ - lib/imperituroard/projects/ukaz60/dns.rb
224
+ - lib/imperituroard/projects/ukaz60/dns_update.rb
225
+ - lib/imperituroard/projects/ukaz60/fortigate.rb
226
+ - lib/imperituroard/projects/ukaz60/staros.rb
227
+ - lib/imperituroard/projects/ukaz60/ukaz60_add_func.rb
228
+ - lib/imperituroard/projects/vpn/ezuev_fun/functions_ezuev.rb
205
229
  - lib/imperituroard/projects/wttx/phpipamcps.rb
206
230
  - lib/imperituroard/projects/wttx/phpipamdb.rb
207
231
  - lib/imperituroard/projects/wttx/updatepostcps.rb
@@ -222,7 +246,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
222
246
  requirements:
223
247
  - - ">="
224
248
  - !ruby/object:Gem::Version
225
- version: 2.3.0
249
+ version: 2.5.0
226
250
  required_rubygems_version: !ruby/object:Gem::Requirement
227
251
  requirements:
228
252
  - - ">="