class Sanctify::Scanner

Attributes

matcher_list[R]
repo[R]

Public Class Methods

new(args) click to toggle source
# File lib/sanctify/scanner.rb, line 8
def initialize(args)
  config = args[:config] || {}
  @repo = Repo.new(args, ignored_paths: config['ignored_paths'])
  @matcher_list = MatcherList.new(
    custom_matchers: config['custom_matchers'],
    disabled_matchers: config['disabled_matchers'])
end

Public Instance Methods

run() click to toggle source
# File lib/sanctify/scanner.rb, line 16
def run
  repo.added_lines.each do |line, path|
    matcher_list.each do |matcher|
      next if matcher.disabled?
      if matcher.regex.match(line)
        raise ScannerError, message(matcher, line, path)
      end
    end
  end
end

Private Instance Methods

message(matcher, line, path) click to toggle source
# File lib/sanctify/scanner.rb, line 29
def message(matcher, line, path)
  "[ERROR] SECRET FOUND (#{matcher.description}): #{line} : #{path}"
end