Class: NoHTTPRule

Inherits:
Rule
  • Object
show all
Defined in:
lib/rules/no_http_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



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rules/no_http_rule.rb', line 20

def self.AnalyzeTokens(tokens)
  result = []

  ptokens = self.filter_resources(tokens, @resources_conf.value)
  ctokens = self.filter_variables(ptokens, @keywords_conf.value) #TODO: It's working upside down
  if not @whitelist_conf.value.to_s.empty?
    wtokens = self.filter_whitelist(ctokens, @whitelist_conf.value)
  else
    wtokens = ptokens
  end
  wtokens.each do |token|
    token_value = token.value.downcase
    token_type = token.type.to_s
    if (token_value =~ @http_conf.value)
      result.append(Sin.new(SinType::HttpWithoutTLS, token.line, token.column, token.line, token.column+token_value.length))
    end
  end

  return result
end