foreman_remote_execution 10.0.3 → 10.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6cbb748f9c9d67aba38a2fa62ad4e82306d665bd9ad0021c2125926207fd95f
4
- data.tar.gz: 435f4a1aee85997d3ef430abf68a24da459bd55a09832a130e51c405638dbfd0
3
+ metadata.gz: afb4ca6a8728877e0e6447afaa11603a53932025e3eeecfeedb32b7f7dcf9b03
4
+ data.tar.gz: daf0a3e69e8a1202ac718995a294a8072f02d34abbf56c58c665d8c3dcd7e71f
5
5
  SHA512:
6
- metadata.gz: 2b3b8b5d63dfc60911069228a9f0ff136ccfe536331bb53bf348b902ee4e0cbb1fb2e26ca3d209a409a5d78a03530d5e490460a6d024baf7a584ae755bbe88d3
7
- data.tar.gz: e54b93592be98be9c6577f662d6a6e3298c36c9e7576b9325f4b1f981f94ff560865e37aaec4a87a8fe06ed933e433e66420326b9c7b5f6e72e13503b8ff4671
6
+ metadata.gz: 538a79f73bd6284f220f1203395255a5e36af2de580c99a9e17135e22206b2ac1cdcf5f363e1c2d207569b0a8323d22cb84b59b910be09806bf8b6991a684c98
7
+ data.tar.gz: 97ff7054e8a90c82c676cbe093b8977c589a8df2a7c14207e43103097c3827b7a0cc639e79ce8a929c0f634c93f7030e48a72f85f102531781ab1a06150f92f5
data/.eslintrc CHANGED
@@ -1,5 +1,8 @@
1
1
  {
2
- "plugins": ["@theforeman/foreman"],
2
+ "plugins": [
3
+ "@theforeman/foreman",
4
+ "@theforeman/rules"
5
+ ],
3
6
  "extends": [
4
7
  "plugin:@theforeman/foreman/core",
5
8
  "plugin:@theforeman/foreman/plugins"
@@ -24,6 +24,9 @@ jobs:
24
24
  - name: Run plugin linter
25
25
  run: |
26
26
  npm run lint
27
+ - name: Run custom plugin linter
28
+ run: |
29
+ npm run lint:custom
27
30
  - name: Run plugin tests
28
31
  run: |
29
32
  npm run test
@@ -1,7 +1,7 @@
1
1
  class UiJobWizardController < ApplicationController
2
2
  include FiltersHelper
3
3
  def categories
4
- job_categories = resource_scope
4
+ job_categories = resource_scope(permission: action_permission)
5
5
  .search_for("job_category ~ \"#{params[:search]}\"")
6
6
  .where(:snippet => false)
7
7
  .select(:job_category).distinct
@@ -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)
@@ -24,6 +24,10 @@
24
24
  <% end %>
25
25
  <% if job_invocation.execution_timeout_interval.present? %>
26
26
  <li><b><%= _("Timeout to kill after") %></b>: <%= job_invocation.execution_timeout_interval %> <%= _('seconds') %><br></li>
27
+ <% end %>
28
+ <% if job_invocation.time_to_pickup.present? %>
29
+ <li><b><%= _("Time to pickup") %></b>: <%= job_invocation.time_to_pickup %> <%= _('seconds') %><br>
30
+ </li>
27
31
  <% end %>
28
32
  </ul>
29
33
  </p>
@@ -1,7 +1,7 @@
1
1
  <div class="tab-pane" id="template_job">
2
2
 
3
3
  <%= autocomplete_f(f, :job_category,
4
- :search_query => '',
4
+ :search_query => @template.job_category,
5
5
  :placeholder => _("Job category") + ' ...',
6
6
  :disabled => @template.locked?) %>
7
7
  <%= text_f f, :description_format,
@@ -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
@@ -158,7 +158,7 @@ module ForemanRemoteExecution
158
158
  collection: proc { ForemanRemoteExecution.job_invocation_report_templates_select }
159
159
  setting 'remote_execution_time_to_pickup',
160
160
  type: :integer,
161
- description: N_('Time in seconds within which the host has to pick up a job. If the job is not picked up within this limit, the job will be cancelled. Defaults to 1 day.'),
161
+ description: N_('Time in seconds within which the host has to pick up a job. If the job is not picked up within this limit, the job will be cancelled. Defaults to 1 day. Applies only to pull-mqtt based jobs.'),
162
162
  default: 24 * 60 * 60,
163
163
  full_name: N_('Time to pickup')
164
164
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanRemoteExecution
2
- VERSION = '10.0.3'.freeze
2
+ VERSION = '10.0.5'.freeze
3
3
  end
data/package.json CHANGED
@@ -4,6 +4,7 @@
4
4
  "license": "GPL-3.0",
5
5
  "scripts": {
6
6
  "lint": "tfm-lint --plugin -d /webpack",
7
+ "lint:custom": "eslint ./webpack",
7
8
  "test": "tfm-test --plugin",
8
9
  "test:watch": "tfm-test --plugin --watchAll",
9
10
  "test:current": "tfm-test --plugin --watch",
@@ -23,6 +24,7 @@
23
24
  "@babel/core": "^7.7.0",
24
25
  "@theforeman/builder": "^12.0.1",
25
26
  "@theforeman/eslint-plugin-foreman": "^12.0.1",
27
+ "@theforeman/eslint-plugin-rules": "^12.0.2",
26
28
  "@theforeman/test": "^12.0.1",
27
29
  "@theforeman/vendor-dev": "^12.0.1",
28
30
  "babel-eslint": "^10.0.0",
@@ -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
@@ -59,7 +59,7 @@ export const TimeToPickupField = ({ value, setValue }) => (
59
59
  label: __('Time to pickup'),
60
60
  labelIcon: helpLabel(
61
61
  __(
62
- 'Interval in seconds, if the job is not picked up by a client within this interval it will be cancelled.'
62
+ 'Interval in seconds, if the job is not picked up by a client within this interval it will be cancelled. Applies only to pull-mqtt based jobs'
63
63
  ),
64
64
  'time-to-pickup'
65
65
  ),
@@ -23,9 +23,8 @@ export const parseRepeat = (repeatType, repeatData) => {
23
23
  const daysKeys = Object.keys(repeatData.daysOfWeek).filter(
24
24
  k => repeatData.daysOfWeek[k]
25
25
  );
26
- const days = getWeekDays()
27
- .filter((d, index) => index in daysKeys)
28
- .join(', ');
26
+ const dayNames = getWeekDays();
27
+ const days = daysKeys.map(day => dayNames[day]).join(', ');
29
28
  return sprintf(__('Every week on %s at %s'), days, repeatData.at);
30
29
  }
31
30
  case repeatTypes.monthly:
@@ -30,6 +30,9 @@ import { WizardTitle } from '../form/WizardTitle';
30
30
  import { parseEnd, parseRepeat } from './helpers';
31
31
  import { HostPreviewModal } from '../HostsAndInputs/HostPreviewModal';
32
32
 
33
+ const maskValue = (isHidden, value) =>
34
+ isHidden ? '*'.repeat(value.length) : value;
35
+
33
36
  const ReviewDetails = ({
34
37
  jobCategory,
35
38
  jobTemplateID,
@@ -122,11 +125,11 @@ const ReviewDetails = ({
122
125
  ),
123
126
  value: stringHosts(),
124
127
  },
125
- ...templateInputs.map(({ name }) => ({
128
+ ...templateInputs.map(({ name, hidden_value: isHidden }) => ({
126
129
  label: (
127
130
  <StepButton stepName={WIZARD_TITLES.hostsAndInputs}>{name}</StepButton>
128
131
  ),
129
- value: templateValues[name],
132
+ value: maskValue(isHidden, templateValues[name]),
130
133
  })),
131
134
  {
132
135
  label: (
@@ -272,9 +275,9 @@ const ReviewDetails = ({
272
275
  ? __('Randomized')
273
276
  : __('Alphabetical'),
274
277
  },
275
- ...advancedTemplateInputs.map(({ name }) => ({
278
+ ...advancedTemplateInputs.map(({ name, hidden_value: isHidden }) => ({
276
279
  label: name,
277
- value: advancedValues.templateValues[name],
280
+ value: maskValue(isHidden, advancedValues.templateValues[name]),
278
281
  })),
279
282
  ];
280
283
 
@@ -1,6 +1,14 @@
1
1
  import React, { useEffect } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { TextInput, FormGroup, ValidatedOptions } from '@patternfly/react-core';
3
+ import {
4
+ List,
5
+ ListItem,
6
+ ListComponent,
7
+ OrderType,
8
+ TextInput,
9
+ FormGroup,
10
+ ValidatedOptions,
11
+ } from '@patternfly/react-core';
4
12
  import { translate as __ } from 'foremanReact/common/I18n';
5
13
  import { helpLabel } from '../form/FormHelpers';
6
14
 
@@ -19,15 +27,15 @@ export const RepeatCron = ({ repeatData, setRepeatData, setValid }) => {
19
27
  label={__('Cron line')}
20
28
  labelIcon={helpLabel(
21
29
  <div>
22
- {__("Cron line format 'a b c d e', where:")}
30
+ {__("Cron line format '1 2 3 4 5', where:")}
23
31
  <br />
24
- <ol>
25
- <li>{__('is minute (range: 0-59)')}</li>
26
- <li>{__('is hour (range: 0-23)')}</li>
27
- <li>{__('is day of month (range: 1-31)')}</li>
28
- <li>{__('is month (range: 1-12)')}</li>
29
- <li>{__('is day of week (range: 0-6)')}</li>
30
- </ol>
32
+ <List component={ListComponent.ol} type={OrderType.number}>
33
+ <ListItem>{__('is minute (range: 0-59)')}</ListItem>
34
+ <ListItem>{__('is hour (range: 0-23)')}</ListItem>
35
+ <ListItem>{__('is day of month (range: 1-31)')}</ListItem>
36
+ <ListItem>{__('is month (range: 1-12)')}</ListItem>
37
+ <ListItem>{__('is day of week (range: 0-6)')}</ListItem>
38
+ </List>
31
39
  </div>
32
40
  )}
33
41
  isRequired
@@ -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.3
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-06-20 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.13
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