This repository has been archived by the owner on Mar 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtest
executable file
·138 lines (117 loc) · 4.22 KB
/
test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/usr/bin/env bash
if [ -z "${SAQ_HOME}" ]
then
echo "missing env var SAQ_HOME"
exit 1
fi
cd "${SAQ_HOME}" || { echo "cannot cd to ${SAQ_HOME}"; exit 1; }
if [ -f "data/logs/unittest.log" ]
then
rm data/logs/unittest.log
fi
if [ ! -d data_unittest ]
then
mkdir data_unittest
fi
if [ -d data_unittest/error_reports ]
then
rm -rf data_unittest/error_reports && mkdir data_unittest/error_reports
fi
if [ -d data_unittest/logs ]
then
rm -rf data_unittest/logs && mkdir data_unittest/logs
else
mkdir data_unittest/logs
fi
export SAQ_UNIT_TESTING=1
#bin/build-unittest-database
# if we passed no parameters then we run all the tests
if [ "$#" -eq "0" ]
then
python3 -W ignore -m unittest -f -v \
$(find -L saq -type f -name 'test*.py' -ipath '*/site/*' | sed -e 's;^lib/;;' -e 's/\.py$//' -e 's;/;.;g') \
saq.analysis.test \
saq.service.test \
saq.util.test \
saq.util.test_filter \
saq.submission.test \
saq.collectors.test \
saq.collectors.test_email \
saq.collectors.test_falcon \
saq.collectors.test_hunter \
saq.collectors.test_qradar_hunter \
saq.collectors.test_query_hunter \
saq.collectors.test_splunk_hunter \
saq.database.test \
saq.error.test \
saq.extractors.ews.test \
saq.extractors.graph.test \
saq.test_email \
saq.test_crawlphish \
saq.configuration.test \
saq.test_crypto \
saq.test_util \
saq.test_locks \
saq.test_graph_api \
saq.persistence.test \
saq.engine.test \
saq.modules.test_alerts \
saq.modules.test_asset \
saq.modules.test_cloudphish \
saq.modules.test_command_line \
saq.modules.test_crits \
saq.modules.test_email \
saq.modules.test_file_analysis \
saq.modules.test_http \
saq.modules.test_intel \
saq.modules.test_url \
saq.modules.test_render \
saq.observables.test \
aceapi.analysis.test \
aceapi.engine.test \
aceapi.cloudphish.test \
aceapi.events.test \
test_ace_api \
# reintroduce these
#saq.collectors.test_http \
# TODO reintroduce these next two somehow
#saq.engine.test_cloudphish \
#saq.test_detection \
#saq.messaging.test \
#saq.test_pds \
#saq.modules.test_pds \
#saq.modules.test_vx \
# no longer a thing
#saq.engine.test_email \
#saq.engine.test_ace \
#saq.test_lock \
# these needs to be created
#saq.modules.test_qradar \
#saq.collectors.test_cb_binaries \
exit 0
fi
# otherwise we run whatever test is specified on the command line
python3 -W ignore -m unittest -f -v "$@"
#PYTHONPATH=lib python3 -W ignore -m unittest -v saq.engine.test_cloudphish.CloudPhishEngineTestCase.test_cloudphish_engine_007_http_clear_alert
#PYTHONPATH=lib python3 -W ignore -m unittest -v saq.modules.test_asset.AssetAnalysisModuleTestCase.test_carbon_black_asset_ident_000
#PYTHONPATH=lib python3 -W ignore -m unittest -v saq.engine.test_ace.ACECoreEngineTestCase.test_ace_engine_002_persistent_engine
#PYTHONPATH=lib python3 -W ignore -m unittest -v saq.engine.test_email.EmailEngineTestCase.test_email_engine_003_email_processing
#PYTHONPATH=lib python3 -W ignore -m unittest -v saq.engine.test_engine.EngineTestCase.test_engine_024_mysql_engine_submit
#PYTHONPATH=lib python3 -W ignore -m unittest -v saq.test_analysis.RootAnalysisTestCase.test_analysis_004_has_observable
#PYTHONPATH=lib python3 -W ignore -m unittest -v saq.test_database.DatabaseTestCase.test_database_007_caching_processes
if [ -f data/logs/unittest.log ]
then
GREP_COLORS='mt=01;103' grep --color=always \\[WARNING\\] data/logs/unittest.log | grep -v 'request for unknown encrypted password'
GREP_COLORS='mt=01;31' grep --color=always \\[ERROR\\] data/logs/unittest.log
GREP_COLORS='mt=01;32' grep --color=always MARKER data/logs/unittest.log
fi
if [ -d $data_dir/error_reports ]
then
if [ $( ls $data_dir/error_reports | wc -l ) -gt "0" ]
then
echo
echo "*** ERRORS REPORTED ** "
echo
cat $data_dir/error_reports/* 2> /dev/null
fi
fi