Skip to content

Commit

Permalink
Fix update process with custom config file
Browse files Browse the repository at this point in the history
  • Loading branch information
ra1nb0rn committed Feb 22, 2024
1 parent 5bf9d7b commit 51a43c7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions search_vulns.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,10 +566,10 @@ def main():

if args.update == True:
from updater import run as run_updater
run_updater(False, args.api_key)
run_updater(False, args.api_key, args.config)
elif args.full_update == True:
from updater import run as run_updater
run_updater(True, args.api_key)
run_updater(True, args.api_key, args.config)

if not args.queries:
return
Expand Down
18 changes: 12 additions & 6 deletions updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@
CPE_DICT_ARTIFACT_URL = "https://github.com/ra1nb0rn/search_vulns/releases/latest/download/cpe-search-dictionary.db3"
CPE_DEPRECATIONS_ARTIFACT_URL = "https://github.com/ra1nb0rn/search_vulns/releases/latest/download/deprecated-cpes.json"
CVE_EDB_MAP_ARTIFACT_URL = "https://github.com/ra1nb0rn/search_vulns/releases/latest/download/cveid_to_edbid.json"

CONFIG = _load_config()
CONFIG['DATABASE_BACKUP_FILE'] = CONFIG['DATABASE_FILE'] + '.bak'
CONFIG['CPE_DATABASE_BACKUP_FILE'] = CONFIG['cpe_search']['CPE_DATABASE_FILE'] + '.bak'
CONFIG['DEPRECATED_CPES_BACKUP_FILE'] = CONFIG['cpe_search']['DEPRECATED_CPES_FILE'] + '.bak'
POC_IN_GITHUB_REPO = "https://github.com/nomi-sec/PoC-in-GitHub.git"
POC_IN_GITHUB_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "PoC-in-GitHub")
REQUEST_HEADERS = {"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/62.0"}
Expand Down Expand Up @@ -409,7 +404,18 @@ def create_poc_in_github_table():
shutil.rmtree(POC_IN_GITHUB_DIR)


def run(full=False, nvd_api_key=None):
def run(full=False, nvd_api_key=None, config_file=""):
global CONFIG

# load config
if config_file:
CONFIG = _load_config(config_file)
else:
CONFIG = _load_config()
CONFIG['DATABASE_BACKUP_FILE'] = CONFIG['DATABASE_FILE'] + '.bak'
CONFIG['CPE_DATABASE_BACKUP_FILE'] = CONFIG['cpe_search']['CPE_DATABASE_FILE'] + '.bak'
CONFIG['DEPRECATED_CPES_BACKUP_FILE'] = CONFIG['cpe_search']['DEPRECATED_CPES_FILE'] + '.bak'

# create file dirs as needed
update_files = [CONFIG['DATABASE_FILE'], CONFIG['cpe_search']['CPE_DATABASE_FILE'],
CONFIG['CVE_EDB_MAP_FILE'], CONFIG['cpe_search']['DEPRECATED_CPES_FILE'],
Expand Down

0 comments on commit 51a43c7

Please sign in to comment.