Class: Ronin::Wordlists::WordlistRepo
- Inherits:
-
Object
- Object
- Ronin::Wordlists::WordlistRepo
- Includes:
- WordlistMetadata
- Defined in:
- lib/ronin/wordlists/wordlist_repo.rb
Overview
Represents a git repository of wordlists.
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
The name of the wordlist repository.
-
#path ⇒ String
readonly
The path to the wordlist repository.
Class Method Summary collapse
-
.download(url, dest_dir = Dir.pwd) ⇒ WordlistRepo
Clones a wordlist repository from the given git URL.
Instance Method Summary collapse
-
#delete ⇒ Object
Deletes the wordlist repository.
-
#filename ⇒ String
The name of the wordlist repository directory.
-
#git? ⇒ Boolean
Determines if the wordlist repository uses Git.
-
#initialize(path, **kwargs) ⇒ WordlistRepo
constructor
Initializes the wordlist repository.
-
#type ⇒ :git
The wordlist type.
-
#update ⇒ Object
Updates the wordlist repository.
-
#url ⇒ String?
The URL of the wordlist repository.
Constructor Details
#initialize(path, **kwargs) ⇒ WordlistRepo
Initializes the wordlist repository.
60 61 62 63 64 65 |
# File 'lib/ronin/wordlists/wordlist_repo.rb', line 60 def initialize(path,**kwargs) super(**kwargs) @path = path @name = File.basename(@path) end |
Instance Attribute Details
#name ⇒ String (readonly)
The name of the wordlist repository.
44 45 46 |
# File 'lib/ronin/wordlists/wordlist_repo.rb', line 44 def name @name end |
#path ⇒ String (readonly)
The path to the wordlist repository.
39 40 41 |
# File 'lib/ronin/wordlists/wordlist_repo.rb', line 39 def path @path end |
Class Method Details
.download(url, dest_dir = Dir.pwd) ⇒ WordlistRepo
Clones a wordlist repository from the given git URL.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/ronin/wordlists/wordlist_repo.rb', line 83 def self.download(url,dest_dir=Dir.pwd) uri = URI(url) url = url.to_s repo_name = File.basename(uri.path,'.git') repo_path = File.join(dest_dir,repo_name) case system('git','clone','--depth','1','--',url,repo_path) when true new(repo_path, url: url) when false raise(DownloadFailed,"git command failed: git clone --depth 1 -- #{url} #{repo_path}") when nil raise(DownloadFailed,"git is not installed on the system") end end |
Instance Method Details
#delete ⇒ Object
Deletes the wordlist repository.
161 162 163 |
# File 'lib/ronin/wordlists/wordlist_repo.rb', line 161 def delete FileUtils.rm_rf(@path) end |
#filename ⇒ String
The name of the wordlist repository directory.
122 123 124 |
# File 'lib/ronin/wordlists/wordlist_repo.rb', line 122 def filename File.basename(@path) end |
#git? ⇒ Boolean
Determines if the wordlist repository uses Git.
113 114 115 |
# File 'lib/ronin/wordlists/wordlist_repo.rb', line 113 def git? File.directory?(File.join(@path,'.git')) end |
#type ⇒ :git
The wordlist type.
104 105 106 |
# File 'lib/ronin/wordlists/wordlist_repo.rb', line 104 def type :git end |
#update ⇒ Object
Updates the wordlist repository.
146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/ronin/wordlists/wordlist_repo.rb', line 146 def update if git? case system('git','pull','-C',@path) when true then true when false raise(DownloadFailed,"git command failed: git pull -C #{@path}") when nil raise(DownloadFailed,"git is not installed on the system") end end end |
#url ⇒ String?
The URL of the wordlist repository.
131 132 133 134 135 136 137 |
# File 'lib/ronin/wordlists/wordlist_repo.rb', line 131 def url @url ||= if git? Dir.chdir(@path) do `git config --get remote.origin.url`.chomp end end end |