Class: Spektr::Checks::BasicAuth

Inherits:
Base
  • Object
show all
Defined in:
lib/spektr/checks/basic_auth.rb

Instance Attribute Summary

Attributes inherited from Base

#name

Instance Method Summary collapse

Methods inherited from Base

#app_version_between?, #dupe?, #model_attribute?, #should_run?, #target_affected?, #user_input?, #version_affected, #version_between?, #warn!

Constructor Details

#initialize(app, target) ⇒ BasicAuth

Returns a new instance of BasicAuth.



5
6
7
8
9
10
# File 'lib/spektr/checks/basic_auth.rb', line 5

def initialize(app, target)
  super
  @name = "Basic Authentication"
  @type = "Password Plaintext Storage"
  @targets = ["Spektr::Targets::Controller"]
end

Instance Method Details

#check_filterObject



17
18
19
20
21
22
23
24
# File 'lib/spektr/checks/basic_auth.rb', line 17

def check_filter
  calls = @target.find_calls(:http_basic_authenticate_with)
  calls.each do |call|
    if call.options[:password] && call.options[:password].value_type == :str
      warn! @target, self, call.location, "Basic authentication password stored in source code"
    end
  end
end

#runObject



12
13
14
15
# File 'lib/spektr/checks/basic_auth.rb', line 12

def run
  return unless super
  check_filter
end