Class: Sanctify::Scanner

Inherits:
Object
  • Object
show all
Defined in:
lib/sanctify/scanner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Scanner



8
9
10
11
12
# File 'lib/sanctify/scanner.rb', line 8

def initialize(args)
  @config = args[:config] || {}
  @repo = Repo.new(args, ignored_paths)
  @matcher_list = MatcherList.new
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



7
8
9
# File 'lib/sanctify/scanner.rb', line 7

def config
  @config
end

#matcher_listObject (readonly)

Returns the value of attribute matcher_list.



7
8
9
# File 'lib/sanctify/scanner.rb', line 7

def matcher_list
  @matcher_list
end

#repoObject (readonly)

Returns the value of attribute repo.



7
8
9
# File 'lib/sanctify/scanner.rb', line 7

def repo
  @repo
end

Instance Method Details

#runObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/sanctify/scanner.rb', line 14

def run
  initialize_custom_matchers!
  repo.added_lines.each do |line, path|
    matcher_list.each do |matcher|
      if matcher[:regex].match(line)
        raise ScannerError, "[ERROR] SECRET FOUND (#{matcher[:description]}): #{line} : #{path}"
      end
    end
  end
  puts "SUCCESS! No Secrets Found in #{repo.path}"
end