Sha256: 7e43f600fd101451a96df251ab65690eaa7fafa010b06b0ddba472214ac28289
Contents?: true
Size: 852 Bytes
Versions: 99
Compression:
Stored size: 852 Bytes
Contents
# Copyright (c) 2015 Sqreen. All Rights Reserved. # Please refer to our terms for more information: https://www.sqreen.io/terms.html require 'sqreen/rule_callback' module Sqreen module Rules # Generic regexp based matching class RegexpRuleCB < RuleCB def initialize(*args) super(*args) prepare end def prepare @patterns = [] raw_patterns = @data['values'] if raw_patterns.nil? msg = "no key 'values' in data (had #{@data.keys})" raise Sqreen::Exception, msg end @patterns = raw_patterns.map do |pattern| Regexp.compile(pattern, Regexp::IGNORECASE) end end def match_regexp(str) @patterns.each do |pattern| return pattern if pattern.match(str) end nil end end end end
Version data entries
99 entries across 99 versions & 2 rubygems