# Class: StatsPlugin — Documentation by YARD 0.8.6.1

Class List Method List File List

# Class: StatsPlugin

Inherits:
  Plugin
  - Object
  - Plugin
  - StatsPlugin
  show all
Defined in:
  lib/wpstools/plugins/stats/stats_plugin.rb

## Instance Attribute Summary

### Attributes inherited from Plugin

#author, #registered_options

## Instance Method Summary (collapse)

- - (StatsPlugin) initialize constructor

  A new instance of StatsPlugin.

- - (Object) lines_in_file(file)
- - (Object) plugin_vulns_count(file = PLUGINS_VULNS_FILE)
- - (Object) run(options = {})
- - (Object) theme_vulns_count(file = THEMES_VULNS_FILE)
- - (Object) total_plugins(file = PLUGINS_FULL_FILE)
- - (Object) total_themes(file = THEMES_FULL_FILE)
- - (Object) vuln_plugin_count(file = PLUGINS_VULNS_FILE)
- - (Object) vuln_theme_count(file = THEMES_VULNS_FILE)

### Methods inherited from Plugin

#register_options

## Constructor Details

### - (`StatsPlugin`) initialize

A new instance of StatsPlugin

    5
    6
    7
    8
    9
    10
    11

    # File 'lib/wpstools/plugins/stats/stats_plugin.rb', line 5

    def initialize
      super(author: 'WPScanTeam - Christian Mehlmauer')

      register_options(
          ['--stats', '--s', 'Show WpScan Database statistics']
      )
    end

## Instance Method Details

### - (`Object`) lines_in_file(file)

    51
    52
    53

    # File 'lib/wpstools/plugins/stats/stats_plugin.rb', line 51

    def lines_in_file(file)
      IO.readlines(file).size
    end

### - (`Object`) plugin_vulns_count(file = PLUGINS_VULNS_FILE)

    35
    36
    37

    # File 'lib/wpstools/plugins/stats/stats_plugin.rb', line 35

    def plugin_vulns_count(file=PLUGINS_VULNS_FILE)
      xml(file).xpath("count(//vulnerability)").to_i
    end

### - (`Object`) run(options = {})

    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25

    # File 'lib/wpstools/plugins/stats/stats_plugin.rb', line 13

    def run(options = {})
      if options[:stats]
        puts "Wpscan Databse Statistics:"
        puts "--------------------------"
        puts "[#] Total vulnerable plugins: #{vuln_plugin_count}"
        puts "[#] Total vulnerable themes: #{vuln_theme_count}"
        puts "[#] Total plugin vulnerabilities: #{plugin_vulns_count}"
        puts "[#] Total theme vulnerabilities: #{theme_vulns_count}"
        puts "[#] Total plugins to enumerate: #{total_plugins}"
        puts "[#] Total themes to enumerate: #{total_themes}"
        puts
      end
    end

### - (`Object`) theme_vulns_count(file = THEMES_VULNS_FILE)

    39
    40
    41

    # File 'lib/wpstools/plugins/stats/stats_plugin.rb', line 39

    def theme_vulns_count(file=THEMES_VULNS_FILE)
      xml(file).xpath("count(//vulnerability)").to_i
    end

### - (`Object`) total_plugins(file = PLUGINS_FULL_FILE)

    43
    44
    45

    # File 'lib/wpstools/plugins/stats/stats_plugin.rb', line 43

    def total_plugins(file=PLUGINS_FULL_FILE)
      lines_in_file(file)
    end

### - (`Object`) total_themes(file = THEMES_FULL_FILE)

    47
    48
    49

    # File 'lib/wpstools/plugins/stats/stats_plugin.rb', line 47

    def total_themes(file=THEMES_FULL_FILE)
      lines_in_file(file)
    end

### - (`Object`) vuln_plugin_count(file = PLUGINS_VULNS_FILE)

    27
    28
    29

    # File 'lib/wpstools/plugins/stats/stats_plugin.rb', line 27

    def vuln_plugin_count(file=PLUGINS_VULNS_FILE)
      xml(file).xpath("count(//plugin)").to_i
    end

### - (`Object`) vuln_theme_count(file = THEMES_VULNS_FILE)

    31
    32
    33

    # File 'lib/wpstools/plugins/stats/stats_plugin.rb', line 31

    def vuln_theme_count(file=THEMES_VULNS_FILE)
      xml(file).xpath("count(//theme)").to_i
    end