Skip to content

Commit

Permalink
Safe load yaml files
Browse files Browse the repository at this point in the history
  • Loading branch information
zachgoll committed Nov 1, 2024
1 parent 47288a1 commit 09b2692
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion db/seeds/exchanges.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Load exchanges from YAML configuration
exchanges_config = YAML.load_file(Rails.root.join('config', 'exchanges.yml'))
exchanges_config = YAML.safe_load(
File.read(Rails.root.join('config', 'exchanges.yml')),
permitted_classes: [],
permitted_symbols: [],
aliases: true
)

exchanges_config.each do |exchange|
next unless exchange['mic'].present? # Skip any invalid entries
Expand Down
7 changes: 6 additions & 1 deletion lib/money/currency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ def new(object)
end

def all
@all ||= YAML.load_file(CURRENCIES_FILE_PATH)
@all ||= YAML.safe_load(
File.read(CURRENCIES_FILE_PATH),
permitted_classes: [],
permitted_symbols: [],
aliases: true
)
end

def all_instances
Expand Down

0 comments on commit 09b2692

Please sign in to comment.