make poc_in_github_importer subclass github_repo
This commit is contained in:
parent
03cadf14d4
commit
0ef9cf7a3c
1 changed files with 4 additions and 24 deletions
|
@ -2,28 +2,13 @@ require 'git'
|
|||
require 'json'
|
||||
require 'date'
|
||||
require 'bulk_insert'
|
||||
require '/data_importer/lib/importers/github_repo.rb'
|
||||
|
||||
class PocInGithubImporter
|
||||
class PocInGithubImporter < GithubRepo
|
||||
CVE_MATCHER = /(CVE|cve)-\d{4}-\d{4,7}/
|
||||
|
||||
attr_accessor :repo_url, :repo_path
|
||||
|
||||
def initialize
|
||||
@repo_url = 'https://github.com/nomi-sec/PoC-in-GitHub.git'
|
||||
@repo_path = '/data_importer/data/poc_in_github'
|
||||
end
|
||||
|
||||
def git_clone_repo
|
||||
Git.clone(repo_url, repo_path)
|
||||
end
|
||||
|
||||
def pull_latest_changes
|
||||
`cd #{repo_path}; git pull;`
|
||||
puts "Now pulling latest changes from #{repo_path}"
|
||||
end
|
||||
|
||||
def read_json(filename)
|
||||
JSON.parse(File.read(filename))
|
||||
super(repo_url='https://github.com/nomi-sec/PoC-in-GitHub.git', repo_path='/data_importer/data/poc_in_github')
|
||||
end
|
||||
|
||||
# all the files are named CVE-year-1234.json in this repo
|
||||
|
@ -100,12 +85,7 @@ class PocInGithubImporter
|
|||
end
|
||||
|
||||
def import
|
||||
if Dir.exist?(repo_path)
|
||||
pull_latest_changes
|
||||
else
|
||||
git_clone_repo
|
||||
end
|
||||
|
||||
pull_or_clone
|
||||
puts "Now starting import for #{repo_url}."
|
||||
puts '----------' * 12
|
||||
(1999..Date.today.year).map do |year|
|
||||
|
|
Loading…
Add table
Reference in a new issue