From d7c4053813f13b00034b0b6b62a6d84b7ce8e59f Mon Sep 17 00:00:00 2001 From: Aaron Lichtman Date: Fri, 28 Apr 2023 19:27:51 -0700 Subject: [PATCH] XDG Support for wpscan db Fix #1586 --- lib/wpscan.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/wpscan.rb b/lib/wpscan.rb index 95500741a..a26eb17c9 100644 --- a/lib/wpscan.rb +++ b/lib/wpscan.rb @@ -38,7 +38,15 @@ module WPScan include CMSScanner APP_DIR = Pathname.new(__FILE__).dirname.join('..', 'app').expand_path - DB_DIR = Pathname.new(Dir.home).join('.wpscan', 'db') + + # XDG support for DB_DIR + legacy_path = Pathname.new(Dir.home).join('.wpscan', 'db') + xdg_path = Pathname.new(ENV['XDG_CACHE_HOME'] || Dir.home.join('.cache')).join('wpscan', 'db') + if legacy_path.exist? + DB_DIR = legacy_path + else + DB_DIR = xdg_path + end Typhoeus.on_complete do |response| next if response.cached? || !response.from_vuln_api?