From 74d01d65da62f066642311574511c1df944c4c75 Mon Sep 17 00:00:00 2001 From: Al Snow Date: Tue, 16 Dec 2025 13:55:13 -0500 Subject: [PATCH] Initial commit for issues #674 --- spec/advisory_example.rb | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/spec/advisory_example.rb b/spec/advisory_example.rb index 6097bbfd4a..953ea1f49d 100644 --- a/spec/advisory_example.rb +++ b/spec/advisory_example.rb @@ -1,5 +1,6 @@ require 'spec_helper' require 'versions_example' +require 'net/http' require 'yaml' @@ -106,6 +107,23 @@ it { expect(subject).to be_kind_of(String) } it { expect(subject).to_not match(%r{\Ahttp(s)?://osvdb\.org}) } it { expect(subject).not_to be_empty } + + it "check for successful URL" do + # Only installing check for advisories going forward. + if Date.parse( advisory['date'].to_s ).year >= 2025 + # Assume only 1 value + uri = URI.parse(subject) + + begin + response = Net::HTTP.get_response(uri) + # TBD: What other codes besides [200, 301, 302, 308, 403]? + expect([200, 301, 302, 308, 403]).to include(response.code.to_i), + ">URL - #{uri} - #{response.code.to_i}" + rescue StandardError => e + raise ">URL - #{uri} - Error: #{e.message}" + end + end + end end describe "title" do @@ -244,6 +262,32 @@ end end end + + it "check for successful related URLs" do + if advisory["related"] # not nil + advisory["related"].each_pair do |name,values| + values.each do |value_str| + if !value_str.to_s.start_with?('CVE-') + # Only installing check for advisories going forward. + if Date.parse( advisory['date'].to_s ).year >= 2025 + # Assume only 1 value + uri = URI.parse(value_str) + + begin + response = Net::HTTP.get_response(uri) + # TBD: What other codes besides [200, 301, 302, 308, 403]? + expect([200, 301, 302, 308, 403]).to include( + response.code.to_i), + ">RELATED - #{uri}: #{response.code.to_i}" + rescue StandardError => e + raise ">RELATED - #{uri} - Error: #{e.message}" + end + end + end + end + end + end + end end describe "notes" do