fixed some things

This commit is contained in:
booboy 2019-04-28 02:32:09 -05:00
parent 213cfad730
commit 30e66c06f8
6 changed files with 30 additions and 33 deletions

1
.pryrc
View file

@ -0,0 +1 @@
irequire 'classes/CVE.rb'

View file

@ -10,4 +10,4 @@ RUN gem install pry
WORKDIR /usr/src/app
CMD pry
CMD pry

0
classes/.pryrc Normal file
View file

View file

@ -1,32 +0,0 @@
#!/usr/bin/env ruby
# CVE class
# the end goal of this is to just be something that i can use to lookup cve quickly from the command line. yes i know that these tools already exist, but what i'm trying to learn more about ruby so why not?
require 'net/http'
class CVE
def base_uri
@base_uri ||= 'https://nvd.nist.gov/feeds/'
end
def years
# i know this is long, ill fix it later to generate the numbers or something
@year ||= %w[
2002 2003 2004 2005 2006 2007
2008 2009 2010 2011 2012 2013
2014 2015 2016 2017 2018]
end
def xml_url
endpoint = 'xml/cve/2.0/'
url = self.base_uri + endpoint
uri = URI(url)
end
def xml_file(year)
xml_file = "nvdcve-2.0-#{year}.xml.gz"
end
end

2
classes/cve_info.rb Normal file
View file

@ -0,0 +1,2 @@
class CveInfo
end

View file

@ -0,0 +1,26 @@
require 'net/http'
# Kenna Security API Client
# Requests are limited to a maximum of 5 requests per second.
# If you exceed this limit, your request will receive a “429: Too Many Requests" status code response.
class APIClient
attr_accessor :api_token, :api_url
def initialize(api_token)
@api_token = api_token
@api_url = 'https://api.kennasecurity.com'
end
private
def get(uri)
# pass a relative url: example - /vulnerabilities
url = URI("#{api_url}/#{uri}")
request = Net::HTTP::Get.new(uri)
request['X-Risk-Token'] = api_token
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
end
end