Class: Decidim::CommonPasswords
- Inherits:
-
Object
- Object
- Decidim::CommonPasswords
show all
- Includes:
- Singleton
- Defined in:
- decidim-core/lib/decidim/common_passwords.rb
Defined Under Namespace
Classes: FileNotFoundError
Constant Summary
collapse
- URLS =
%w(
https://raw.githubusercontent.com/danielmiessler/SecLists/master/Passwords/xato-net-10-million-passwords-1000000.txt
https://raw.githubusercontent.com/danielmiessler/SecLists/master/Passwords/darkweb2017-top10000.txt
https://raw.githubusercontent.com/danielmiessler/SecLists/master/Passwords/Common-Credentials/10-million-password-list-top-1000000.txt
).freeze
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of CommonPasswords.
15
16
17
18
19
20
21
|
# File 'decidim-core/lib/decidim/common_passwords.rb', line 15
def initialize
raise FileNotFoundError unless File.exist?(self.class.common_passwords_path)
File.open(self.class.common_passwords_path, "r") do |file|
@passwords = file.read.split
end
end
|
Instance Attribute Details
#passwords ⇒ Object
Returns the value of attribute passwords.
7
8
9
|
# File 'decidim-core/lib/decidim/common_passwords.rb', line 7
def passwords
@passwords
end
|
Class Method Details
.common_password_list ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'decidim-core/lib/decidim/common_passwords.rb', line 29
def self.common_password_list
@common_password_list ||= begin
list = []
URLS.each do |url|
URI.parse(url).open do |data|
data.read.split.each do |line|
list << line if line.length >= min_length
end
end
end
list.uniq
end
end
|
.common_passwords_path ⇒ Object
50
51
52
|
# File 'decidim-core/lib/decidim/common_passwords.rb', line 50
def self.common_passwords_path
File.join(__dir__, "db", "common-passwords.txt")
end
|
.update_passwords! ⇒ Object
23
24
25
26
27
|
# File 'decidim-core/lib/decidim/common_passwords.rb', line 23
def self.update_passwords!
File.open(common_passwords_path, "w") do |file|
common_password_list.each { |item| file.puts(item) }
end
end
|