Class: YAVDB::API

Inherits:
Object
  • Object
show all
Defined in:
lib/yavdb.rb

Class Method Summary collapse

Class Method Details

.download_database(force_update = false, yavdb_path = YAVDB::Constants::DEFAULT_YAVDB_PATH, yavdb_url = YAVDB::Constants::YAVDB_DB_URL, yavdb_branch = YAVDB::Constants::YAVDB_DB_BRANCH) ⇒ Object

Download a previously generated database from the official yavdb repository into yavdb_path.

Parameters:

  • force_update (Boolean) (defaults to: false)

    force an update of the database if it already exists but is in a previous version.

  • yavdb_path (String) (defaults to: YAVDB::Constants::DEFAULT_YAVDB_PATH)

    the local path to the yavdb repository with the database.

  • yavdb_url (String) (defaults to: YAVDB::Constants::YAVDB_DB_URL)

    the yavdb url to clone the database repository from.

  • yavdb_branch (String) (defaults to: YAVDB::Constants::YAVDB_DB_BRANCH)

    the yavdb branch with the database.



60
61
62
63
64
65
# File 'lib/yavdb.rb', line 60

def self.download_database(force_update = false,
  yavdb_path = YAVDB::Constants::DEFAULT_YAVDB_PATH,
  yavdb_url = YAVDB::Constants::YAVDB_DB_URL,
  yavdb_branch = YAVDB::Constants::YAVDB_DB_BRANCH)
  YAVDB::Utils::Git.download_or_update(yavdb_path, yavdb_url, yavdb_branch, force_update)
end

.generate_database(database_path = YAVDB::Constants::DEFAULT_GENERATE_DATABASE_PATH) ⇒ Object

Crawl several sources and generate a local database in database_path.

Parameters:

  • database_path (String) (defaults to: YAVDB::Constants::DEFAULT_GENERATE_DATABASE_PATH)

    the local path to the database.



49
50
51
52
# File 'lib/yavdb.rb', line 49

def self.generate_database(database_path = YAVDB::Constants::DEFAULT_GENERATE_DATABASE_PATH)
  vulnerabilities = YAVDB::Crawler.vulnerabilities
  YAVDB::Database.save(database_path, vulnerabilities)
end

.list_vulnerabilities(package_manager, package_name, database_path = YAVDB::Constants::DEFAULT_YAVDB_PATH) ⇒ Array<Advisory>

List vulnerabilities from database_path of package_name for package_manager.

Parameters:

  • package_manager (String)

    the package manager.

  • package_name (String)

    the package_name.

  • database_path (String) (defaults to: YAVDB::Constants::DEFAULT_YAVDB_PATH)

    the local path to the database.

Returns:

  • (Array<Advisory>)

    the array of vulnerabilities.



40
41
42
43
44
# File 'lib/yavdb.rb', line 40

def self.list_vulnerabilities(package_manager,
  package_name,
  database_path = YAVDB::Constants::DEFAULT_YAVDB_PATH)
  YAVDB::Database.search(database_path, package_manager, package_name)
end