Module: SafeYAML

Defined in:
lib/safe_yaml.rb,
lib/safe_yaml/version.rb,
lib/safe_yaml/resolver.rb,
lib/safe_yaml/transform.rb,
lib/safe_yaml/syck_resolver.rb,
lib/safe_yaml/psych_resolver.rb,
lib/safe_yaml/transform/to_nil.rb,
lib/safe_yaml/transform/to_date.rb,
lib/safe_yaml/transform/to_time.rb,
lib/safe_yaml/transform/to_float.rb,
lib/safe_yaml/transform/to_symbol.rb,
lib/safe_yaml/safe_to_ruby_visitor.rb,
lib/safe_yaml/transform/to_boolean.rb,
lib/safe_yaml/transform/to_integer.rb

Defined Under Namespace

Classes: PsychResolver, Resolver, SafeToRubyVisitor, SyckResolver, Transform

Constant Summary collapse

MULTI_ARGUMENT_YAML_LOAD =
YAML.method(:load).arity != 1
YAML_ENGINE =
defined?(YAML::ENGINE) ? YAML::ENGINE.yamler : "syck"
DEFAULT_OPTIONS =
{
  :default_mode         => nil,
  :deserialize_symbols  => false,
  :whitelisted_tags     => [],
  :custom_initializers  => {},
  :raise_on_unknown_tag => false
}.freeze
OPTIONS =
DEFAULT_OPTIONS.dup
TRUSTED_TAGS =
["tag:yaml.org,2002:str"].freeze
VERSION =
"0.8.3"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.restore_defaults!Object


27
28
29
# File 'lib/safe_yaml.rb', line 27

def restore_defaults!
  OPTIONS.clear.merge!(DEFAULT_OPTIONS)
end

.tag_safety_check!(tag) ⇒ Object


31
32
33
34
35
36
# File 'lib/safe_yaml.rb', line 31

def tag_safety_check!(tag)
  return if tag.nil?
  if OPTIONS[:raise_on_unknown_tag] && !OPTIONS[:whitelisted_tags].include?(tag) && !tag_is_explicitly_trusted?(tag)
    raise "Unknown YAML tag '#{tag}'"
  end
end

Instance Method Details

#tag_is_explicitly_trusted?(tag) ⇒ Boolean

Returns:

  • (Boolean)

39
40
41
# File 'lib/safe_yaml.rb', line 39

def tag_is_explicitly_trusted?(tag)
  false
end