-
-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add specs to ensure there are no "double reported" advisories.
* All advisory files must contain a unique CVE ID and GHSA ID *per* directory.
- Loading branch information
1 parent
d7288e6
commit c6157ef
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,24 @@ | ||
load File.join(File.dirname(__FILE__), 'spec_helper.rb') | ||
require 'gem_advisory_example' | ||
require 'ruby_advisory_example' | ||
require 'advisory_dir_example' | ||
|
||
describe "gems" do | ||
Dir.glob(File.join(File.dirname(__FILE__), '../gems/*/*')) do |path| | ||
include_examples 'Gem Advisory', path | ||
end | ||
|
||
Dir.glob(File.join(File.dirname(__FILE__), '../gems/*')) do |dir| | ||
include_examples 'Advisory Directory', dir | ||
end | ||
end | ||
|
||
describe "rubies" do | ||
Dir.glob(File.join(File.dirname(__FILE__), '../rubies/*/*')) do |path| | ||
include_examples 'Rubies Advisory', path | ||
end | ||
|
||
Dir.glob(File.join(File.dirname(__FILE__), '../rubies/*')) do |dir| | ||
include_examples 'Advisory Directory', dir | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'rspec' | ||
require 'date' | ||
|
||
shared_examples_for "Advisory Directory" do |dir| | ||
describe dir do | ||
let(:advisory_paths) { Dir.glob(File.join(dir,'*.yml')) } | ||
let(:advisories) do | ||
advisory_paths.map do |path| | ||
YAML.safe_load_file(path, permitted_classes: [Date]) | ||
end | ||
end | ||
|
||
it "must not contain duplicate CVE IDs" do | ||
cve_ids = advisories.map { |advisory| advisory['cve'] } | ||
cve_ids.compact! | ||
|
||
expect(cve_ids).to eq(cve_ids.uniq) | ||
end | ||
|
||
it "must not contain duplicate GHSA IDs" do | ||
ghsa_ids = advisories.map { |advisory| advisory['ghsa'] }.compact | ||
ghsa_ids.compact! | ||
|
||
expect(ghsa_ids).to eq(ghsa_ids.uniq) | ||
end | ||
end | ||
end |