Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions lib/bundler/audit/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,16 @@ def self.load(file_path)
doc.root.children.each_slice(2) do |key,value|
case key.value
when 'ignore'
unless value.is_a?(YAML::Nodes::Sequence)
if value.is_a?(YAML::Nodes::Sequence)
unless value.children.all? { |node| node.is_a?(YAML::Nodes::Scalar) }
raise(InvalidConfigurationError,"'ignore' array in config file contains a non-String")
end
config[:ignore] = value.children.map(&:value)
elsif value.is_a?(YAML::Nodes::Mapping)
raise(InvalidConfigurationError,"'ignore' key found in config file, but is not an Array")
else
config[:ignore] = []
end

unless value.children.all? { |node| node.is_a?(YAML::Nodes::Scalar) }
raise(InvalidConfigurationError,"'ignore' array in config file contains a non-String")
end

config[:ignore] = value.children.map(&:value)
end
end

Expand Down
6 changes: 6 additions & 0 deletions spec/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
it { should be_a(described_class) }
end

context 'when ignore contains and commented values' do
let(:path) { File.join(fixtures_dir,'ignore_contains_commented.yml') }

it { should be_a(described_class) }
end

describe "when ignore contains non-strings" do
let(:path) { File.join(fixtures_dir,'bad','ignore_contains_a_non_string.yml') }

Expand Down
4 changes: 4 additions & 0 deletions spec/fixtures/config/ignore_contains_commented.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
ignore:
# - CVE-123
# - CVE-456