fi
# Output the test plan.
-plan 11
+plan 14
# Create a temporary directory and wordlist and ensure it's writable.
tmpdir=`test_tmpdir`
ok_program 'Database does not contain non-ASCII password' 100 '' \
cdb -q "$tmpdir/wordlist.cdb" 'عربى'
+# Regenerate the database, filtering out long passwords.
+ok_program 'Database generation with no long passwords' 0 '' \
+ "$cdbmake" -L 10 "$tmpdir/wordlist"
+ok_program 'Database still contains bitterbane' 0 '1' \
+ cdb -q "$tmpdir/wordlist.cdb" bitterbane
+ok_program 'Database does not contain happenstance' 100 '' \
+ cdb -q "$tmpdir/wordlist.cdb" happenstance
+
# Clean up.
rm -f "$tmpdir/wordlist.cdb"
rm -f "$tmpdir/wordlist"
local $0 = basename($0);
# Parse the argument list.
-my ($ascii, $min_length, $manual);
+my ($ascii, $max_length, $min_length, $manual);
Getopt::Long::config('bundling', 'no_ignore_case');
GetOptions(
'ascii|a' => \$ascii,
+ 'max-length|L=i' => \$max_length,
'min-length|l=i' => \$min_length,
'manual|man|m' => \$manual
);
chomp($word);
my $length = length($word);
next if (defined($min_length) && $length < $min_length);
+ next if (defined($max_length) && $length > $max_length);
if ($ascii) {
next if $word =~ m{ [^[:ascii:]] }xms;
next if $word =~ m{ [[:cntrl:]] }xms;
=head1 SYNOPSIS
-B<cdbmake-wordlist> [B<-am>] [B<-l> I<length>] I<wordlist>
+B<cdbmake-wordlist> [B<-am>] [B<-l> I<min-length>] [B<-L> I<max-length>]
+ I<wordlist>
=head1 DESCRIPTION
from the resulting cdb file, leaving only words that consist solely of
ASCII non-control characters.
+=item B<-L> I<maximum>, B<--max-length>=I<maximum>
+
+Filter all words of length greater than I<maximum> from the resulting cdb
+database. The length of each line (minus the separating newline) in the
+input wordlist will be checked against I<minimum> and will be filtered out
+of the resulting database if it is shorter. Useful for generating
+password dictionaries from word lists that contain random noise that's
+highly unlikely to be used as a password.
+
+The default is to not filter out any words for maximum length.
+
=item B<-l> I<minimum>, B<--min-length>=I<minimum>
Filter all words of length less than I<minimum> from the resulting cdb