fi
# Output the test plan.
-plan 14
+plan 18
# Create a temporary directory and wordlist and ensure it's writable.
tmpdir=`test_tmpdir`
ok_program 'Database does not contain happenstance' 100 '' \
cdb -q "$tmpdir/wordlist.cdb" happenstance
+# Regenerate the database, filtering out words starting with b or ending in d.
+ok_program 'Database generation with no b passwords' 0 '' \
+ "$cdbmake" -x '\Ab' -x '.*d' "$tmpdir/wordlist"
+ok_program 'Database does not contain bitterbane' 100 '' \
+ cdb -q "$tmpdir/wordlist.cdb" bitterbane
+ok_program 'Database still contains happenstance' 0 '1' \
+ cdb -q "$tmpdir/wordlist.cdb" happenstance
+ok_program 'Database does not contain password' 100 '' \
+ cdb -q "$tmpdir/wordlist.cdb" password
+
# Clean up.
rm -f "$tmpdir/wordlist.cdb"
rm -f "$tmpdir/wordlist"
local $0 = basename($0);
# Parse the argument list.
-my ($ascii, $max_length, $min_length, $manual);
+my ($ascii, @exclude, $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
+ 'manual|man|m' => \$manual,
+ 'exclude|x=s' => \@exclude,
);
if ($manual) {
print_fh(\*STDOUT, "Feeding myself to perldoc, please wait...\n");
or die "$0: cannot open input file $input: $!\n";
open(my $out, '>', $output)
or die "$0: cannot create output file $output: $!\n";
-while (defined(my $word = <$in>)) {
+WORD: while (defined(my $word = <$in>)) {
chomp($word);
my $length = length($word);
next if (defined($min_length) && $length < $min_length);
next if $word =~ m{ [^[:ascii:]] }xms;
next if $word =~ m{ [[:cntrl:]] }xms;
}
+ for my $pattern (@exclude) {
+ next WORD if $word =~ m{ $pattern }xms;
+ }
print_fh($out, "+$length,1:$word->1\n");
}
print_fh($out, "\n");
=head1 SYNOPSIS
B<cdbmake-wordlist> [B<-am>] [B<-l> I<min-length>] [B<-L> I<max-length>]
- I<wordlist>
+ [B<-x> I<exclude> ...] I<wordlist>
=head1 DESCRIPTION
Print out this documentation (which is done simply by feeding the script to
C<perldoc -t>).
+=item B<-x> I<exclude>, B<--exclude>=I<exclude>
+
+Filter all words matching the regular expression I<exclude> from the
+resulting cdb database. This regular expression will be matched against
+each line of the source wordlist after the trailing newline is removed.
+This option may be given repeatedly to add multiple exclusion regexes.
+
=back
=head1 AUTHOR