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

safe_yaml vs rubocop #2009

Closed
mfazekas opened this issue Jul 3, 2015 · 1 comment
Closed

safe_yaml vs rubocop #2009

mfazekas opened this issue Jul 3, 2015 · 1 comment

Comments

@mfazekas
Copy link

mfazekas commented Jul 3, 2015

In my rails project when i do rake rubocop it fails with An error occurred while Style/WordArray cop was inspecting .... When i do plain rubocop -d it work fine.

Some debugging showed this: My rails project uses rails_admin which loads safe_yaml. It looks safe_yaml disables regex loading of !ruby/regexp from yaml by default.

require 'yaml'
require 'safe_yaml'
YAML.safe_load("foo: !ruby/regexp '/bar/'\n",[Regexp])

Seems to be caused by this commit
36b857f

@mfazekas
Copy link
Author

mfazekas commented Jul 3, 2015

Questions:

  • is this is a bug in safe_yaml (1.0.4)?
  • do rubocop need to use safe_load, at all?
  • would it be better for rubocop rake task to invoke rubocop in a subprocess to avoid execution in various potentially conflicting gems autoloaded rails

My workaround is:

  desc 'run rubocop'
  RuboCop::RakeTask.new(:rubocop) do |task|
    SafeYAML.whitelist!(Regexp) if Object.const_defined?('SafeYAML')
  end

bbatsov added a commit that referenced this issue Aug 20, 2015
…ml-is-loaded

[Fix #2009] Use SafeYAML.whitelist! to allow deserialize Regexp when SafeYAML is required
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant