39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/zxcvbn/feedback.rb', line 39
def self.get_match_feedback(match, is_sole_match)
case match["pattern"]
when "dictionary"
get_dictionary_match_feedback(match, is_sole_match)
when "spatial"
warning = if match["turns"] == 1
"Straight rows of keys are easy to guess"
else
"Short keyboard patterns are easy to guess"
end
{
"warning" => warning,
"suggestions" => ["Use a longer keyboard pattern with more turns"]
}
when "repeat"
warning = if match["base_token"].length == 1
'Repeats like "aaa" are easy to guess'
else
'Repeats like "abcabcabc" are only slightly harder to guess than "abc"'
end
{
"warning" => warning,
"suggestions" => ["Avoid repeated words and characters"]
}
when "sequence"
{
"warning" => "Sequences like abc or 6543 are easy to guess",
"suggestions" => ["Avoid sequences"]
}
when "regex"
if match["regex_name"] == "recent_year"
{
"warning" => "Recent years are easy to guess",
"suggestions" => ["Avoid recent years", "Avoid years that are associated with you"]
}
end
when "date"
{
"warning" => "Dates are often easy to guess",
"suggestions" => ["Avoid dates and years that are associated with you"]
}
end
end
|