Sha256: 81cb10caaeb64408eea065f437853f4a6d1c97f407cc4e6aa66e319198135421
Contents?: true
Size: 867 Bytes
Versions: 5
Compression:
Stored size: 867 Bytes
Contents
#!/usr/bin/env ruby # frozen_string_literal: true require 'net/http' require 'json' require 'uri' require_relative '../../domain/vulnerability/model' module CisaKevApi FEED_URL = 'https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json' def self.fetch_vulnerabilities uri = URI(FEED_URL) response = Net::HTTP.get_response(uri) unless response.is_a?(Net::HTTPSuccess) raise "Failed to fetch vulnerabilities: #{response.code} #{response.message}" end json_response = JSON.parse(response.body) vulnerabilities = json_response['vulnerabilities'] vulnerabilities.each do |vulnerability| yield CisaKevVulnerability.from_json(vulnerability) end end def self.vulnerabilities list = [] fetch_vulnerabilities do |vulnerability| list << vulnerability end list end end
Version data entries
5 entries across 5 versions & 1 rubygems