Sha256: 5dd4c5ada8b0d49ebfc347c833cb89cd5a23288f5a246048e120b2a1937fb3fc
Contents?: true
Size: 859 Bytes
Versions: 29
Compression:
Stored size: 859 Bytes
Contents
module Security class CheckForVulnerableCode < RuboCop::Cop::Cop RESULT = {} def self.read_file gem_path = File.expand_path("#{File.dirname(__FILE__)}../../../../") file = File.open("#{gem_path}/vuln_db.json", "r").read.strip json = JSON.parse(file) json["vulnerabilities"]["rails"] end VULNERABILITY_LIST = read_file VULNERABILITY_LIST.each do |string| search = string["search_string"] info = string["info"] RESULT[search.to_sym] = info def_node_matcher search.to_sym, "(send _ :#{search} _)" end def on_send(node) _, method = *node return unless method if (info = RESULT[method]) message = "Rails: Possible vulnerability found, CVE Details - #{info} " add_offense(node, location: :selector, message: message) end end end end
Version data entries
29 entries across 29 versions & 1 rubygems