-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
670adc3
commit 15b1228
Showing
23 changed files
with
537 additions
and
540 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
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
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
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,46 @@ | ||
#!/usr/bin/env ruby | ||
$LOAD_PATH.unshift File.expand_path(File.join('..', '..', '/lib'), __FILE__) | ||
require 'zlib' | ||
require 'json' | ||
require 'net/http' | ||
require 'tzinfo' | ||
require 'nvd_helper' | ||
require 'cve_server' | ||
require 'cve_server/nvd/json/reader' | ||
|
||
class NvdSeed | ||
include NVDHelper | ||
|
||
def download_data | ||
if local_data_timestamp = last_data_timestamp | ||
print "There are files in the nvd_data directory. Quitting.\n" | ||
exit | ||
else | ||
files = download_pages | ||
update_db(files) | ||
end | ||
end | ||
|
||
|
||
def update_db(file_list) | ||
CVEServer::Cve.drop_all | ||
CVEServer::Cpe.drop_all | ||
CVEServer::CpeWithVersion.drop_all | ||
|
||
file_list.sort.each do |file| | ||
puts "Uncompressing #{file}" | ||
input = Zlib::GzipReader.open(file).read | ||
@doc = CVEServer::NVD::JSON::Reader.new(input) | ||
puts 'Exporting data into the CVE collection' | ||
CVEServer::Cve.bulk_create(@doc.all_cve) | ||
end | ||
puts "Reducing the cpe list" | ||
CVEServer::Cve.reduce_cpes | ||
puts 'Creating CVE collection Index' | ||
CVEServer::Cve.create_index(:cve) | ||
end | ||
end | ||
|
||
nvd_seed = NvdSeed.new | ||
nvd_seed.download_data | ||
|
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,38 @@ | ||
#!/usr/bin/env ruby | ||
$LOAD_PATH.unshift File.expand_path(File.join('..', '..', '/lib'), __FILE__) | ||
require 'json' | ||
require 'net/http' | ||
require 'tzinfo' | ||
require 'nvd_helper' | ||
require 'cve_server' | ||
require 'cve_server/nvd/json/reader' | ||
|
||
class NvdUpdater | ||
include NVDHelper | ||
|
||
def download_data | ||
if local_data_timestamp = last_data_timestamp | ||
files = download_pages(local_data_timestamp) | ||
update_db(files) | ||
else | ||
print "There are no local files to aquire a timestamp from for updating.\n" | ||
end | ||
end | ||
|
||
|
||
def update_db(file_list) | ||
file_list.sort.each do |file| | ||
puts "Uncompressing #{file}" | ||
input = Zlib::GzipReader.open(file).read | ||
@doc = CVEServer::NVD::JSON::Reader.new(input) | ||
puts 'Exporting data into the CVE collection' | ||
CVEServer::Cve.bulk_upsert(@doc.all_cve) | ||
end | ||
puts "Reducing the cpe list" | ||
CVEServer::Cve.reduce_cpes | ||
end | ||
end | ||
|
||
nvd_updater = NvdUpdater.new | ||
nvd_updater.download_data | ||
|
This file was deleted.
Oops, something went wrong.
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
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,18 @@ | ||
#!/usr/bin/env ruby | ||
$LOAD_PATH.unshift File.expand_path(File.join('..', '..', '/lib'), __FILE__) | ||
require 'zlib' | ||
require 'cve_server' | ||
require 'cve_server/nvd/json/reader' | ||
|
||
files = File.join(CVEServer::Boot.config.raw_data_path, "*update.json.gz") | ||
|
||
Dir.glob(files).sort.each do |infile| | ||
puts "Uncompressing #{infile}" | ||
input = Zlib::GzipReader.open(infile).read | ||
@doc = CVEServer::NVD::JSON::Reader.new(input) | ||
puts 'Exporting data into the CVE collection' | ||
CVEServer::Cve.bulk_upsert(@doc.all_cve) | ||
end | ||
puts "Reducing the cpe list" | ||
CVEServer::Cve.reduce_cpes | ||
|
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
Oops, something went wrong.