Uses Pathname#join rather than File#join when possible

This commit is contained in:
erwanlr
2019-02-11 19:30:49 +00:00
parent cdc1dab4a6
commit 7a0f98b2cb
64 changed files with 118 additions and 118 deletions

View File

@@ -33,7 +33,7 @@ module WPScan
include CMSScanner
APP_DIR = Pathname.new(__FILE__).dirname.join('..', 'app').expand_path
DB_DIR = File.join(Dir.home, '.wpscan', 'db')
DB_DIR = Pathname.new(Dir.home).join('.wpscan', 'db')
# Override, otherwise it would be returned as 'wp_scan'
#

View File

@@ -5,7 +5,7 @@ module WPScan
# @return [ String ] The path to the user agents list
def user_agents_list
@user_agents_list ||= File.join(DB_DIR, 'user-agents.txt')
@user_agents_list ||= DB_DIR.join('user-agents.txt').to_s
end
# @return [ String ]

View File

@@ -4,7 +4,7 @@ module WPScan
class Base
# @return [ String ]
def self.db_file
@db_file ||= File.join(DB_DIR, 'dynamic_finders.yml')
@db_file ||= DB_DIR.join('dynamic_finders.yml')
end
# @return [ Hash ]

View File

@@ -33,7 +33,7 @@ module WPScan
# @return [ String ]
def self.wp_fingerprints_path
@wp_fingerprints_path ||= File.join(DB_DIR, 'wp_fingerprints.json')
@wp_fingerprints_path ||= DB_DIR.join('wp_fingerprints.json')
end
# @return [ Hash ]

View File

@@ -4,7 +4,7 @@ module WPScan
class Plugin < WpItem
# @return [ String ]
def self.db_file
@db_file ||= File.join(DB_DIR, 'plugins.json')
@db_file ||= DB_DIR.join('plugins.json')
end
end
end

View File

@@ -4,7 +4,7 @@ module WPScan
class Theme < WpItem
# @return [ String ]
def self.db_file
@db_file ||= File.join(DB_DIR, 'themes.json')
@db_file ||= DB_DIR.join('themes.json')
end
end
end

View File

@@ -15,11 +15,11 @@ module WPScan
attr_reader :repo_directory
def initialize(repo_directory)
@repo_directory = repo_directory
@repo_directory = Pathname.new(repo_directory).expand_path
FileUtils.mkdir_p(repo_directory) unless Dir.exist?(repo_directory)
FileUtils.mkdir_p(repo_directory.to_s) unless Dir.exist?(repo_directory.to_s)
raise "#{repo_directory} is not writable" unless Pathname.new(repo_directory).writable?
raise "#{repo_directory} is not writable" unless repo_directory.writable?
delete_old_files
end
@@ -41,7 +41,7 @@ module WPScan
# @return [ String ]
def last_update_file
@last_update_file ||= File.join(repo_directory, '.last_update')
@last_update_file ||= repo_directory.join('.last_update').to_s
end
# @return [ Boolean ]
@@ -54,7 +54,7 @@ module WPScan
# @return [ Boolean ]
def missing_files?
FILES.each do |file|
return true unless File.exist?(File.join(repo_directory, file))
return true unless File.exist?(repo_directory.join(file))
end
false
end
@@ -85,16 +85,18 @@ module WPScan
res.body.chomp
end
# @return [ String ]
def local_file_path(filename)
File.join(repo_directory, filename.to_s)
repo_directory.join(filename.to_s).to_s
end
def local_file_checksum(filename)
Digest::SHA512.file(local_file_path(filename)).hexdigest
end
# @return [ String ]
def backup_file_path(filename)
File.join(repo_directory, "#{filename}.back")
repo_directory.join("#{filename}.back").to_s
end
def create_backup(filename)

View File

@@ -4,7 +4,7 @@ module WPScan
class Version < WpItem
# @return [ String ]
def self.db_file
@db_file ||= File.join(DB_DIR, 'wordpresses.json')
@db_file ||= DB_DIR.join('wordpresses.json')
end
end
end