require 'pluginscan/reports/vulnerability_report/advisories_api' require 'pluginscan/reports/vulnerability_report/wp_vuln_db_api' require 'pluginscan/reports/vulnerability_report/vulnerability_scanner' require 'pluginscan/reports/vulnerability_report/vulnerabilities_printer' require 'fileutils' module Pluginscan module Reports module VulnerabilityReport def self.print(plugin_directory, printer, error_printer) plugin_slug = get_plugin_slug(plugin_directory) advisories = VulnerabilityScanner.new.scan(plugin_slug) printer.print(advisories, plugin_slug) true rescue WPVulnDB::APIError => e error_printer.print(e.message) false end def self.get_plugin_slug(plugin_directory) # Expanding the path handles '.' and '..' etc. full_path = File.expand_path(plugin_directory) full_path.split('/').last end end end end