navi_client 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/client.rb +26 -1
- data/lib/cloud/navi_cloud_client.rb +10 -3
- data/lib/local/navi_local_client.rb +16 -1
- data/lib/navi_client/version.rb +1 -1
- data/navi_client.gemspec +2 -2
- metadata +19 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3116d34f98600e972aa8a6ab86ef58356b0648ff0fe4a9b88e38f055f46056e0
|
4
|
+
data.tar.gz: 98932290774c44e338428536cf5e339e114e0d8422ff90ef7335bdf7ba0a359f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb9bd09aa8e872670e369b89644469608587e735b1fac13318592e6915450149c5865d9c8ca51f69af753d33840257d62c826294303b439ede29199ac6071b62
|
7
|
+
data.tar.gz: d0a2478694fda87c9e4db31e7cda0f27c8b3995dd101caee333bf58e0a20deb18e66b2e5e85b94c7135944b966279ca48ff6073385d54f13539c3952ec3e461d
|
data/lib/client.rb
CHANGED
@@ -10,6 +10,7 @@ require "logger"
|
|
10
10
|
|
11
11
|
require "httparty"
|
12
12
|
require "http_service/naviai"
|
13
|
+
require 'openssl'
|
13
14
|
|
14
15
|
module Client
|
15
16
|
def logger
|
@@ -115,7 +116,31 @@ module Client
|
|
115
116
|
end
|
116
117
|
|
117
118
|
def encrypt(data)
|
118
|
-
|
119
|
+
cipher = OpenSSL::Cipher::AES.new(256, :CFB)
|
120
|
+
cipher.encrypt
|
121
|
+
|
122
|
+
yml_config = config
|
123
|
+
|
124
|
+
key_iv_exists = (yml_config['key'] && yml_config['iv']) ? (!yml_config['key'].empty? && !yml_config['iv'].empty? ) : false
|
125
|
+
|
126
|
+
if key_iv_exists
|
127
|
+
# this condition must be true for cloud version
|
128
|
+
cipher.key = Base64.decode64(File.read(yml_config['key']))
|
129
|
+
cipher.iv = Base64.decode64(File.read(yml_config['iv']))
|
130
|
+
else
|
131
|
+
cipher.key = key = cipher.random_key
|
132
|
+
cipher.iv = iv = cipher.random_iv
|
133
|
+
|
134
|
+
key_path, iv_path = save_aes_key_iv(key, iv)
|
135
|
+
|
136
|
+
yml_config['key'] = key_path
|
137
|
+
yml_config['iv'] = iv_path
|
138
|
+
|
139
|
+
update_config(yml_config)
|
140
|
+
end
|
141
|
+
|
142
|
+
encrypted = cipher.update(data)
|
143
|
+
Base64.encode64(encrypted)
|
119
144
|
end
|
120
145
|
|
121
146
|
def time_now
|
@@ -22,6 +22,9 @@ module NaviClient
|
|
22
22
|
|
23
23
|
# client_type
|
24
24
|
@client_type = "cloud"
|
25
|
+
|
26
|
+
# set email_address of current_user for s3 folder name
|
27
|
+
@current_user_email = nil
|
25
28
|
end
|
26
29
|
|
27
30
|
def override_logger(logger)
|
@@ -37,9 +40,13 @@ module NaviClient
|
|
37
40
|
@token = session_token
|
38
41
|
end
|
39
42
|
|
43
|
+
def set_current_user_email(email)
|
44
|
+
@current_user_email = email
|
45
|
+
end
|
46
|
+
|
40
47
|
def send_request(in_filenames = [])
|
41
48
|
unless in_filenames.blank?
|
42
|
-
download_path = config['s3_download_folder']
|
49
|
+
download_path = config['s3_download_folder'] + "/" + @current_user_email
|
43
50
|
filepath = download_path + "/inputs/" + (Time.now.to_f * 1000).to_s
|
44
51
|
filename = upload_to_s3(filepath, in_filenames.join("\n"))
|
45
52
|
|
@@ -48,7 +55,7 @@ module NaviClient
|
|
48
55
|
end
|
49
56
|
|
50
57
|
def download(message, custom_uid)
|
51
|
-
download_path = config[:s3_download_folder]
|
58
|
+
download_path = config[:s3_download_folder] + "/" + @current_user_email
|
52
59
|
if ['text/plain', 'text/html'].include? message.mime_type
|
53
60
|
|
54
61
|
h = Hash.new
|
@@ -63,7 +70,7 @@ module NaviClient
|
|
63
70
|
end
|
64
71
|
|
65
72
|
def save(data={}, filename)
|
66
|
-
download_path = config[:s3_download_folder]
|
73
|
+
download_path = config[:s3_download_folder] + "/" + @current_user_email
|
67
74
|
filepath = download_path + "/" + filename + ".yml"
|
68
75
|
|
69
76
|
return upload_to_s3(filepath, data.to_yaml)
|
@@ -3,6 +3,8 @@ require_relative '../client'
|
|
3
3
|
module NaviClient
|
4
4
|
class Local
|
5
5
|
include Client
|
6
|
+
CONFIG_PATH = File.join(ENV['HOME'], '/.navi/config.yml')
|
7
|
+
|
6
8
|
def initialize(sso_web_url = 'http://localhost:3008')
|
7
9
|
# flag to print Ruby library debug info (very detailed)
|
8
10
|
@net_imap_debug = false
|
@@ -147,7 +149,20 @@ module NaviClient
|
|
147
149
|
end
|
148
150
|
|
149
151
|
def config
|
150
|
-
YAML.load_file(
|
152
|
+
YAML.load_file(CONFIG_PATH)
|
153
|
+
end
|
154
|
+
|
155
|
+
def save_aes_key_iv(key, iv)
|
156
|
+
aes_key_path = File.join(ENV['HOME'] + '/.navi/.aes.key')
|
157
|
+
iv_path = File.join(ENV['HOME'] + '/.navi/.aes.iv')
|
158
|
+
|
159
|
+
File.open(aes_key_path, "w") { |f| f.write(Base64.encode64(key)) }
|
160
|
+
File.open(iv_path, "w") { |f| f.write(Base64.encode64(iv)) }
|
161
|
+
return aes_key_path, iv_path
|
162
|
+
end
|
163
|
+
|
164
|
+
def update_config(data)
|
165
|
+
File.write(CONFIG_PATH, YAML.dump(data))
|
151
166
|
end
|
152
167
|
end
|
153
168
|
end
|
data/lib/navi_client/version.rb
CHANGED
data/navi_client.gemspec
CHANGED
@@ -6,8 +6,8 @@ require 'navi_client/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "navi_client"
|
8
8
|
spec.version = NaviClient::VERSION
|
9
|
-
spec.authors = ["Surya"]
|
10
|
-
spec.email = ["surya@whitehatengineering.com"]
|
9
|
+
spec.authors = ["Surya", "Saroj"]
|
10
|
+
spec.email = ["surya@whitehatengineering.com", "saroj@whitehatengineering.com"]
|
11
11
|
|
12
12
|
spec.summary = %q{ Write a short summary, because Rubygems requires one.}
|
13
13
|
spec.description = %q{ Write a longer description or delete this line.}
|
metadata
CHANGED
@@ -1,80 +1,81 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: navi_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Surya
|
8
|
-
|
8
|
+
- Saroj
|
9
|
+
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
12
|
+
date: 2018-01-23 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.11'
|
20
|
-
|
20
|
+
name: bundler
|
21
21
|
prerelease: false
|
22
|
+
type: :development
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
24
25
|
- - "~>"
|
25
26
|
- !ruby/object:Gem::Version
|
26
27
|
version: '1.11'
|
27
28
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.0'
|
34
|
-
|
34
|
+
name: rake
|
35
35
|
prerelease: false
|
36
|
+
type: :development
|
36
37
|
version_requirements: !ruby/object:Gem::Requirement
|
37
38
|
requirements:
|
38
39
|
- - "~>"
|
39
40
|
- !ruby/object:Gem::Version
|
40
41
|
version: '10.0'
|
41
42
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '3.0'
|
48
|
-
|
48
|
+
name: rspec
|
49
49
|
prerelease: false
|
50
|
+
type: :development
|
50
51
|
version_requirements: !ruby/object:Gem::Requirement
|
51
52
|
requirements:
|
52
53
|
- - "~>"
|
53
54
|
- !ruby/object:Gem::Version
|
54
55
|
version: '3.0'
|
55
56
|
- !ruby/object:Gem::Dependency
|
56
|
-
name: httparty
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
-
|
62
|
+
name: httparty
|
63
63
|
prerelease: false
|
64
|
+
type: :runtime
|
64
65
|
version_requirements: !ruby/object:Gem::Requirement
|
65
66
|
requirements:
|
66
67
|
- - ">="
|
67
68
|
- !ruby/object:Gem::Version
|
68
69
|
version: '0'
|
69
70
|
- !ruby/object:Gem::Dependency
|
70
|
-
name: mail
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
|
-
|
76
|
+
name: mail
|
77
77
|
prerelease: false
|
78
|
+
type: :runtime
|
78
79
|
version_requirements: !ruby/object:Gem::Requirement
|
79
80
|
requirements:
|
80
81
|
- - ">="
|
@@ -83,6 +84,7 @@ dependencies:
|
|
83
84
|
description: " Write a longer description or delete this line."
|
84
85
|
email:
|
85
86
|
- surya@whitehatengineering.com
|
87
|
+
- saroj@whitehatengineering.com
|
86
88
|
executables: []
|
87
89
|
extensions: []
|
88
90
|
extra_rdoc_files: []
|
@@ -109,7 +111,7 @@ homepage: http://navihq.com
|
|
109
111
|
licenses:
|
110
112
|
- MIT
|
111
113
|
metadata: {}
|
112
|
-
post_install_message:
|
114
|
+
post_install_message:
|
113
115
|
rdoc_options: []
|
114
116
|
require_paths:
|
115
117
|
- lib
|
@@ -124,9 +126,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
126
|
- !ruby/object:Gem::Version
|
125
127
|
version: '0'
|
126
128
|
requirements: []
|
127
|
-
rubyforge_project:
|
128
|
-
rubygems_version: 2.6.
|
129
|
-
signing_key:
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 2.6.11
|
131
|
+
signing_key:
|
130
132
|
specification_version: 4
|
131
133
|
summary: Write a short summary, because Rubygems requires one.
|
132
134
|
test_files: []
|