Module: Codesake::Utils::Secrets

Included in:
Engine::Jsp, Engine::Text
Defined in:
lib/codesake/utils/secrets.rb

Constant Summary collapse

DEFAULT_SECRETS =
["secret", "password", "username", "login", "xxx", "fixme", "fix", "todo", "passwd"]

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#reserved_keywordsObject

Returns the value of attribute reserved_keywords.



6
7
8
# File 'lib/codesake/utils/secrets.rb', line 6

def reserved_keywords
  @reserved_keywords
end

#secretsObject

Returns the value of attribute secrets.



5
6
7
# File 'lib/codesake/utils/secrets.rb', line 5

def secrets
  @secrets
end

Instance Method Details

#add(word) ⇒ Object



16
17
18
19
# File 'lib/codesake/utils/secrets.rb', line 16

def add(word)
  @secrets << word
  @secrets
end

#find_reserved_keywordsObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/codesake/utils/secrets.rb', line 25

def find_reserved_keywords

  ret = []

  @file_content.each_with_index do |l, i|
    l = l.unpack("C*").pack("U*")
    l.split.each do |tok|
      # ret << {:line=> i+1, :matcher=>tok, :source_line=>l} if @secrets.include?(tok.downcase)
      ret << {:line=> i+1, :matcher=>tok } if @secrets.include?(tok.downcase)

    end
  end

  ret
end

#initializeObject



8
9
10
# File 'lib/codesake/utils/secrets.rb', line 8

def initialize
  load_secrets
end

#load_secretsObject



12
13
14
# File 'lib/codesake/utils/secrets.rb', line 12

def load_secrets
  @secrets = DEFAULT_SECRETS
end

#reserved?(word) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/codesake/utils/secrets.rb', line 21

def reserved?(word)
  @secrets.include?(word)
end