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
-
#reserved_keywords ⇒ Object
Returns the value of attribute reserved_keywords.
-
#secrets ⇒ Object
Returns the value of attribute secrets.
Instance Method Summary collapse
- #add(word) ⇒ Object
- #find_reserved_keywords ⇒ Object
- #initialize ⇒ Object
- #load_secrets ⇒ Object
- #reserved?(word) ⇒ Boolean
Instance Attribute Details
#reserved_keywords ⇒ Object
Returns the value of attribute reserved_keywords.
6 7 8 |
# File 'lib/codesake/utils/secrets.rb', line 6 def reserved_keywords @reserved_keywords end |
#secrets ⇒ Object
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_keywords ⇒ Object
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 |
#initialize ⇒ Object
8 9 10 |
# File 'lib/codesake/utils/secrets.rb', line 8 def initialize load_secrets end |
#load_secrets ⇒ Object
12 13 14 |
# File 'lib/codesake/utils/secrets.rb', line 12 def load_secrets @secrets = DEFAULT_SECRETS end |
#reserved?(word) ⇒ Boolean
21 22 23 |
# File 'lib/codesake/utils/secrets.rb', line 21 def reserved?(word) @secrets.include?(word) end |