Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix yaml safe load #406

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions bin/autoproj_bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,22 @@ module Autoproj
# @param [String] autoproj_version a constraint on the autoproj version
# that should be used
# @return [String]
def default_gemfile_contents(autoproj_version = ">= 2.16.0")
def default_gemfile_contents(autoproj_version = ">= 2.17.0")
["source \"#{gem_source}\"",
"ruby \"#{RUBY_VERSION}\" if respond_to?(:ruby)",
"gem \"autoproj\", \"#{autoproj_version}\""].join("\n")
end

def load_yaml(contents)
if Gem::Version.new(Psych::VERSION) >= Gem::Version.new("3.1.0")
YAML.safe_load(contents, permitted_classes: [Symbol])
else
YAML.safe_load(contents, [Symbol])
end
end

def add_seed_config(path)
@config.merge!(YAML.safe_load(File.read(path), [Symbol]))
@config.merge!(load_yaml(File.read(path)))
end

# Parse the provided command line options and returns the non-options
Expand Down
12 changes: 10 additions & 2 deletions bin/autoproj_install
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,22 @@ module Autoproj
# @param [String] autoproj_version a constraint on the autoproj version
# that should be used
# @return [String]
def default_gemfile_contents(autoproj_version = ">= 2.16.0")
def default_gemfile_contents(autoproj_version = ">= 2.17.0")
["source \"#{gem_source}\"",
"ruby \"#{RUBY_VERSION}\" if respond_to?(:ruby)",
"gem \"autoproj\", \"#{autoproj_version}\""].join("\n")
end

def load_yaml(contents)
if Gem::Version.new(Psych::VERSION) >= Gem::Version.new("3.1.0")
YAML.safe_load(contents, permitted_classes: [Symbol])
else
YAML.safe_load(contents, [Symbol])
end
end

def add_seed_config(path)
@config.merge!(YAML.safe_load(File.read(path), [Symbol]))
@config.merge!(load_yaml(File.read(path)))
end

# Parse the provided command line options and returns the non-options
Expand Down
10 changes: 9 additions & 1 deletion lib/autoproj/ops/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,16 @@ def default_gemfile_contents(autoproj_version = ">= #{Autoproj::VERSION}")
"gem \"autoproj\", \"#{autoproj_version}\""].join("\n")
end

def load_yaml(contents)
if Gem::Version.new(Psych::VERSION) >= Gem::Version.new("3.1.0")
YAML.safe_load(contents, permitted_classes: [Symbol])
else
YAML.safe_load(contents, [Symbol])
end
end

def add_seed_config(path)
@config.merge!(YAML.safe_load(File.read(path), [Symbol]))
@config.merge!(load_yaml(File.read(path)))
end

# Parse the provided command line options and returns the non-options
Expand Down
Loading