Skip to content

Commit baa7987

Browse files
committed
XDG Support for wpscan db
Fix wpscanteam#1586
1 parent 96b6b81 commit baa7987

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/wpscan.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,17 @@ module WPScan
3838
include CMSScanner
3939

4040
APP_DIR = Pathname.new(__FILE__).dirname.join('..', 'app').expand_path
41-
DB_DIR = Pathname.new(Dir.home).join('.wpscan', 'db')
41+
42+
# XDG support for DB_DIR
43+
# If the legacy path exists, it will be used
44+
# Otherwise, we'll use XDG_CACHE_HOME/wpscan/db or ~/.cache/wpscan/db if XDG_CACHE_HOME is not set
45+
legacy_path = Pathname.new(Dir.home).join('.wpscan', 'db')
46+
xdg_path = Pathname.new(ENV['XDG_CACHE_HOME'] || Pathname.new(Dir.home).join('.cache')).join('wpscan', 'db')
47+
DB_DIR = if legacy_path.exist?
48+
legacy_path
49+
else
50+
xdg_path
51+
end
4252

4353
Typhoeus.on_complete do |response|
4454
next if response.cached? || !response.from_vuln_api?

0 commit comments

Comments
 (0)