Skip to content

Commit

Permalink
Fix Security/YAMLLoad offences
Browse files Browse the repository at this point in the history
The cop is disabled for the `TextDirectionTest` because

Replacing `YAML.load` with `YAML.safe_load` produces the following
test failure:

```
TextDirectionTest#test_explicitly_sets_text_direction_for_en.yml:
Psych::BadAlias: Unknown alias: nested_attachment_field_names
```

The en.yml file contains the folowing line which appears to be invalid YAML:

```
nested_attachment_field_names: &nested_attachment_field_names
```

See #3684
  • Loading branch information
andrewgarner committed Jan 16, 2018
1 parent 3bbafbb commit fb2e14f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion test/unit/address_formatter/h_card_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class AddressFormatter::HCardTest < ActiveSupport::TestCase
setup do
@old_formats = AddressFormatter::Formatter.address_formats
AddressFormatter::Formatter.address_formats = YAML.load(%{
AddressFormatter::Formatter.address_formats = YAML.safe_load(%{
es: |-
{{fn}}
{{street-address}}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/address_formatter/json_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class AddressFormatter::JsonTest < ActiveSupport::TestCase
setup do
@old_formats = AddressFormatter::Formatter.address_formats
AddressFormatter::Formatter.address_formats = YAML.load(%{
AddressFormatter::Formatter.address_formats = YAML.safe_load(%{
gb: |-
{{fn}}
{{street-address}}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/address_formatter/text_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class AddressFormatter::TextTest < ActiveSupport::TestCase
setup do
@old_formats = AddressFormatter::Formatter.address_formats
AddressFormatter::Formatter.address_formats = YAML.load(%{
AddressFormatter::Formatter.address_formats = YAML.safe_load(%{
es: |-
{{fn}}
{{street-address}}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/text_direction_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TextDirectionTest < ActiveSupport::TestCase

paths.each do |path|
test "explicitly sets text direction for #{File.basename(path)}" do
data = YAML.load(File.read(path))
data = YAML.load(File.read(path)) # rubocop:disable Security/YAMLLoad
locale = data.keys.first

i18n = data[locale]["i18n"]
Expand Down

0 comments on commit fb2e14f

Please sign in to comment.