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

Version Path
simplycop-1.11.0 lib/simplycop/security/check_for_vulnerable_code.rb
simplycop-1.10.0 lib/simplycop/security/check_for_vulnerable_code.rb
simplycop-1.9.5 lib/simplycop/security/check_for_vulnerable_code.rb
simplycop-1.9.4 lib/simplycop/security/check_for_vulnerable_code.rb
simplycop-1.9.3 lib/simplycop/security/check_for_vulnerable_code.rb
simplycop-1.9.2 lib/simplycop/security/check_for_vulnerable_code.rb
simplycop-1.9.1 lib/simplycop/security/check_for_vulnerable_code.rb
simplycop-1.9.0 lib/simplycop/security/check_for_vulnerable_code.rb
simplycop-1.8.1 lib/simplycop/security/check_for_vulnerable_code.rb
simplycop-1.8.0 lib/simplycop/security/check_for_vulnerable_code.rb
simplycop-1.7.5 lib/simplycop/security/check_for_vulnerable_code.rb
simplycop-1.7.4 lib/simplycop/security/check_for_vulnerable_code.rb
simplycop-1.7.3 lib/simplycop/security/check_for_vulnerable_code.rb
simplycop-1.7.2 lib/simplycop/security/check_for_vulnerable_code.rb
simplycop-1.7.1 lib/simplycop/security/check_for_vulnerable_code.rb
simplycop-1.7.0 lib/simplycop/security/check_for_vulnerable_code.rb
simplycop-1.6.4 lib/simplycop/security/check_for_vulnerable_code.rb
simplycop-1.6.3 lib/simplycop/security/check_for_vulnerable_code.rb
simplycop-1.6.2 lib/simplycop/security/check_for_vulnerable_code.rb
simplycop-1.6.1 lib/simplycop/security/check_for_vulnerable_code.rb