foreman_remote_execution 10.0.4 → 10.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: afb55ca9ac902c2d13fa825bb4bf6b2a31cd3729f9f073b98f1add34001fdfa2
4
- data.tar.gz: a3155cf9f3c74f9d7588984015dc47ba6b7a81d4bea04bcb3b870c4ad6306405
3
+ metadata.gz: afb4ca6a8728877e0e6447afaa11603a53932025e3eeecfeedb32b7f7dcf9b03
4
+ data.tar.gz: daf0a3e69e8a1202ac718995a294a8072f02d34abbf56c58c665d8c3dcd7e71f
5
5
  SHA512:
6
- metadata.gz: d9e34ed092397296e54f100d3a5697ef18ee86e79f5a293e01c0fcf19b33c195d7cfdd1a8046079ab70fce503e2760b93ca616346ab3cd7a21c4df9ef2c10983
7
- data.tar.gz: 54cb3b829257039f3f3568544ec3f944e247a966ffd8e06f6f9a4ef1d71c7a3aaf4d0b2b3f5cea78cec32fa0eaa7e67d818e264db5bcf8b63eb0ab0d7b4f1bff
6
+ metadata.gz: 538a79f73bd6284f220f1203395255a5e36af2de580c99a9e17135e22206b2ac1cdcf5f363e1c2d207569b0a8323d22cb84b59b910be09806bf8b6991a684c98
7
+ data.tar.gz: 97ff7054e8a90c82c676cbe093b8977c589a8df2a7c14207e43103097c3827b7a0cc639e79ce8a929c0f634c93f7030e48a72f85f102531781ab1a06150f92f5
@@ -192,7 +192,7 @@ class JobTemplate < ::Template
192
192
  self.default = options[:default] unless options[:default].nil?
193
193
 
194
194
  # job templates have too long metadata, we remove them on parsing until it's stored in separate attribute
195
- self.template = self.template.gsub(/<%\#.+?.-?%>\n?/m, '').strip
195
+ self.template = self.template.sub(/<%\#.+?.-?%>\n?/m, '').strip
196
196
  end
197
197
 
198
198
  def default_input_values(ignore_keys)
@@ -170,24 +170,41 @@ class Relay
170
170
  def initialize(proxy, params)
171
171
  @proxy = proxy
172
172
  @params = params
173
+ @inject_authorization = @params['ssh_user'] != 'root' && @params['effective_user_password']
173
174
  end
174
175
 
175
176
  def proxy_loop
176
177
  proxy1 = ProxyBuffer.new($stdin, @sock)
177
178
  proxy2 = ProxyBuffer.new(@sock, $stdout)
178
179
  proxy2.on_data do |data|
179
- message = Cockpit.read_control(StringIO.new(data))
180
- if message.is_a?(Hash) && message['command'] == 'authorize'
181
- response = {
182
- 'command' => 'authorize',
183
- 'cookie' => message['cookie'],
184
- 'response' => @params['effective_user_password'],
185
- }
186
- proxy1.enqueue(Cockpit.encode_message(response))
187
- ''
188
- else
189
- data
180
+ if @inject_authorization
181
+ sio = StringIO.new(data)
182
+ begin
183
+ message = Cockpit.read_control(sio)
184
+ rescue StandardError
185
+ # We're looking for one specific message, but the expectation that one
186
+ # invocation of this callback processes one message doesn't really
187
+ # hold. The message we're looking for is sent quite early in the
188
+ # communication, if at all, so the chance that it will be aligned with
189
+ # the beginning of the buffer is quite high. If we somehow fail to
190
+ # process the contents of the buffer, we should just carry on.
191
+ #
192
+ # With the authorization injection check in place, this is more of a
193
+ # precaution so that unexpectedly big message won't bring the entire
194
+ # thing down.
195
+ end
196
+ if message.is_a?(Hash) && message['command'] == 'authorize'
197
+ response = {
198
+ 'command' => 'authorize',
199
+ 'cookie' => message['cookie'],
200
+ 'response' => @params['effective_user_password'],
201
+ }
202
+ proxy1.enqueue(Cockpit.encode_message(response))
203
+ @inject_authorization = false
204
+ data = sio.read # Return whatever was left unread after read_control
205
+ end
190
206
  end
207
+ data
191
208
  end
192
209
 
193
210
  proxies = [proxy1, proxy2]
@@ -271,7 +288,7 @@ class Relay
271
288
  end
272
289
  raise AccessDeniedError, message
273
290
  else
274
- raise CockpitError, "Error talking to smart proxy: #{response}"
291
+ raise CockpitError, "Error talking to smart proxy: #{body}"
275
292
  end
276
293
  end
277
294
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanRemoteExecution
2
- VERSION = '10.0.4'.freeze
2
+ VERSION = '10.0.5'.freeze
3
3
  end
@@ -94,6 +94,8 @@ class JobTemplateTest < ActiveSupport::TestCase
94
94
  %>
95
95
 
96
96
  service <%= input("service_name") %> restart
97
+
98
+ <%# test comment %>
97
99
  END_TEMPLATE
98
100
 
99
101
  JobTemplate.import_raw!(template, :default => true)
@@ -122,7 +124,7 @@ class JobTemplateTest < ActiveSupport::TestCase
122
124
  end
123
125
 
124
126
  it 'has a template' do
125
- _(template.template.squish).must_equal 'service <%= input("service_name") %> restart'
127
+ _(template.template.squish).must_equal 'service <%= input("service_name") %> restart <%# test comment %>'
126
128
  end
127
129
 
128
130
  it 'imports inputs' do
@@ -9,11 +9,12 @@ export const getWeekDays = () => {
9
9
  const locale = documentLocale().replace(/-/g, '_');
10
10
  const baseDate = new Date(Date.UTC(2017, 0, 1)); // just a Sunday
11
11
  const weekDays = [];
12
+ const formatOptions = { weekday: 'short', timeZone: 'UTC' };
12
13
  for (let i = 0; i < 7; i++) {
13
14
  try {
14
- weekDays.push(baseDate.toLocaleDateString(locale, { weekday: 'short' }));
15
+ weekDays.push(baseDate.toLocaleDateString(locale, formatOptions));
15
16
  } catch {
16
- weekDays.push(baseDate.toLocaleDateString('en', { weekday: 'short' }));
17
+ weekDays.push(baseDate.toLocaleDateString('en', formatOptions));
17
18
  }
18
19
  baseDate.setDate(baseDate.getDate() + 1);
19
20
  }
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: 10.0.4
4
+ version: 10.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: 2023-07-19 00:00:00.000000000 Z
11
+ date: 2023-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -576,7 +576,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
576
576
  - !ruby/object:Gem::Version
577
577
  version: '0'
578
578
  requirements: []
579
- rubygems_version: 3.4.16
579
+ rubygems_version: 3.4.17
580
580
  signing_key:
581
581
  specification_version: 4
582
582
  summary: A plugin bringing remote execution to the Foreman, completing the config