Skip to content

Commit

Permalink
basic tagger tests
Browse files Browse the repository at this point in the history
  • Loading branch information
awick committed Sep 16, 2014
1 parent 4fa7ddd commit 097d5a8
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 4 deletions.
5 changes: 5 additions & 0 deletions capture/plugins/tagger.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,11 @@ gboolean tagger_fetch_files (gpointer sync)
*/
void moloch_plugin_init()
{
if (config.dryRun) {
LOG("Not enabling in dryRun mode");
return;
}

HASH_INIT(s_, allFiles, moloch_string_hash, moloch_string_cmp);
HASH_INIT(s_, allDomains, moloch_string_hash, moloch_string_cmp);
HASH_INIT(s_, allMD5s, moloch_string_hash, moloch_string_cmp);
Expand Down
2 changes: 1 addition & 1 deletion tests/config.test.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ rirFile = ipv4-address-space.csv
parsersDir = ../capture/parsers;parsers
pluginsDir = plugins;../tests/plugins;../capture/plugins
yara=rules.yara
plugins=test.so
smtpIpHeaders=X-Originating-IP:;X-Barracuda-Apparent-Source-IP:
keyFile=
spiDataMaxIndices=-1
Expand All @@ -18,6 +17,7 @@ viewPort=8123
[test]
passwordSecret=
regressionTests=true
plugins=test.so;tagger.so


[headers-http-request]
Expand Down
3 changes: 3 additions & 0 deletions tests/host.tagger1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cdn.betchoice.com
www.example.com
cluster5.us.messagelabs.com
1 change: 1 addition & 0 deletions tests/ip.tagger1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10.0.0.3
1 change: 1 addition & 0 deletions tests/md5.tagger1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5ff7b2c69c3b22826a717cd5ea4c9f32
18 changes: 15 additions & 3 deletions tests/tests.pl
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ sub errTest {
sub doViewer {
my ($cmd) = @_;

plan tests => 897;
plan tests => 903;

die "Must run in tests directory" if (! -f "../db/db.pl");

Expand All @@ -177,12 +177,19 @@ sub doViewer {
} else {
system("../db/db.pl localhost:9200 initnoprompt 2>&1 1>/dev/null");
}

print ("Loading tagger\n");
system("../capture/plugins/taggerUpload.pl localhost:9200 ip ip.tagger1.json iptaggertest");
system("../capture/plugins/taggerUpload.pl localhost:9200 host host.tagger1.json hosttaggertest");
system("../capture/plugins/taggerUpload.pl localhost:9200 md5 md5.tagger1.json md5taggertest");

$main::userAgent->get("http://localhost:9200/_flush");
$main::userAgent->get("http://localhost:9200/_refresh");

print ("Loading PCAP\n");
system("/bin/cp socks-http-example.pcap copytest.pcap");
my $cmd = "../capture/moloch-capture -c config.test.ini -n test -R .";

my $cmd = "../capture/moloch-capture -c config.test.ini -n test -R .";
if (!$main::debug) {
$cmd .= " 2>&1 1>/dev/null";
} else {
Expand Down Expand Up @@ -680,7 +687,12 @@ sub doViewer {
countTest(2, "date=-1&expression=" . uri_escape("(file=$pwd/dns-flags0110.pcap||file=$pwd/dns-dnskey.pcap)&&mac=/00:.*/"));
countTest(2, "date=-1&expression=" . uri_escape("(file=$pwd/dns-flags0110.pcap||file=$pwd/dns-dnskey.pcap)&&mac=[00:23:04:17:9b:00,00:1a:e3:dc:2e:c0]"));

# bigendian tests
# tagger tests
countTest(7, "date=-1&expression=" . uri_escape("(file=$pwd/copytest.pcap||file=$pwd/socks-https-example.pcap||file=$pwd/dns-mx.pcap)&&tags=hosttaggertest"));
countTest(2, "date=-1&expression=" . uri_escape("(file=$pwd/socks5-rdp.pcap||file=$pwd/bt-udp.pcap)&&tags=iptaggertest"));
countTest(1, "date=-1&expression=" . uri_escape("(file=$pwd/socks5-rdp.pcap||file=$pwd/http-content-gzip.pcap)&&tags=md5taggertest"));

# bigendian pcap file tests
my $json = viewerGet("/sessions.json?date=-1&expression=" . uri_escape("file=$pwd/bigendian.pcap"));
is ($json->{iTotalDisplayRecords}, 1, "bigendian iTotalDisplayRecords");
my $response = $main::userAgent->get("http://localhost:8123/test/raw/" . $json->{aaData}->[0]->{id} . "?type=src");
Expand Down

0 comments on commit 097d5a8

Please sign in to comment.