Skip to content

Commit fd44d38

Browse files
committed
updates to
1 parent 7050aeb commit fd44d38

File tree

9 files changed

+103
-84
lines changed

9 files changed

+103
-84
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ RUN mkdir -p /opt/scot4-inbox && mkdir -p /var/log/scot
88
COPY . /opt/scot4-inbox
99

1010
# create user/group for scotinbox
11-
RUN groupadd scotinbox && \
12-
useradd -c "Scot Inbox User" -g "scotinbox" -d /opt/scot4-inbox -M -s /bin/bash scotinbox && \
11+
RUN groupadd -g 5555 scotinbox && \
12+
useradd -c "Scot Inbox User" -g "scotinbox" -u 5555 -d /opt/scot4-inbox -M -s /bin/bash scotinbox && \
1313
chown -R scotinbox:scotinbox /opt/scot4-inbox && \
1414
chown -R scotinbox:scotinbox /var/log/scot
1515

LICENSE

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Copyright (2024) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive license for use of this work by or on behalf of the U.S. Government. Export of this program may require a license from the United States Government.
2+
3+
NOTICE:
4+
5+
For five (5) years from 09/01/2024, the United States Government is granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable worldwide license in this data to reproduce, prepare derivative works, and perform publicly and display publicly, by or on behalf of the Government. There is provision for the possible extension of the term of this license. Subsequent to that period or any extension granted, the United States Government is granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable worldwide license in this data to reproduce, prepare derivative works, distribute copies to the public, perform publicly and display publicly, and to permit others to do so. The specific term of the license can be identified by inquiry made to Sandia Corporation or DOE.
6+
7+
NEITHER THE UNITED STATES GOVERNMENT, NOR THE UNITED STATES DEPARTMENT OF ENERGY, NOR SANDIA CORPORATION, NOR ANY OF THEIR EMPLOYEES, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT, OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS.
8+
9+
Any licensee of this software has the obligation and responsibility to abide by the applicable export control laws, regulations, and general prohibitions relating to the export of technical data. Failure to obtain an export control license or other authority from the Government may result in criminal liability under U.S. laws.
10+
11+
Copyright [2024] Sandia Corporation.
12+
13+
Licensed under the Apache License, Version 2.0 (the "License");
14+
you may not use this file except in compliance with the License.
15+
You may obtain a copy of the License at
16+
17+
http://www.apache.org/licenses/LICENSE-2.0
18+
19+
Unless required by applicable law or agreed to in writing, software
20+
distributed under the License is distributed on an "AS IS" BASIS,
21+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22+
See the License for the specific language governing permissions and
23+
limitations under the License.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ Creates a container to run the SCOT4 inbox processor. The processor will read I
88
This is a convenient way to input data from detection systems, threat intel feeds, and analysts directly into SCOT.
99

1010
For more information and instructions, consult the main SCOT4 documentaton Repository.
11+
https://sandialabs.github.io/scot4-docs/index.html

bin/inbox.pl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ END
3636
EOF
3737

3838
GetOptions(
39-
'config=s' => \$configfile,
4039
'test' => \$test,
4140
'secrets=s' => \$secrets,
4241
'msv' => \$nomsv,
@@ -47,7 +46,6 @@ END
4746
4847
usage: $0
4948
[--test] overwrites peeking to true
50-
[--config=/path/to/inbox.conf] use this file as the configuration file
5149
[--secrets=/path/to/secrets.conf] use this file for secret storage
5250
[--msv] do not filter msv data
5351
[--msvlog=/path/to/log] where to log msv hits
@@ -60,7 +58,6 @@ END
6058
}
6159

6260
my $opts = {
63-
configfile => $configfile,
6461
test => $test,
6562
secrets => $secrets,
6663
msv => $msv,

lib/Scot/Inbox/Config.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ log4perl.appender.InboxLog.layout.ConversionPattern = %d %7p [%P] %15F{1}: %4L %
106106
scot_queue => $ENV{S4INBOX_SCOT_INPUT_QUEUE},
107107
class => $ENV{S4INBOX_MAIL_CLIENT_CLASS},
108108
mboxconfig => $mboxconf,
109+
addsplunksigs => $ENV{S4INBOX_ADD_SPLUNK_SIGS}, # for disconnected nets
109110
};
110111
return $config;
111112
}

lib/Scot/Inbox/Processor.pm

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,29 @@ sub create_alertgroup ($self, $json) {
335335
{filter=>\&Dumper, value=>$response});
336336
};
337337
$self->log->debug("response => ",{filter=>\&Dumper, value=>$rhash});
338+
339+
$self->upsert_signature($json) if (defined $self->config->{addsplunksigs});
340+
338341
return 1;
339342
}
340343
$self->log->error("undefined response from ScotApi!");
341344

342345
return;
343346
}
344347

348+
sub upsert_signature ($self, $json) {
349+
# For a certain disconnected network, there is no dag to pull signatures into SCOT
350+
# but the email includes the signature, so "upsert" a signature
351+
# XXX
352+
# query api to see if signature matches
353+
if ($self->scotapi->signature_exists($json->{search})) {
354+
$self->log->debug("Signature exists. moving on...");
355+
return;
356+
}
357+
358+
$self->scotapi->create_signature($json->{search});
359+
}
360+
345361

346362
sub process_splunk_alert ($self, $msg) {
347363
$self->log->debug("Processing a splunk generated alert...");

t/msv.t

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/opt/perl/bin/perl
2+
3+
use Test::Most;
4+
use Data::Dumper::Concise;
5+
use lib '../lib';
6+
use Scot::Inbox::Processor;
7+
use Scot::Inbox::Config;
8+
use Scot::Inbox::Log;
9+
use Storable qw(dclone);
10+
use feature qw(say);
11+
12+
$ENV{S4INBOX_IMAP_SERVERNAME} = "mail.sandia.gov";
13+
$ENV{S4INBOX_IMAP_PORT} = 993;
14+
$ENV{S4INBOX_IMAP_INBOX} = 'INBOX';
15+
$ENV{S4INBOX_IMAP_USERNAME} = 'scot-alerts';
16+
$ENV{S4INBOX_IMAP_PASSWORD} = '';
17+
$ENV{S4INBOX_SSL_VERIFY} = 1;
18+
$ENV{S4INBOX_IMAP_PEEK} = 1;
19+
$ENV{S4INBOX_PERMITTED_SENDERS} = '*,tbruner@sandia.gov';
20+
$ENV{S4INBOX_MSV_FILTER_DEFINITIONS} = '../etc/msv.defs';
21+
$ENV{S4INBOX_LOG_LEVEL} = 'TRACE';
22+
$ENV{S4INBOX_LOG_FILE} = './test.log';
23+
$ENV{S4INBOX_SCOTAPI_INSECURE_SSL} = 0;
24+
$ENV{S4INBOX_API_KEY} = '';
25+
$ENV{S4INBOX_API_URI_ROOT} = 'https://scot4-qual/api/v1';
26+
$ENV{S4INBOX_MSV_DBM_FILE} = '../var/msgids.dbm';
27+
$ENV{S4INBOX_MAIL_CLIENT_CLASS} = 'Scot::Inbox::Imap';
28+
$ENV{S4INBOX_SCOT_INPUT_QUEUE} = 'alertgroup';
29+
30+
my $config = build_config();
31+
my $log = start_logging($config->{log});
32+
my $proc = Scot::Inbox::Processor->new(
33+
config => $config,
34+
log => $log,
35+
);
36+
37+
my $json = {
38+
message_id => '<1234567@098765>',
39+
data => [
40+
{
41+
domain => 'ct-salsa.ca.sandia.gov',
42+
stuff => 'goes here',
43+
},
44+
{
45+
domain => 'www.google.com',
46+
stuff => 'dies here',
47+
},
48+
],
49+
};
50+
my $json2 = dclone($json);
51+
52+
$proc->filter_msv($json);
53+
54+
say Dumper($json);
55+
56+
$proc->filter_msv($json2);
57+
58+
say Dumper($json2);
59+
60+

t/mtest.pl

Lines changed: 0 additions & 55 deletions
This file was deleted.

t/test.log

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)