Advertisement
Guest User

Untitled

a guest
Jul 6th, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. # RubyGems client upgrader script
  2.  
  3. # Set some basic items to build on
  4. home_path = Dir.home
  5.  
  6. # This is set for user RVM install (modify as needed for system RVM install)
  7. rvm_path = home_path + "/.rvm"
  8. rvm_rubies_path = rvm_path + "/rubies/"
  9.  
  10. check_paths = [
  11. rvm_rubies_path, # The locations of RVM Rubies for a user install
  12. "/usr/" # The location for a system install on Mac
  13. ]
  14.  
  15. check_paths.each do |check_path|
  16. Dir.entries(check_path).each do |ruby_path|
  17. gem_path = check_path + ruby_path + "/bin/gem"
  18.  
  19. if File.exists?(gem_path)
  20. puts "Found a RubyGems client binary at #{gem_path}"
  21.  
  22. gem_version = `#{gem_path} --version`.chomp
  23.  
  24. unless gem_version.empty?
  25.  
  26. if gem_version == "2.4.8"
  27. puts "RubyGems client binary at version #{gem_version} (PATCHED)"
  28. else
  29. puts "RubyGems client binary at version #{gem_version} (VULNERABLE)"
  30. puts "Attempting to upgrade RubyGems client"
  31. puts `#{gem_path} update --system`
  32. end
  33.  
  34. end
  35. end
  36. end
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement