Skip to content

Commit ce44ca7

Browse files
greysteilreedloden
authored andcommitted
Test that advisory file extensions are .yml (#367)
1 parent 5956c59 commit ce44ca7

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

spec/advisories_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
require 'ruby_example'
55

66
describe "gems" do
7-
Dir.glob(File.join(File.dirname(__FILE__), '../gems/*/*.yml')) do |path|
7+
Dir.glob(File.join(File.dirname(__FILE__), '../gems/*/*')) do |path|
88
include_examples 'Gem Advisory', path
99
end
1010
end
1111

1212
describe "libraries" do
13-
Dir.glob(File.join(File.dirname(__FILE__), '../libraries/*/*.yml')) do |path|
13+
Dir.glob(File.join(File.dirname(__FILE__), '../libraries/*/*')) do |path|
1414
include_examples 'Libraries Advisory', path
1515
end
1616
end
1717

1818
describe "rubies" do
19-
Dir.glob(File.join(File.dirname(__FILE__), '../rubies/*/*.yml')) do |path|
19+
Dir.glob(File.join(File.dirname(__FILE__), '../rubies/*/*')) do |path|
2020
include_examples 'Rubies Advisory', path
2121
end
2222
end

spec/advisory_example.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
advisory = YAML.load_file(path)
66

77
describe path do
8-
let(:filename) { File.basename(path).chomp('.yml') }
8+
let(:filename) { File.basename(path) }
99

1010
let(:filename_cve) do
1111
if filename.start_with?('CVE-')
@@ -20,7 +20,8 @@
2020
end
2121

2222
it "should be correctly named CVE-XXX or OSVDB-XXX" do
23-
expect(filename).to match(/^(CVE-\d{4}-(0\d{3}|[1-9]\d{3,})|OSVDB-\d+)$/)
23+
expect(filename).
24+
to match(/^(CVE-\d{4}-(0\d{3}|[1-9]\d{3,})|OSVDB-\d+)\.yml$/)
2425
end
2526

2627
it "should have CVE or OSVDB" do
@@ -51,7 +52,7 @@
5152
end
5253
it "should be id in filename if filename is CVE-XXX" do
5354
if filename_cve
54-
is_expected.to eq(filename_cve)
55+
is_expected.to eq(filename_cve.chomp('.yml'))
5556
end
5657
end
5758
end

0 commit comments

Comments
 (0)