Skip to content

Commit

Permalink
simplify loading of safe YAML
Browse files Browse the repository at this point in the history
  • Loading branch information
akostadinov committed Oct 3, 2024
1 parent 3773140 commit 066c2d1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
9 changes: 1 addition & 8 deletions app/lib/three_scale/jobs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ module ThreeScale
module Jobs

class Task
attr_reader :object

def initialize(object, method, *args)
@object = object
@method = method
Expand Down Expand Up @@ -45,8 +43,7 @@ def map(tasks)

def deserialize(args)
hash = normalize_task_args(args)
permitted_classes = ActiveRecord::Base.yaml_column_permitted_classes + ThreeScale::Jobs::JOB_CLASSES
klass, method, arguments = YAML.load(hash[:init_args], permitted_classes: permitted_classes)
klass, method, arguments = YAML.unsafe_load(hash[:init_args])
hash[:klass].constantize.new(klass, method, *arguments)
end

Expand Down Expand Up @@ -133,9 +130,5 @@ def run
HOUR = Task.map([
[Rails, :env]
]).freeze # just a fake job to ensure cron works

PERIODS = [HOUR, DAILY, WEEK, MONTH, BILLING]

JOB_CLASSES = ThreeScale::Jobs::PERIODS.flatten.map(&:object)
end
end
2 changes: 1 addition & 1 deletion test/unit/three_scale/middleware/cors_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ThreeScale::Middleware::CorsTest < ActiveSupport::TestCase
end

test 'provider signup path excluded in default configs' do
cors_config = YAML.load_file(Rails.root.join("config/cors.yml"), aliases: true, permitted_classes: [Symbol, Regexp]).deep_symbolize_keys
cors_config = YAML.unsafe_load_file(Rails.root.join("config/cors.yml")).deep_symbolize_keys
rails_envs = %i[development test production]
rails_envs.each do |rails_env|
stub_config = cors_config[rails_env]
Expand Down

0 comments on commit 066c2d1

Please sign in to comment.