safe_yaml breaks new i18n.
ArgumentError: wrong number of arguments (given 2, expected 1)
/home/tom/.gem/ruby/2.7.0/gems/safe_yaml-1.0.5/lib/safe_yaml.rb:37:in `unsafe_load_file'
/home/tom/.gem/ruby/2.7.0/gems/i18n-1.14.1/lib/i18n/backend/base.rb:254:in `load_yml'
...
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>
gem 'arvados', '~> 2.7.0.rc1'
gem 'httpclient'
-gem 'safe_yaml'
gem 'lograge'
gem 'logstash-event'
nokogiri (1.15.4)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
- oj (3.16.0)
+ oj (3.16.1)
optimist (3.1.0)
os (1.1.4)
passenger (6.0.18)
rack
rake (>= 0.8.1)
- pg (1.5.3)
+ pg (1.5.4)
power_assert (2.0.3)
public_suffix (5.0.3)
racc (1.7.1)
retriable (1.4.1)
ruby-prof (0.15.9)
ruby2_keywords (0.0.5)
- safe_yaml (1.0.5)
signet (0.16.1)
addressable (~> 2.8)
faraday (>= 0.17.5, < 3.0)
rails-perftest
responders
ruby-prof (~> 0.15.0)
- safe_yaml
simplecov (~> 0.7.1)
simplecov-rcov
sprockets (~> 3.0)
where('email is null or (email not like ? and email not like ?)', '%@example.com', '%.example.com').
collect(&:uuid)
fixture_uuids =
- YAML::load_file(File.expand_path('../../../test/fixtures/users.yml',
- __FILE__)).
+ YAML::safe_load_file(File.expand_path('../../../test/fixtures/users.yml',
+ __FILE__)).
values.collect { |u| u['uuid'] }
unexpected_uuids = user_uuids - fixture_uuids
if unexpected_uuids.any?
def validate_definition
begin
- @definition_yaml = YAML.load self.definition if !definition.nil?
+ @definition_yaml = YAML.safe_load self.definition if !definition.nil?
rescue => e
errors.add :definition, "is not valid yaml: #{e.message}"
end
def set_name_and_description
old_wf = {}
begin
- old_wf = YAML.load self.definition_was if !self.definition_was.nil?
+ old_wf = YAML.safe_load self.definition_was if !self.definition_was.nil?
rescue => e
logger.warn "set_name_and_description error: #{e.message}"
return
module Server
class Application < Rails::Application
- # The following is to avoid SafeYAML's warning message
- SafeYAML::OPTIONS[:default_mode] = :safe
require_relative "arvados_config.rb"
puts stderr
raise "error loading config: #{status}"
end
-confs = YAML.load(defaultYAML, deserialize_symbols: false)
+confs = YAML.safe_load(defaultYAML)
clusterID, clusterConfig = confs["Clusters"].first
$arvados_config_defaults = clusterConfig
$arvados_config_defaults["ClusterID"] = clusterID
else
# Load the global config file
Open3.popen2("arvados-server", "config-dump", "-skip-legacy") do |stdin, stdout, status_thread|
- confs = YAML.load(stdout, deserialize_symbols: false)
+ confs = YAML.safe_load(stdout)
if confs && !confs.empty?
# config-dump merges defaults with user configuration, so every
# key should be set.
path = "#{::Rails.root.to_s}/config/#{cfgfile}.yml"
confs = ConfigLoader.load(path, erb: true)
# Ignore empty YAML file:
- next if confs == false
+ next if confs == nil
application_config.deep_merge!(confs['common'] || {})
application_config.deep_merge!(confs[::Rails.env.to_s] || {})
end
# precision cannot represent multiple updates per second.
if t.to_f != t_lastload.to_f || Time.now.to_f - t.to_f < 5
Open3.popen2("arvados-server", "config-dump", "-skip-legacy") do |stdin, stdout, status_thread|
- confs = YAML.load(stdout, deserialize_symbols: false)
+ confs = YAML.safe_load(stdout)
hash = confs["SourceSHA256"]
rescue => e
Rails.logger.info("reload_config: config file updated but could not be loaded: #{e}")
#
# SPDX-License-Identifier: AGPL-3.0
+# When loading YAML, deserialize :foo as ":foo", rather than raising
+# "Psych::DisallowedClass: Tried to load unspecified class: Symbol"
+class Psych::ScalarScanner
+ alias :orig_tokenize :tokenize
+ def tokenize string
+ return string if string =~ /^:[a-zA-Z]/
+ orig_tokenize(string)
+ end
+end
+
module Psych
module Visitors
class YAMLTree < Psych::Visitors::Visitor
if erb
yaml = ERB.new(yaml).result(binding)
end
- YAML.load(yaml, deserialize_symbols: false)
+ YAML.safe_load(yaml)
else
{}
end
[[nil, '---%']],
).rows.map do |id, yaml|
n += 1
- json = SafeJSON.dump(YAML.load(yaml))
+ json = SafeJSON.dump(YAML.safe_load(yaml))
conn.exec_query(
"UPDATE #{table} SET #{column}=$1 WHERE id=$2 AND #{column}=$3",
"#{table}.#{column} convert YAML to JSON",
end
def self.legacy_load(s)
- val = Psych.safe_load(s)
+ val = Psych.safe_load(s, permitted_classes: [Time])
if val.is_a? String
# If apiserver was downgraded to a YAML-only version after
# storing JSON in the database, the old code would have loaded
# if present, overriding base config parameters as specified
path = File.absolute_path('../../config/arvados-clients.yml', __FILE__)
if File.exist?(path) then
- cp_config = YAML.load_file(path)[ENV['RAILS_ENV']]
+ cp_config = YAML.safe_load_file(path)[ENV['RAILS_ENV']]
else
puts "Please create a\n #{path}\n file"
exit 1
# if present, overriding base config parameters as specified
path = File.dirname(__FILE__) + '/config/arvados-clients.yml'
if File.exist?(path) then
- cp_config = YAML.load_file(path)[ENV['RAILS_ENV']]
+ cp_config = YAML.safe_load_file(path)[ENV['RAILS_ENV']]
else
puts "Please create a\n " + File.dirname(__FILE__) + "/config/arvados-clients.yml\n file"
exit 1