Project

General

Profile

Actions

Bug #22715

closed

states can't be added through API

Added by Lars Wagner about 6 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
API
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

When I try to add a state trough the salt-api I get an error:

 "error": {"message":"ActiveModel::ForbiddenAttributesError"}

The problem is in the salt_minions_controller.rb file, because some parameters don't get passed and this can be fixed as follows:

--- salt_minions_controller.rb.orig    2018-02-28 10:55:57.000000000 +0100
+++ salt_minions_controller.rb    2018-02-28 10:56:20.000000000 +0100
@@ -29,7 +29,7 @@
         param_group :minion
         def update
           params[:minion][:salt_module_ids] = params[:minion].delete(:salt_state_ids) if params[:minion]
-          process_response @salt_minion.update_attributes(params[:minion])
+          process_response @salt_minion.update_attributes(params.require(:minion).permit(:salt_proxy_id, :salt_environment_id, :salt_module_ids => []))
         end

         def controller_permission

Is this fix in the right place, or should it be moved to a different class? If it's in the right place I'll submit a pull request.

Actions #1

Updated by Anonymous about 6 years ago

please open a PR, thanks! :)

Actions #2

Updated by The Foreman Bot about 6 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman_salt/pull/76 added
Actions #3

Updated by Anonymous about 6 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF