From f39123890a386bfe71a7e3bf3aadb34e94b3e133 Mon Sep 17 00:00:00 2001 From: exoego Date: Fri, 5 Jan 2024 10:15:04 +0900 Subject: [PATCH] Replace eval with require --- lib/rspec/openapi/result_recorder.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/rspec/openapi/result_recorder.rb b/lib/rspec/openapi/result_recorder.rb index 49e60d9..676e29f 100644 --- a/lib/rspec/openapi/result_recorder.rb +++ b/lib/rspec/openapi/result_recorder.rb @@ -10,7 +10,11 @@ def record_results! @path_records.each do |path, records| # Look for a path-specific config file and run it. config_file = File.join(File.dirname(path), RSpec::OpenAPI.config_filename) - eval(File.read(config_file)) if File.exist?(config_file) + begin + require config_file if File.exist?(config_file) + rescue => e + puts "WARNING: Unable to load #{config_file}: #{e}" + end title = RSpec::OpenAPI.title RSpec::OpenAPI::SchemaFile.new(path).edit do |spec|