Skip to content

Commit bac3bca

Browse files
committed
Merge branch 'master' of baltig.sandia.gov:scot/SCOT
2 parents eb6cb73 + a2c5c3e commit bac3bca

File tree

445 files changed

+47501
-13369
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

445 files changed

+47501
-13369
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ scot-ui/build/static/js/
2323
scot-ui/build/
2424
.vscode/
2525
emailapi.cfg.pl
26+
local/
27+
**/*.log
28+
**/foo

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,28 @@ IMPORTANT: Read [Issue #55](https://github.com/sandialabs/scot/issues/55) before
3333
Install It!
3434
-----------
3535

36+
** RPM Based Installer (CENTOS 7) **
37+
38+
* clone scot repo or download the files
39+
40+
* scot.perl.rpm.install.tar.gz
41+
* scot.rpm.install.tar.gz
42+
43+
* extract both files:
44+
45+
* tar xzvf scot*tar.gz
46+
47+
* install scot perl first
48+
49+
* cd scot-perl-install
50+
* ./install.sh
51+
* follow instructions presented at end of install
52+
53+
* install scot second
54+
55+
* cd scot-install
56+
* ./install.sh
57+
3658
**Docker Method**
3759

3860
The suggested method for installation of SCOT is using docker. For a walkthrough of installing SCOT via docker, please read: https://github.com/sandialabs/scot/blob/scot-docker/docs/source/scotdocker.rst

bin/bulk_close_alertgroup.pl

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/usr/bin/env perl
2+
3+
use lib '../lib';
4+
use lib '/opt/scot/lib';
5+
use Data::Dumper;
6+
use Scot::Env;
7+
use v5.16;
8+
9+
my $env = Scot::Env->new(config_file=>'/opt/scot/etc/scot.cfg.pl');
10+
my $mongo = $env->mongo;
11+
12+
my $agcol = $mongo->collection('Alertgroup');
13+
my $acol = $mongo->collection('Alert');
14+
15+
my $start = $ARGV[0];
16+
my $end = $ARGV[1];
17+
18+
if ( !defined $start or !defined $end ) {
19+
die "usage error: $0 start_id end_id";
20+
}
21+
22+
if ( $start > $end ) {
23+
my $tmp = $start;
24+
$start = $end;
25+
$end = $tmp;
26+
}
27+
28+
my $agcursor = $agcol->find({
29+
'$and' => [
30+
{ id => { '$gte' => $start + 0 } },
31+
{ id => { '$lte' => $end + 0 }},
32+
],
33+
});
34+
35+
while ( my $ag = $agcursor->next ) {
36+
37+
my $agid = $ag->id + 0;
38+
39+
print "Bulk closing Alertgroup $agid\n";
40+
41+
my $acursor = $acol->find({alertgroup => $agid});
42+
my $count = 0;
43+
while (my $alert = $acursor->next) {
44+
45+
print " closing alert ".$alert->id."\n";
46+
47+
$alert->update({
48+
'$set' => { status => 'closed' },
49+
});
50+
$count++;
51+
52+
}
53+
print " updating alertgroup stats\n";
54+
$ag->update({
55+
'$set' => {
56+
status => 'closed',
57+
closed_count => $count,
58+
open_count => 0,
59+
promoted_count => 0,
60+
updated => time(),
61+
},
62+
});
63+
64+
print " sending mq message to browsers\n";
65+
$env->mq->send("/topic/scot", {
66+
action => 'updated',
67+
data => {
68+
who => 'scot-admin',
69+
type => 'alertgroup',
70+
id => $agid,
71+
},
72+
});
73+
74+
}
75+

bin/bulk_load_ipaddrs.pl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env perl
2+
3+
use lib '../lib';
4+
use lib '/opt/scot/lib';
5+
use Data::Dumper;
6+
use Scot::Env;
7+
use File::Slurp;
8+
9+
my $env = Scot::Env->new(config_file=>'/opt/scot/etc/scot.cfg.pl');
10+
my $mongo = $env->mongo;
11+
my $csvfile = "/tmp/bulk.csv";
12+
13+
my @lines = read_file($csvfile);
14+
15+
foreach my $line (@lines) {
16+
17+
my @row = split(',',$line);
18+
19+
my $ipaddr = $row[0];
20+
my $subnet = $row[1];
21+
my $machine = $row[2];
22+
my $make = $row[3];
23+
my $site = $row[4];
24+
my $area = $row[5];
25+
my $building = $row[6];
26+
my $room = $row[7];
27+
28+
}
29+
30+
31+
32+
33+
34+

bin/email_processor.pl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env perl
2+
3+
use strict;
4+
use warnings;
5+
use lib '../lib';
6+
7+
use Scot::Env;
8+
use Scot::Email::Processor;
9+
10+
my $config = "/opt/scot/etc/email_processing.cfg.pl";
11+
my $env = Scot::Env->new(config_file => $config);
12+
my $processor = Scot::Email::Processor->new({env => $env});
13+
14+
my $flag = $ARGV[0];
15+
16+
unless ($flag) {
17+
$processor->run();
18+
}
19+
20+
if ( $flag eq "-d" ) {
21+
$processor->dump_messages()
22+
}
23+
24+

bin/email_responder.pl

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env perl
2+
3+
# start a Scot::Email::Responder to watch a queue
4+
# first argument is the responder type. eg:
5+
# to start Scot::Email::Responder::Dispatch the
6+
# first arg is "dispatch"
7+
8+
use strict;
9+
use warnings;
10+
use lib '../lib';
11+
use Scot::Env;
12+
use Module::Runtime qw(require_module);
13+
use Try::Tiny;
14+
15+
my $config = "/opt/scot/etc/email_processing.cfg.pl";
16+
my $env = Scot::Env->new(config_file => $config);
17+
18+
my $resptype = $ARGV[0];
19+
20+
if ( ! defined $resptype ) {
21+
$env->log->logdie("Failed to provide command line argument 0: Responder type");
22+
}
23+
24+
my $class = "Scot::Email::Responder::$resptype";
25+
26+
try {
27+
require_module($class);
28+
}
29+
catch {
30+
$env->log->logdie("$_. Failed to load Module $class! Ensure module name patched a responder in /opt/scot/lib/Scot/Email/Responder.");
31+
};
32+
33+
my $queue = $env->responders->{$class}->{queue};
34+
35+
36+
my $responder = $class->new({env => $env, queue => $queue});
37+
$responder->run();

bin/flairer.pl renamed to bin/enricher.pl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,31 @@
66
use lib '../../lib';
77
use lib '../../Scot-Internal-Modules/lib';
88
use lib '/opt/scot/lib';
9-
use v5.16;
10-
use Scot::App::Responder::Flair;
9+
use Scot::Enricher::Worker;
1110
use Data::Dumper;
11+
use utf8::all;
12+
use feature qw(say);
1213

1314
my $config_file = $ENV{'scot_app_flair_config_file'} //
14-
'/opt/scot/etc/flair.cfg.pl';
15+
'/opt/scot/etc/enricher.cfg.pl';
1516
my $env = Scot::Env->new(
1617
config_file => $config_file,
1718
);
1819

20+
die unless defined $env and ref($env) eq "Scot::Env";
21+
1922
$SIG{__DIE__} = sub { our @reason = @_ };
2023

2124
END {
2225
our @reason;
2326
if (@reason) {
24-
say "Flairer died because: @reason";
25-
$env->log->error("Flairer died because: ",{filter=>\&Dumper, value=>\@reason});
27+
say "Enricher died because: @reason";
28+
$env->log->error("Enricher died because: ",{filter=>\&Dumper, value=>\@reason});
2629
}
2730
}
2831

32+
# say Dumper($env);
2933

30-
31-
32-
my $loop = Scot::App::Responder::Flair->new({
33-
env => $env,
34-
});
34+
my $loop = Scot::Enricher::Worker->new(env => $env);
3535
$loop->run();
3636

bin/fix_last_id.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
my $mongo = $env->mongo;
1010

11-
foreach my $colname (qw(appearance alertgroup alert checklist entity entry event guide history incident intel source tag user audit file link)) {
11+
foreach my $colname (qw(appearance remoteflair alertgroup alert checklist entity entry event guide history incident intel source tag user audit file link)) {
1212

1313
print "Getting Max Id of $colname\n";
1414
my $collection = $mongo->collection(ucfirst($colname));

bin/fix_splunk_buttons.pl

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env perl
2+
3+
use lib '../lib';
4+
use lib '../../Scot-Internal-Modules/lib';
5+
use Scot::Env;
6+
use Data::Dumper;
7+
8+
use strict;
9+
use warnings;
10+
11+
my $env = Scot::Env->new(config_file => '/opt/scot/etc/scot.cfg.pl');
12+
my $mongo = $env->mongo;
13+
14+
my $col = $mongo->collection('Entity');
15+
my $cursor = $col->find();
16+
$cursor->immortal(1);
17+
18+
while (my $entity = $cursor->next) {
19+
my $id = $entity->id;
20+
my $data = $entity->data;
21+
if ( defined $data->{splunk} ) {
22+
if (defined $data->{splunkit}) {
23+
printf "%10d SplunkIt present, deleting splunk button\n",$id;
24+
delete $data->{splunk};
25+
$entity->update({'$set' => { data => $data }});
26+
}
27+
else {
28+
my $orig = delete $data->{splunk};
29+
my $title = $orig->{data}->{title};
30+
my $url = $orig->{data}->{url};
31+
32+
(my $newtitle = $title) =~ s/Splunk/SplunkIt/g;
33+
(my $newurl = $url) =~ s/splunk/splunkit/g;
34+
35+
print "$id Changing Data => \n";
36+
print " $newtitle\n";
37+
print " $newurl\n";
38+
39+
$orig->{data} = {
40+
title => $newtitle,
41+
url => $newurl,
42+
};
43+
44+
$data->{splunkit} = $orig;
45+
46+
$entity->update({'$set' => { data => $data }});
47+
}
48+
}
49+
}
50+

bin/flair.pl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env perl
2+
3+
use strict;
4+
use warnings;
5+
use lib '../lib';
6+
use lib '../../lib';
7+
use lib '../../Scot-Internal-Modules/lib';
8+
use lib '/opt/scot/lib';
9+
# use Scot::Flair::Worker;
10+
use Scot::Flair::Worker;
11+
use Scot::Env;
12+
use Data::Dumper;
13+
use utf8::all;
14+
use Carp qw(cluck longmess shortmess);
15+
use feature qw(say);
16+
17+
my $env = Scot::Env->new(config_file => '/opt/scot/etc/flair.cfg.pl');
18+
my $log = $env->log;
19+
20+
die unless defined $env and ref($env) eq "Scot::Env";
21+
22+
$SIG{__DIE__} = sub { our @reason =@_};
23+
24+
END {
25+
our @reason;
26+
if (@reason) {
27+
say "Flair Diead because: @reason";
28+
$env->log->error("Flair died because: ", {filter => \&Dumper, value =>\@reason});
29+
}
30+
}
31+
32+
33+
my $loop = Scot::Flair::Worker->new(env => $env);
34+
$loop->run();
35+

0 commit comments

Comments
 (0)