Skip to content

Commit

Permalink
feat(rubocop): allow use of YAML.load for _mapdata.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
myii committed Feb 23, 2021
1 parent 1211ecf commit c71da52
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
7 changes: 5 additions & 2 deletions ssf/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ ssf_node_anchors:
# An alternative method could be to use:
# `git describe --abbrev=0 --tags`
# yamllint disable rule:line-length rule:quoted-strings
title: "chore(shellcheck): switch hook for '`'shellcheck'`' [skip ci]"
body: '* Automated using https://github.com/myii/ssf-formula/pull/295'
title: "chore(rubocop): allow use of '`'YAML.load'`' for '`'_mapdata.rb'`' [skip ci]"
body: '* Automated using https://github.com/myii/ssf-formula/pull/296'
# yamllint enable rule:line-length rule:quoted-strings
github:
owner: 'saltstack-formulas'
Expand Down Expand Up @@ -214,6 +214,9 @@ ssf_node_anchors:
- describe
Default: 25
Max: 30
Security/YAMLLoad:
Exclude:
- 'test/integration/**/_mapdata.rb'
salt_lint: {}
script_kitchen:
bin: 'bin/kitchen'
Expand Down
9 changes: 8 additions & 1 deletion ssf/files/default/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
{%- endfor %}
# Increase from default of `{{ rbcp_MBL.Default }}`
Max: {{ rbcp_MBL.Max }}
{%- set SYL = 'Security/YAMLLoad' %}
{{ SYL }}:
{%- set rbcp_SYL = rubocop.Cops.get(SYL) %}
Exclude:
{%- for path in rbcp_SYL.Exclude %}
- {{ path }}
{%- endfor %}

{%- if rubocop.AllCops %}

Expand All @@ -36,7 +43,7 @@ AllCops:
{%- endif %}

# Any offenses that should be fixed, e.g. collected via. `rubocop --auto-gen-config`
{%- for cop, config in rubocop.Cops.items() if cop not in [LLL, MBL] %}
{%- for cop, config in rubocop.Cops.items() if cop not in [LLL, MBL, SYL] %}
{{ cop }}:
{#- This is purposefully simplistic for the time being,
until (if ever) more advanced configuration is necessary #}
Expand Down
2 changes: 1 addition & 1 deletion ssf/files/default/inspec/controls/_mapdata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
mapdata_file_path = "_mapdata/#{platform_finger}.yaml"
# Load the mapdata from profile, into a YAML structure
# https://docs.chef.io/inspec/profiles/#profile-files
mapdata_file_yaml = YAML.safe_load(inspec.profile.file(mapdata_file_path))
mapdata_file_yaml = YAML.load(inspec.profile.file(mapdata_file_path))
# Dump the YAML back into a string for comparison
mapdata_file_dump = YAML.dump(mapdata_file_yaml)

Expand Down

0 comments on commit c71da52

Please sign in to comment.