Sha256: 2b3427b9c83e3c60ec063923f918077b4017e1bde57ab4d93107d0936aba3f73

Contents?: true

Size: 929 Bytes

Versions: 1

Compression:

Stored size: 929 Bytes

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pluginscan-0.9.0 lib/pluginscan/reports/vulnerability_report.rb