From 0ef9cf7a3ce185cc2de98279c90ee2bff8cb459b Mon Sep 17 00:00:00 2001 From: Brendan McDevitt Date: Tue, 12 Apr 2022 14:48:36 -0500 Subject: [PATCH] make poc_in_github_importer subclass github_repo --- lib/importers/poc_in_github_importer.rb | 28 ++++--------------------- 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/lib/importers/poc_in_github_importer.rb b/lib/importers/poc_in_github_importer.rb index 037bbf8..e0f5cb6 100644 --- a/lib/importers/poc_in_github_importer.rb +++ b/lib/importers/poc_in_github_importer.rb @@ -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|