foreman_remote_execution 2.0.4 → 2.0.5

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: d591db6ed8d68889930cc5159f943f5512e4f1cc9803aa4d55e6462789dbaeec
4
- data.tar.gz: 9738453478cc9f29a39eb4a48dae434e55111ed0ef393201ba495dbabbca724d
3
+ metadata.gz: 4aba9a7fccd6e4e3833bd7b102ea464e7266947d2b661ed23665588b969ce848
4
+ data.tar.gz: 037e1902f40fa780a090aca7f0141be58e0a10805afef0ca0ae5ebc3f7675e2a
5
5
  SHA512:
6
- metadata.gz: 9abd0b27d9ad9a13597b28b205bf49d97320f45d1a8851a4d09ae01b9419542b1c4a2dc98370409de37ce777ef2e6fc212e9b048e914f7c49522d32d90d1f25c
7
- data.tar.gz: 6549291f03f9b1a00865c0ec0d1b0dba18dc3b0912a1488d8f600c41c5eadb42658392b162f7666c16c4a522b4120d6d74178d1ec682ad6db5ee51b278663c0b
6
+ metadata.gz: a79d209933c9b81a4f0276e20602241147e442f4060d62afd0eab6ccc1d22a65c5b8e95025abfcb0be013ac5d7857f4ccc3cddbea2abf7b67bc2174d6a572406
7
+ data.tar.gz: 19e249a6a63c909a36fb89e7f614d0db5224d4c14b6dbff92fc078a5259eba9f9cf8d6d9e852f81bb73e32cd9a773dff5b95c48b21223406a6040e4474639802
@@ -3,22 +3,25 @@ inherit_from:
3
3
 
4
4
  AllCops:
5
5
  Exclude:
6
+ - 'config/routes.rb'
7
+ - 'node_modules/**'
8
+ - 'test/**/*'
6
9
  - 'doc/plugins/**'
7
10
 
8
11
  Rails:
9
12
  Enabled: true
10
13
  Exclude:
11
14
  - 'lib/foreman_remote_execution_core/**'
15
+ - 'node_modules/**'
12
16
 
13
17
  Rails/Date:
14
18
  Enabled: false
15
19
 
16
- # Don't enforce documentation
17
- Style/Documentation:
20
+ Metrics:
18
21
  Enabled: false
19
22
 
20
- Metrics/MethodLength:
21
- Max: 40
23
+ Style/Documentation:
24
+ Enabled: false
22
25
 
23
26
  Style/TrailingCommaInArrayLiteral:
24
27
  Enabled: false
@@ -35,14 +38,10 @@ Naming/AccessorMethodName:
35
38
  Style/RedundantSelf:
36
39
  Enabled: false
37
40
 
38
- Metrics/ClassLength:
39
- Max: 500
40
- Exclude:
41
- - 'test/**/*'
42
-
43
41
  Naming/FileName:
44
42
  Exclude:
45
43
  - 'db/seeds.d/*'
44
+ - 'node_modules/font-awesome-sass/lib/font-awesome-sass.rb'
46
45
 
47
46
  Style/WordArray:
48
47
  Enabled: false
@@ -62,15 +61,6 @@ Style/EachWithObject:
62
61
  Style/GuardClause:
63
62
  Enabled: false
64
63
 
65
- Metrics/BlockLength:
66
- Exclude:
67
- - 'config/routes.rb'
68
- - 'lib/foreman_remote_execution/engine.rb'
69
- - 'test/**/*'
70
-
71
- Metrics/ParameterLists:
72
- Enabled: false
73
-
74
64
  Naming/VariableNumber:
75
65
  Enabled: false
76
66
 
@@ -102,12 +92,6 @@ Style/SafeNavigation:
102
92
  Lint/BooleanSymbol:
103
93
  Enabled: false
104
94
 
105
- Metrics/PerceivedComplexity:
106
- Max: 8
107
-
108
- Metrics/AbcSize:
109
- Max: 45
110
-
111
95
  Style/FrozenStringLiteralComment:
112
96
  Enabled: false
113
97
 
data/README.md CHANGED
@@ -44,6 +44,14 @@ Because it doesn't really open the outgoing connections, it doesn't need hosts w
44
44
 
45
45
  Fork and send a Pull Request. Thanks!
46
46
 
47
+ To run Rubocop use the rake task in foreman dir:
48
+
49
+ bundle exec rake foreman_remote_execution:rubocop
50
+
51
+ Auto correct can be executed directly too:
52
+
53
+ bundle exec rubocop ~/work/foreman_remote_execution -a
54
+
47
55
  ## Release Process
48
56
 
49
57
  ### Pull Translations from Transifex
@@ -33,7 +33,7 @@
33
33
  <% end %>
34
34
  </span>
35
35
  <%= selectable_f targeting_fields, :bookmark_id, @composer.available_bookmarks.map { |b| [b.name, b.id] }, :selected => @composer.targeting.bookmark_id, :include_blank => true %>
36
- <%= textarea_f targeting_fields, :search_query, :value => @composer.displayed_search_query, :rows => 5, :class => 'autocomplete-input form-control', :'data-url' => auto_complete_search_hosts_path %>
36
+ <%= autocomplete_f targeting_fields, :search_query, :search_query => @composer.displayed_search_query, :full_path => auto_complete_search_hosts_path %>
37
37
 
38
38
  <div class="form-group ">
39
39
  <label class="col-md-2 control-label"><%= _('Resolves to') %></label>
@@ -8,7 +8,7 @@ require "yaml"
8
8
  # Logging
9
9
 
10
10
  LOG = Logger.new($stderr)
11
- LOG.formatter = proc { | severity, datetime, progname, msg | "#{severity}: #{msg}\n" }
11
+ LOG.formatter = proc { |severity, datetime, progname, msg| "#{severity}: #{msg}\n" }
12
12
 
13
13
  def safe_log(format_string, data = nil)
14
14
  if data.is_a? Hash
@@ -26,7 +26,7 @@ end
26
26
 
27
27
  def read_settings
28
28
  settings_path = ENV["FOREMAN_COCKPIT_SETTINGS"] || "/etc/foreman-cockpit/settings.yml"
29
- settings = YAML.load(File.read(settings_path))
29
+ settings = YAML.safe_load(File.read(settings_path))
30
30
  LOG.level = Logger.const_get(settings.fetch(:log_level, "INFO"))
31
31
  LOG.info("Running foreman-cockpit-session with settings from #{settings_path}:\n#{settings.inspect}")
32
32
  settings
@@ -46,7 +46,7 @@ def read_control
46
46
  raise ArgumentError, "Invalid frame: invalid size" if size.zero?
47
47
  data = $stdin.read(size)
48
48
  LOG.debug("Received control message #{data.lstrip}")
49
- raise ArgumentError, "Invalid frame: too short" if data == nil || data.length < size
49
+ raise ArgumentError, "Invalid frame: too short" if data.nil? || data.length < size
50
50
  JSON.parse(data)
51
51
  end
52
52
 
@@ -55,18 +55,16 @@ end
55
55
  def send_auth_challenge(challenge)
56
56
  send_control({ "command" => "authorize",
57
57
  "cookie" => "1234", # must be present, but value doesn't matter
58
- "challenge" => challenge
59
- })
58
+ "challenge" => challenge})
60
59
  end
61
60
 
62
61
  def send_auth_response(response)
63
62
  send_control({ "command" => "authorize",
64
- "response" => response
65
- })
63
+ "response" => response})
66
64
  end
67
65
 
68
66
  def read_auth_reply
69
- cmd = read_control()
67
+ cmd = read_control
70
68
  response = cmd["response"]
71
69
  raise ArgumentError, "Did not receive a valid authorize command" if cmd["command"] != "authorize" || !response
72
70
  response
@@ -77,8 +75,7 @@ def exit_with_problem(problem, message, auth_methods)
77
75
  send_control({ "command" => "init",
78
76
  "problem" => problem,
79
77
  "message" => message,
80
- "auth-method-results" => auth_methods
81
- })
78
+ "auth-method-results" => auth_methods})
82
79
  exit 1
83
80
  end
84
81
 
@@ -137,7 +134,7 @@ def ssh_read_and_handle_response_header(sock, url, params)
137
134
  header = ""
138
135
  loop do
139
136
  line = sock.readline
140
- break unless line and line != "\r\n"
137
+ break unless line && (line != "\r\n")
141
138
  header += line
142
139
  end
143
140
 
@@ -145,11 +142,11 @@ def ssh_read_and_handle_response_header(sock, url, params)
145
142
  status = status_line.split(" ")[1]
146
143
  if status != "101"
147
144
  m = /^Content-Length:[ \t]*([0-9]+)\r?$/i.match(headers_text)
148
- if m
149
- expected_len = m[1].to_i
150
- else
151
- expected_len = -1
152
- end
145
+ expected_len = if m
146
+ m[1].to_i
147
+ else
148
+ -1
149
+ end
153
150
  response = ""
154
151
  while expected_len < 0 || response.length < expected_len
155
152
  begin
@@ -162,7 +159,7 @@ def ssh_read_and_handle_response_header(sock, url, params)
162
159
  exit_with_problem("access-denied", "The proxy #{url.hostname} does not support web console sessions", nil)
163
160
  elsif status[0] == "4"
164
161
  if response.include? "cockpit-bridge: command not found"
165
- exit_with_problem("access-denied", "#{params["hostname"]} has no web console", nil)
162
+ exit_with_problem("access-denied", "#{params['hostname']} has no web console", nil)
166
163
  else
167
164
  exit_with_problem("access-denied", response, nil)
168
165
  end
@@ -191,16 +188,14 @@ def ssh_read_sock(sock)
191
188
  end
192
189
 
193
190
  def ssh_write_sock(sock, data)
194
- begin
195
191
  sock.write_nonblock(data)
196
- rescue IO::WaitWritable
192
+ rescue IO::WaitWritable
197
193
  0
198
- rescue IO::WaitReadable
194
+ rescue IO::WaitReadable
199
195
  # This might happen with SSL during a renegotiation. Block a
200
196
  # bit to get it over with.
201
197
  IO.select([sock])
202
198
  retry
203
- end
204
199
  end
205
200
 
206
201
  def ssh_with_proxy(proxy, params)
@@ -208,7 +203,7 @@ def ssh_with_proxy(proxy, params)
208
203
  LOG.debug("Connecting to proxy at #{url}")
209
204
  raw_sock = TCPSocket.open(url.hostname, url.port)
210
205
  if url.scheme == 'https'
211
- ssl_context = OpenSSL::SSL::SSLContext.new()
206
+ ssl_context = OpenSSL::SSL::SSLContext.new
212
207
  ssl_context.cert = OpenSSL::X509::Certificate.new(File.read(SETTINGS[:ssl_certificate]))
213
208
  ssl_context.key = OpenSSL::PKey.read(File.read(SETTINGS[:ssl_private_key]))
214
209
  sock = OpenSSL::SSL::SSLSocket.new(raw_sock, ssl_context)
@@ -253,7 +248,7 @@ def ssh_with_proxy(proxy, params)
253
248
  begin
254
249
  n = ssh_write_sock(sock, inp_buf)
255
250
  inp_buf = inp_buf[n..-1]
256
- raw_sock.close_write() if inp_buf == "" and ws_eof
251
+ raw_sock.close_write if (inp_buf == "") && ws_eof
257
252
  end
258
253
  end
259
254
 
@@ -262,16 +257,15 @@ def ssh_with_proxy(proxy, params)
262
257
  inp_buf += $stdin.readpartial(4096)
263
258
  rescue EOFError
264
259
  ws_eof = true
265
- raw_sock.close_write() if inp_buf == ""
260
+ raw_sock.close_write if inp_buf == ""
266
261
  end
267
262
  end
268
263
 
269
- if w.include?($stdout)
270
- n = $stdout.write(out_buf)
271
- $stdout.flush()
272
- out_buf = out_buf[n..-1]
273
- break if out_buf == "" and bridge_eof
274
- end
264
+ next unless w.include?($stdout)
265
+ n = $stdout.write(out_buf)
266
+ $stdout.flush
267
+ out_buf = out_buf[n..-1]
268
+ break if (out_buf == "") && bridge_eof
275
269
 
276
270
  end
277
271
  end
@@ -283,7 +277,7 @@ SETTINGS = read_settings
283
277
  host = ARGV[0]
284
278
 
285
279
  send_auth_challenge("*")
286
- token = get_token_from_auth_data(read_auth_reply())
280
+ token = get_token_from_auth_data(read_auth_reply)
287
281
 
288
282
  params = foreman_call("cockpit/host_ssh_params/#{host}", token)
289
283
  exit_with_problem("access-denied", "Host #{host} is not known", nil) unless params
@@ -157,32 +157,32 @@ module ForemanRemoteExecution
157
157
  # ProvisioningTemplate.reflect_on_association :template_inputs # => nil
158
158
  require_dependency 'job_template'
159
159
  (Template.descendants + [Template]).each { |klass| klass.send(:include, ForemanRemoteExecution::TemplateExtensions) }
160
- Template.send(:prepend, ForemanRemoteExecution::TemplateOverrides)
160
+ Template.prepend ForemanRemoteExecution::TemplateOverrides
161
161
 
162
162
  (Taxonomy.descendants + [Taxonomy]).each { |klass| klass.send(:include, ForemanRemoteExecution::TaxonomyExtensions) }
163
163
 
164
- User.send(:include, ForemanRemoteExecution::UserExtensions)
164
+ User.include ForemanRemoteExecution::UserExtensions
165
165
 
166
- Host::Managed.send(:prepend, ForemanRemoteExecution::HostExtensions)
167
- Host::Managed.send(:include, ForemanTasks::Concerns::HostActionSubject)
166
+ Host::Managed.prepend ForemanRemoteExecution::HostExtensions
167
+ Host::Managed.include ForemanTasks::Concerns::HostActionSubject
168
168
 
169
169
  (Nic::Base.descendants + [Nic::Base]).each do |klass|
170
170
  klass.send(:include, ForemanRemoteExecution::NicExtensions)
171
171
  end
172
172
 
173
- Bookmark.send(:include, ForemanRemoteExecution::BookmarkExtensions)
174
- HostsHelper.send(:prepend, ForemanRemoteExecution::HostsHelperExtensions)
175
- ProvisioningTemplatesHelper.send(:prepend, ForemanRemoteExecution::JobTemplatesExtensions)
176
- TemplateInput.send(:include, ForemanRemoteExecution::TemplateInputExtensions)
173
+ Bookmark.include ForemanRemoteExecution::BookmarkExtensions
174
+ HostsHelper.prepend ForemanRemoteExecution::HostsHelperExtensions
175
+ ProvisioningTemplatesHelper.prepend ForemanRemoteExecution::JobTemplatesExtensions
176
+ TemplateInput.include ForemanRemoteExecution::TemplateInputExtensions
177
177
 
178
- SmartProxy.send(:prepend, ForemanRemoteExecution::SmartProxyExtensions)
179
- Subnet.send(:include, ForemanRemoteExecution::SubnetExtensions)
178
+ SmartProxy.prepend ForemanRemoteExecution::SmartProxyExtensions
179
+ Subnet.include ForemanRemoteExecution::SubnetExtensions
180
180
 
181
181
  # We need to explicitly force to load the Task model due to Rails loader
182
182
  # having issues with resolving it to Rake::Task otherwise
183
183
  require_dependency 'foreman_tasks/task'
184
- ForemanTasks::Task.send(:include, ForemanRemoteExecution::ForemanTasksTaskExtensions)
185
- ForemanTasks::Cleaner.send(:include, ForemanRemoteExecution::ForemanTasksCleanerExtensions)
184
+ ForemanTasks::Task.include ForemanRemoteExecution::ForemanTasksTaskExtensions
185
+ ForemanTasks::Cleaner.include ForemanRemoteExecution::ForemanTasksCleanerExtensions
186
186
  RemoteExecutionProvider.register(:SSH, SSHExecutionProvider)
187
187
 
188
188
  ForemanRemoteExecution.register_rex_feature
@@ -1,3 +1,3 @@
1
1
  module ForemanRemoteExecution
2
- VERSION = '2.0.4'.freeze
2
+ VERSION = '2.0.5'.freeze
3
3
  end
@@ -2,4 +2,4 @@
2
2
  _("Remote action:")
3
3
  _("Import Puppet classes")
4
4
  _("Import facts")
5
- _("Action with sub plans")
5
+ _("Action with sub plans")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_remote_execution
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Remote Execution team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-29 00:00:00.000000000 Z
11
+ date: 2019-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface