Sha256: 94279dfc0dc56ed614c23aef68f3f8700a593d75a95b38318d1bcd6c3a9eb360
Contents?: true
Size: 1.65 KB
Versions: 2
Compression:
Stored size: 1.65 KB
Contents
require 'spec_helper' require 'ronin/exploits/advisory' describe Ronin::Exploits::Advisory do let(:id) { 'CVE-2022-1234' } let(:url) { "https://nvd.nist.gov/vuln/detail/#{id}" } subject { described_class.new(id,url) } describe "#initialize" do context "when given only an id" do subject { described_class.new(id) } it "must set #id" do expect(subject.id).to eq(id) end it "must default #url to .url_for(id)" do expect(subject.url).to eq(described_class.url_for(id)) end end context "when given an id and a url" do subject { described_class.new(id,url) } it "must set #id" do expect(subject.id).to eq(id) end it "must set #url" do expect(subject.url).to eq(url) end end end describe ".url_for" do subject { described_class } context "when given a CVE-YYYY-NNNN id" do let(:id) { 'CVE-2022-1234' } it "must return 'https://nvd.nist.gov/vuln/detail/CVE-YYYY-NNNN'" do expect(subject.url_for(id)).to eq( "https://nvd.nist.gov/vuln/detail/#{id}" ) end end context "when given a GHSA-XXXX id" do let(:id) { 'GHSA-1234abcd' } it "must return 'https://github.com/advisories/GHSA-XXXX'" do expect(subject.url_for(id)).to eq("https://github.com/advisories/#{id}") end end context "when given any other kind of id" do let(:id) { 'XYZ-123' } it "must return nil" do expect(subject.url_for(id)).to be(nil) end end end describe "#to_s" do it "must return the advisory #id" do expect(subject.to_s).to eq(id) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ronin-exploits-1.0.0.beta2 | spec/advisory_spec.rb |
ronin-exploits-1.0.0.beta1 | spec/advisory_spec.rb |