14873: Removes protected_attributes gem dependency.
authorLucas Di Pentima <ldipentima@veritasgenetics.com>
Mon, 18 Mar 2019 18:49:51 +0000 (15:49 -0300)
committerLucas Di Pentima <ldipentima@veritasgenetics.com>
Wed, 20 Mar 2019 17:54:36 +0000 (14:54 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima@veritasgenetics.com>

services/api/Gemfile
services/api/Gemfile.lock
services/api/app/models/arvados_model.rb
services/api/app/models/job.rb

index 25e441bfca87842ccbb9fd3a0bd7343587550fcf..ad27c2df1290d624e1bbe4cdfa70a0bbc100bb1e 100644 (file)
@@ -6,7 +6,6 @@ source 'https://rubygems.org'
 
 gem 'rails', '~> 4.2'
 gem 'responders', '~> 2.0'
-gem 'protected_attributes'
 
 group :test, :development do
   gem 'factory_bot_rails'
index 6e2fa2cd66e3a2ddcf56502e95ae970940612ca0..9f7f36ee01370ae13e6c22cc06e9ce7ac05d3035 100644 (file)
@@ -188,8 +188,6 @@ GEM
       rake (>= 0.8.1)
     pg (0.21.0)
     power_assert (1.1.1)
-    protected_attributes (1.1.4)
-      activemodel (>= 4.0.1, < 5.0)
     public_suffix (3.0.3)
     rack (1.6.11)
     rack-test (0.6.3)
@@ -303,7 +301,6 @@ DEPENDENCIES
   omniauth-oauth2 (~> 1.1)
   passenger
   pg (~> 0.18)
-  protected_attributes
   rails (~> 4.2)
   rails-observers
   responders (~> 2.0)
index 2002e90acbde7d0375f36f9a3926bb01fb02b24d..3d6e15025cb1ba031f63e9e6081cae2fee922164 100644 (file)
@@ -46,6 +46,11 @@ class ArvadosModel < ActiveRecord::Base
   # penalty.
   attr_accessor :async_permissions_update
 
+  # Ignore listed attributes on mass assignments
+  def self.protected_attributes
+    []
+  end
+
   class PermissionDeniedError < RequestError
     def http_status
       403
@@ -98,6 +103,7 @@ class ArvadosModel < ActiveRecord::Base
     # "ActionController::Parameters.permit_all_parameters = true",
     # because permit_all does not permit nested attributes.
     if raw_params
+      raw_params.delete_if { |k, _| self.protected_attributes.include? k }
       serialized_attributes.each do |colname, coder|
         param = raw_params[colname.to_sym]
         if param.nil?
index 7508ead5d5c31bd397d2b0958eac72f4712d2062..420386cdc2ac0b4cfa423bb423e9c6053ec8b4ba 100644 (file)
@@ -12,7 +12,6 @@ class Job < ArvadosModel
   extend CurrentApiClient
   extend LogReuseInfo
   serialize :components, Hash
-  attr_protected :arvados_sdk_version, :docker_image_locator
   serialize :script_parameters, Hash
   serialize :runtime_constraints, Hash
   serialize :tasks_summary, Hash
@@ -83,6 +82,10 @@ class Job < ArvadosModel
     ["components"]
   end
 
+  def self.protected_attributes
+    [:arvados_sdk_version, :docker_image_locator]
+  end
+
   def assert_finished
     update_attributes(finished_at: finished_at || db_current_time,
                       success: success.nil? ? false : success,