Class: EmptyPasswordRule

Inherits:
Rule
  • Object
show all
Defined in:
lib/rules/empty_password_rule.rb

Class Method Summary collapse

Methods inherited from Rule

filter_resources, filter_tokens, filter_variables, filter_whitelist, get_comments, get_string_tokens, get_tokens, inherited

Class Method Details

.AnalyzeTokens(tokens) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rules/empty_password_rule.rb', line 14

def self.AnalyzeTokens(tokens)
  result = []

  ftokens = self.get_string_tokens(tokens,'')
  ftokens.each do |token|
    token_value = token.value.downcase
    token_type = token.type.to_s
    if ["EQUALS", "FARROW"].include? token.prev_code_token.type.to_s
      prev_token = token.prev_code_token
      left_side = prev_token.prev_code_token
      if left_side.value.downcase =~ @password_conf.value and ["VARIABLE", "NAME"].include? left_side.type.to_s
        if token_value == ''
          result.append(Sin.new(SinType::EmptyPassword, prev_token.line, prev_token.column, token.line, token.column+token_value.length))
        end
      end
    end
  end

  return result
end