Class: WPScan::Controller::VulnApi

Inherits:
CMSScanner::Controller::Base
  • Object
show all
Defined in:
app/controllers/vuln_api.rb

Overview

Controller to handle the API token

Constant Summary collapse

ENV_KEY =
'WPSCAN_API_TOKEN'

Instance Method Summary collapse

Instance Method Details

#after_scanObject



30
31
32
# File 'app/controllers/vuln_api.rb', line 30

def after_scan
  output('status', status: DB::VulnApi.status, api_requests: WPScan.api_requests)
end

#before_scanObject



18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/vuln_api.rb', line 18

def before_scan
  return unless ParsedCli.api_token || ENV.key?(ENV_KEY)

  DB::VulnApi.token = ParsedCli.api_token || ENV[ENV_KEY]

  api_status = DB::VulnApi.status

  raise Error::InvalidApiToken if api_status['status'] == 'forbidden'
  raise Error::ApiLimitReached if api_status['requests_remaining'] == 0
  raise api_status['http_error'] if api_status['http_error']
end

#cli_optionsObject



9
10
11
12
13
14
15
16
# File 'app/controllers/vuln_api.rb', line 9

def cli_options
  [
    OptString.new(
      ['--api-token TOKEN',
       'The WPScan API Token to display vulnerability data, available at https://wpscan.com/profile']
    )
  ]
end