foreman_remote_execution 16.6.5 → 16.6.7

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: 803af8d6f1617172c150d68158d14d6fa9df2e5cc431226c1c0522f679420c7b
4
- data.tar.gz: 43b21d05688e374f58999c890d0ed3fedcf8e98d978be053bc52f83701e89292
3
+ metadata.gz: 7c70e248f7f1d1a6fb7dd1424915e6982d96ef6d2681564b9d8c83f14207062a
4
+ data.tar.gz: 0df83541a7c217e72e3356b68ea8f8fc8bf597ca36e572d4c56f470bbc8ba986
5
5
  SHA512:
6
- metadata.gz: 9fed722946268e04461455cffe63c27add5a23a5a0e2bbdd698a2d7bd7c94017deb0342650ecaadf92426d64db8e40682f8871ab4a43a7e60e24c1096c230bb0
7
- data.tar.gz: c11bfa8d9b1e72d2bb35d11829509923b6fb7babffd98a7782d5c8718adc9628def8739d388be1f5de07c239ba8b852c9de907c8e1b77383c573f460813ccff7
6
+ metadata.gz: 6a66e078d7b482499e27048cdcd00bbd79da1ed27b4ac43f23904d1fdd09d1f1aa4d37f898e33e05ef1c666ff599e493d356b3502a8cf52798269e5bb25c213e
7
+ data.tar.gz: 11114c1b631fd6f810ec410c2e77c307fb7f1989ac70cf412f05cdf6e63867d2dc7497cbeadd86a13d966fa71a978bb4bae5dbda42c61bce01771c4f6257caef
@@ -135,7 +135,7 @@ class JobInvocationsController < ApplicationController
135
135
 
136
136
  job_invocations = job_invocations.map do |job|
137
137
  @job_invocation = job
138
- template_invocation = job.template_invocations.find { |template_inv| template_inv.host_id == params[:host_id].to_i }
138
+ template_invocation = job.template_invocations.find_by(:host_id => params[:host_id].to_i)
139
139
  task = template_invocation.try(:run_host_job_task)
140
140
  status_mapper = task ? HostStatus::ExecutionStatus::ExecutionTaskStatusMapper.new(task) : job
141
141
  {
@@ -24,7 +24,7 @@ class TemplateInvocationsController < ApplicationController
24
24
  end
25
25
 
26
26
  def show_template_invocation_by_host
27
- @template_invocation = @job_invocation.template_invocations.find { |template_inv| template_inv.host_id == @host.id }
27
+ @template_invocation = @job_invocation.template_invocations.find_by(host_id: @host.id)
28
28
  if @template_invocation.nil?
29
29
  render :json => { :error => _('Template invocation not found') }, :status => :not_found
30
30
  end
@@ -60,13 +60,15 @@ class TemplateInvocationsController < ApplicationController
60
60
  private
61
61
 
62
62
  def find_job_invocation
63
- @job_invocation = JobInvocation.find(params[:id])
63
+ @job_invocation = JobInvocation.authorized(:view_job_invocations)
64
+ .joins(:template_invocations)
65
+ .find_by!(id: params[:id], template_invocations: { host_id: params[:host_id] })
64
66
  rescue ActiveRecord::RecordNotFound
65
67
  render :json => { :error => { :message => format(_("Job with id '%{id}' was not found"), :id => params['id']) } }, :status => :not_found
66
68
  end
67
69
 
68
70
  def find_host
69
- @host = Host.find(params[:host_id])
71
+ @host = Host.authorized(:view_hosts, Host).find(params[:host_id])
70
72
  rescue ActiveRecord::RecordNotFound
71
73
  render :json => { :error => { :message => format(_("Host with id '%{id}' was not found"), :id => params['host_id']) } }, :status => :not_found
72
74
  end
@@ -59,7 +59,7 @@ class RemoteExecutionProvider
59
59
  end
60
60
 
61
61
  def effective_user(template_invocation)
62
- template_invocation.effective_user
62
+ template_invocation.effective_user.shellescape
63
63
  end
64
64
 
65
65
  def effective_user_method(host)
@@ -1,3 +1,3 @@
1
1
  module ForemanRemoteExecution
2
- VERSION = '16.6.5'.freeze
2
+ VERSION = '16.6.7'.freeze
3
3
  end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_plugin_helper'
4
+
5
+ class TemplateInvocationsControllerTest < ActionController::TestCase
6
+ setup do
7
+ @invocation = FactoryBot.create(:job_invocation, :with_template, :with_task)
8
+ @template_invocation = @invocation.template_invocations.first
9
+ ForemanTasks::Task.any_instance.stubs(:main_action).returns(OpenStruct.new(:live_output => [], :output => {}))
10
+ ForemanTasks::Task.any_instance.stubs(:execution_plan).returns(OpenStruct.new(:actions => [nil, OpenStruct.new(:input => { 'script' => '' })]))
11
+ ForemanTasks::Task.any_instance.stubs(:cancellable?).returns(false)
12
+ end
13
+
14
+ test 'should not show template invocation for a job invocation outside the permission filter' do
15
+ user = setup_user 'view', 'hosts'
16
+ setup_user 'view', 'job_invocations', "id != #{@invocation.id}"
17
+
18
+ get :show_template_invocation_by_host,
19
+ params: { id: @invocation.id, host_id: @template_invocation.host_id },
20
+ session: set_session_user(user)
21
+
22
+ assert_response :not_found
23
+ end
24
+
25
+ test 'should not show template invocation for a host outside the permission filter' do
26
+ user = setup_user 'view', 'job_invocations'
27
+ setup_user 'view', 'hosts', "name != #{@template_invocation.host.name}"
28
+
29
+ get :show_template_invocation_by_host,
30
+ params: { id: @invocation.id, host_id: @template_invocation.host_id },
31
+ session: set_session_user(user)
32
+
33
+ assert_response :not_found
34
+ end
35
+ end
@@ -125,7 +125,7 @@ class RemoteExecutionProviderTest < ActiveSupport::TestCase
125
125
  describe 'effective user' do
126
126
  it 'takes the effective user from value from the template invocation' do
127
127
  template_invocation.effective_user = 'my user'
128
- assert_equal 'my user', proxy_options[:effective_user]
128
+ assert_equal 'my\\ user', proxy_options[:effective_user]
129
129
  end
130
130
  end
131
131
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_remote_execution
3
3
  version: !ruby/object:Gem::Version
4
- version: 16.6.5
4
+ version: 16.6.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Remote Execution team
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-06-23 00:00:00.000000000 Z
10
+ date: 2026-11-13 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: deface
@@ -30,6 +30,9 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 8.3.0
33
+ - - "<"
34
+ - !ruby/object:Gem::Version
35
+ version: '13'
33
36
  type: :runtime
34
37
  prerelease: false
35
38
  version_requirements: !ruby/object:Gem::Requirement
@@ -37,6 +40,9 @@ dependencies:
37
40
  - - ">="
38
41
  - !ruby/object:Gem::Version
39
42
  version: 8.3.0
43
+ - - "<"
44
+ - !ruby/object:Gem::Version
45
+ version: '13'
40
46
  description: A plugin bringing remote execution to the Foreman, completing the config
41
47
  management functionality with remote management functionality.
42
48
  email:
@@ -349,6 +355,7 @@ files:
349
355
  - test/functional/cockpit_controller_test.rb
350
356
  - test/functional/job_invocations_controller_test.rb
351
357
  - test/functional/job_templates_controller_test.rb
358
+ - test/functional/template_invocations_controller_test.rb
352
359
  - test/functional/ui_job_wizard_controller_test.rb
353
360
  - test/graphql/mutations/job_invocations/create_test.rb
354
361
  - test/graphql/queries/job_invocation_query_test.rb
@@ -560,7 +567,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
560
567
  - !ruby/object:Gem::Version
561
568
  version: '0'
562
569
  requirements: []
563
- rubygems_version: 4.0.10
570
+ rubygems_version: 4.0.20
564
571
  specification_version: 4
565
572
  summary: A plugin bringing remote execution to the Foreman, completing the config
566
573
  management functionality with remote management functionality.