Sha256: 02fa0997575ad68420fc74625fe13ab4c09abfb38bceaa09833f2c12f47f873c

Contents?: true

Size: 984 Bytes

Versions: 16

Compression:

Stored size: 984 Bytes

Contents

# frozen_string_literal: true

module WPScan
  module Controller
    # Controller to handle the API token
    class VulnApi < CMSScanner::Controller::Base
      ENV_KEY = 'WPSCAN_API_TOKEN'

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

      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

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

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
wpscan-3.8.27 app/controllers/vuln_api.rb
wpscan-3.8.26 app/controllers/vuln_api.rb
wpscan-3.8.25 app/controllers/vuln_api.rb
wpscan-3.8.24 app/controllers/vuln_api.rb
wpscan-3.8.22 app/controllers/vuln_api.rb
wpscan-3.8.21 app/controllers/vuln_api.rb
wpscan-3.8.20 app/controllers/vuln_api.rb
wpscan-3.8.19 app/controllers/vuln_api.rb
wpscan-3.8.18 app/controllers/vuln_api.rb
wpscan-3.8.17 app/controllers/vuln_api.rb
wpscan-3.8.16 app/controllers/vuln_api.rb
wpscan-3.8.15 app/controllers/vuln_api.rb
wpscan-3.8.14 app/controllers/vuln_api.rb
wpscan-3.8.13 app/controllers/vuln_api.rb
wpscan-3.8.12 app/controllers/vuln_api.rb
wpscan-3.8.11 app/controllers/vuln_api.rb