49
49
from parsedmarc .utils import is_mbox , get_reverse_dns
50
50
from parsedmarc import SEEN_AGGREGATE_REPORT_IDS
51
51
52
- http .client ._MAXHEADERS = 200 # pylint:disable=protected-access
52
+ http .client ._MAXHEADERS = 200 # pylint:disable=protected-access
53
53
54
54
formatter = logging .Formatter (
55
55
fmt = "%(levelname)8s:%(filename)s:%(lineno)d:%(message)s" ,
@@ -399,15 +399,15 @@ def process_reports(reports_):
399
399
arg_parser .add_argument (
400
400
"-c" ,
401
401
"--config-file" ,
402
- help = "a path to a configuration file " " (--silent implied)" ,
402
+ help = "a path to a configuration file (--silent implied)" ,
403
403
)
404
404
arg_parser .add_argument (
405
405
"file_path" ,
406
406
nargs = "*" ,
407
407
help = "one or more paths to aggregate or forensic "
408
408
"report files, emails, or mbox files'" ,
409
409
)
410
- strip_attachment_help = "remove attachment payloads from forensic " " report output"
410
+ strip_attachment_help = "remove attachment payloads from forensic report output"
411
411
arg_parser .add_argument (
412
412
"--strip-attachment-payloads" , help = strip_attachment_help , action = "store_true"
413
413
)
@@ -450,14 +450,14 @@ def process_reports(reports_):
450
450
arg_parser .add_argument (
451
451
"-t" ,
452
452
"--dns_timeout" ,
453
- help = "number of seconds to wait for an answer " " from DNS (default: 2.0)" ,
453
+ help = "number of seconds to wait for an answer from DNS (default: 2.0)" ,
454
454
type = float ,
455
455
default = 2.0 ,
456
456
)
457
457
arg_parser .add_argument (
458
458
"--offline" ,
459
459
action = "store_true" ,
460
- help = "do not make online queries for geolocation " " or DNS" ,
460
+ help = "do not make online queries for geolocation or DNS" ,
461
461
)
462
462
arg_parser .add_argument (
463
463
"-s" , "--silent" , action = "store_true" , help = "only print errors"
@@ -734,7 +734,7 @@ def process_reports(reports_):
734
734
if "host" in imap_config :
735
735
opts .imap_host = imap_config ["host" ]
736
736
else :
737
- logger .error ("host setting missing from the " " imap config section" )
737
+ logger .error ("host setting missing from the imap config section" )
738
738
exit (- 1 )
739
739
if "port" in imap_config :
740
740
opts .imap_port = imap_config .getint ("port" )
@@ -750,14 +750,12 @@ def process_reports(reports_):
750
750
if "user" in imap_config :
751
751
opts .imap_user = imap_config ["user" ]
752
752
else :
753
- logger .critical ("user setting missing from the " " imap config section" )
753
+ logger .critical ("user setting missing from the imap config section" )
754
754
exit (- 1 )
755
755
if "password" in imap_config :
756
756
opts .imap_password = imap_config ["password" ]
757
757
else :
758
- logger .critical (
759
- "password setting missing from the " "imap config section"
760
- )
758
+ logger .critical ("password setting missing from the imap config section" )
761
759
exit (- 1 )
762
760
if "reports_folder" in imap_config :
763
761
opts .mailbox_reports_folder = imap_config ["reports_folder" ]
@@ -826,21 +824,20 @@ def process_reports(reports_):
826
824
opts .graph_user = graph_config ["user" ]
827
825
else :
828
826
logger .critical (
829
- "user setting missing from the " " msgraph config section"
827
+ "user setting missing from the msgraph config section"
830
828
)
831
829
exit (- 1 )
832
830
if "password" in graph_config :
833
831
opts .graph_password = graph_config ["password" ]
834
832
else :
835
833
logger .critical (
836
- "password setting missing from the " " msgraph config section"
834
+ "password setting missing from the msgraph config section"
837
835
)
838
836
if "client_secret" in graph_config :
839
837
opts .graph_client_secret = graph_config ["client_secret" ]
840
838
else :
841
839
logger .critical (
842
- "client_secret setting missing from the "
843
- "msgraph config section"
840
+ "client_secret setting missing from the msgraph config section"
844
841
)
845
842
exit (- 1 )
846
843
@@ -853,7 +850,7 @@ def process_reports(reports_):
853
850
opts .graph_tenant_id = graph_config ["tenant_id" ]
854
851
else :
855
852
logger .critical (
856
- "tenant_id setting missing from the " " msgraph config section"
853
+ "tenant_id setting missing from the msgraph config section"
857
854
)
858
855
exit (- 1 )
859
856
@@ -862,24 +859,23 @@ def process_reports(reports_):
862
859
opts .graph_client_secret = graph_config ["client_secret" ]
863
860
else :
864
861
logger .critical (
865
- "client_secret setting missing from the "
866
- "msgraph config section"
862
+ "client_secret setting missing from the msgraph config section"
867
863
)
868
864
exit (- 1 )
869
865
870
866
if "client_id" in graph_config :
871
867
opts .graph_client_id = graph_config ["client_id" ]
872
868
else :
873
869
logger .critical (
874
- "client_id setting missing from the " " msgraph config section"
870
+ "client_id setting missing from the msgraph config section"
875
871
)
876
872
exit (- 1 )
877
873
878
874
if "mailbox" in graph_config :
879
875
opts .graph_mailbox = graph_config ["mailbox" ]
880
876
elif opts .graph_auth_method != AuthMethod .UsernamePassword .name :
881
877
logger .critical (
882
- "mailbox setting missing from the " " msgraph config section"
878
+ "mailbox setting missing from the msgraph config section"
883
879
)
884
880
exit (- 1 )
885
881
@@ -897,7 +893,7 @@ def process_reports(reports_):
897
893
opts .elasticsearch_hosts = _str_to_list (elasticsearch_config ["hosts" ])
898
894
else :
899
895
logger .critical (
900
- "hosts setting missing from the " " elasticsearch config section"
896
+ "hosts setting missing from the elasticsearch config section"
901
897
)
902
898
exit (- 1 )
903
899
if "timeout" in elasticsearch_config :
@@ -935,7 +931,7 @@ def process_reports(reports_):
935
931
opts .opensearch_hosts = _str_to_list (opensearch_config ["hosts" ])
936
932
else :
937
933
logger .critical (
938
- "hosts setting missing from the " " opensearch config section"
934
+ "hosts setting missing from the opensearch config section"
939
935
)
940
936
exit (- 1 )
941
937
if "timeout" in opensearch_config :
@@ -971,21 +967,21 @@ def process_reports(reports_):
971
967
opts .hec = hec_config ["url" ]
972
968
else :
973
969
logger .critical (
974
- "url setting missing from the " " splunk_hec config section"
970
+ "url setting missing from the splunk_hec config section"
975
971
)
976
972
exit (- 1 )
977
973
if "token" in hec_config :
978
974
opts .hec_token = hec_config ["token" ]
979
975
else :
980
976
logger .critical (
981
- "token setting missing from the " " splunk_hec config section"
977
+ "token setting missing from the splunk_hec config section"
982
978
)
983
979
exit (- 1 )
984
980
if "index" in hec_config :
985
981
opts .hec_index = hec_config ["index" ]
986
982
else :
987
983
logger .critical (
988
- "index setting missing from the " " splunk_hec config section"
984
+ "index setting missing from the splunk_hec config section"
989
985
)
990
986
exit (- 1 )
991
987
if "skip_certificate_verification" in hec_config :
@@ -998,9 +994,7 @@ def process_reports(reports_):
998
994
if "hosts" in kafka_config :
999
995
opts .kafka_hosts = _str_to_list (kafka_config ["hosts" ])
1000
996
else :
1001
- logger .critical (
1002
- "hosts setting missing from the " "kafka config section"
1003
- )
997
+ logger .critical ("hosts setting missing from the kafka config section" )
1004
998
exit (- 1 )
1005
999
if "user" in kafka_config :
1006
1000
opts .kafka_username = kafka_config ["user" ]
@@ -1015,29 +1009,28 @@ def process_reports(reports_):
1015
1009
opts .kafka_aggregate_topic = kafka_config ["aggregate_topic" ]
1016
1010
else :
1017
1011
logger .critical (
1018
- "aggregate_topic setting missing from the " " kafka config section"
1012
+ "aggregate_topic setting missing from the kafka config section"
1019
1013
)
1020
1014
exit (- 1 )
1021
1015
if "forensic_topic" in kafka_config :
1022
1016
opts .kafka_forensic_topic = kafka_config ["forensic_topic" ]
1023
1017
else :
1024
1018
logger .critical (
1025
- "forensic_topic setting missing from the " " kafka config section"
1019
+ "forensic_topic setting missing from the kafka config section"
1026
1020
)
1027
1021
if "smtp_tls_topic" in kafka_config :
1028
1022
opts .kafka_smtp_tls_topic = kafka_config ["smtp_tls_topic" ]
1029
1023
else :
1030
1024
logger .critical (
1031
- "forensic_topic setting missing from the "
1032
- "splunk_hec config section"
1025
+ "forensic_topic setting missing from the splunk_hec config section"
1033
1026
)
1034
1027
1035
1028
if "smtp" in config .sections ():
1036
1029
smtp_config = config ["smtp" ]
1037
1030
if "host" in smtp_config :
1038
1031
opts .smtp_host = smtp_config ["host" ]
1039
1032
else :
1040
- logger .critical ("host setting missing from the " " smtp config section" )
1033
+ logger .critical ("host setting missing from the smtp config section" )
1041
1034
exit (- 1 )
1042
1035
if "port" in smtp_config :
1043
1036
opts .smtp_port = smtp_config .getint ("port" )
@@ -1049,23 +1042,21 @@ def process_reports(reports_):
1049
1042
if "user" in smtp_config :
1050
1043
opts .smtp_user = smtp_config ["user" ]
1051
1044
else :
1052
- logger .critical ("user setting missing from the " " smtp config section" )
1045
+ logger .critical ("user setting missing from the smtp config section" )
1053
1046
exit (- 1 )
1054
1047
if "password" in smtp_config :
1055
1048
opts .smtp_password = smtp_config ["password" ]
1056
1049
else :
1057
- logger .critical (
1058
- "password setting missing from the " "smtp config section"
1059
- )
1050
+ logger .critical ("password setting missing from the smtp config section" )
1060
1051
exit (- 1 )
1061
1052
if "from" in smtp_config :
1062
1053
opts .smtp_from = smtp_config ["from" ]
1063
1054
else :
1064
- logger .critical ("from setting missing from the " " smtp config section" )
1055
+ logger .critical ("from setting missing from the smtp config section" )
1065
1056
if "to" in smtp_config :
1066
1057
opts .smtp_to = _str_to_list (smtp_config ["to" ])
1067
1058
else :
1068
- logger .critical ("to setting missing from the " " smtp config section" )
1059
+ logger .critical ("to setting missing from the smtp config section" )
1069
1060
if "subject" in smtp_config :
1070
1061
opts .smtp_subject = smtp_config ["subject" ]
1071
1062
if "attachment" in smtp_config :
@@ -1078,7 +1069,7 @@ def process_reports(reports_):
1078
1069
if "bucket" in s3_config :
1079
1070
opts .s3_bucket = s3_config ["bucket" ]
1080
1071
else :
1081
- logger .critical ("bucket setting missing from the " " s3 config section" )
1072
+ logger .critical ("bucket setting missing from the s3 config section" )
1082
1073
exit (- 1 )
1083
1074
if "path" in s3_config :
1084
1075
opts .s3_path = s3_config ["path" ]
@@ -1103,9 +1094,7 @@ def process_reports(reports_):
1103
1094
if "server" in syslog_config :
1104
1095
opts .syslog_server = syslog_config ["server" ]
1105
1096
else :
1106
- logger .critical (
1107
- "server setting missing from the " "syslog config section"
1108
- )
1097
+ logger .critical ("server setting missing from the syslog config section" )
1109
1098
exit (- 1 )
1110
1099
if "port" in syslog_config :
1111
1100
opts .syslog_port = syslog_config ["port" ]
@@ -1156,17 +1145,17 @@ def process_reports(reports_):
1156
1145
if "host" in gelf_config :
1157
1146
opts .gelf_host = gelf_config ["host" ]
1158
1147
else :
1159
- logger .critical ("host setting missing from the " " gelf config section" )
1148
+ logger .critical ("host setting missing from the gelf config section" )
1160
1149
exit (- 1 )
1161
1150
if "port" in gelf_config :
1162
1151
opts .gelf_port = gelf_config ["port" ]
1163
1152
else :
1164
- logger .critical ("port setting missing from the " " gelf config section" )
1153
+ logger .critical ("port setting missing from the gelf config section" )
1165
1154
exit (- 1 )
1166
1155
if "mode" in gelf_config :
1167
1156
opts .gelf_mode = gelf_config ["mode" ]
1168
1157
else :
1169
- logger .critical ("mode setting missing from the " " gelf config section" )
1158
+ logger .critical ("mode setting missing from the gelf config section" )
1170
1159
exit (- 1 )
1171
1160
1172
1161
if "webhook" in config .sections ():
@@ -1192,8 +1181,7 @@ def process_reports(reports_):
1192
1181
try :
1193
1182
fh = logging .FileHandler (opts .log_file , "a" )
1194
1183
formatter = logging .Formatter (
1195
- "%(asctime)s - "
1196
- "%(levelname)s - [%(filename)s:%(lineno)d] - %(message)s"
1184
+ "%(asctime)s - %(levelname)s - [%(filename)s:%(lineno)d] - %(message)s"
1197
1185
)
1198
1186
fh .setFormatter (formatter )
1199
1187
logger .addHandler (fh )
@@ -1301,7 +1289,7 @@ def process_reports(reports_):
1301
1289
1302
1290
if opts .hec :
1303
1291
if opts .hec_token is None or opts .hec_index is None :
1304
- logger .error ("HEC token and HEC index are required when " " using HEC URL" )
1292
+ logger .error ("HEC token and HEC index are required when using HEC URL" )
1305
1293
exit (1 )
1306
1294
1307
1295
verify = True
@@ -1464,7 +1452,7 @@ def process_reports(reports_):
1464
1452
try :
1465
1453
if opts .imap_user is None or opts .imap_password is None :
1466
1454
logger .error (
1467
- "IMAP user and password must be specified if" "host is specified"
1455
+ "IMAP user and password must be specified ifhost is specified"
1468
1456
)
1469
1457
1470
1458
ssl = True
0 commit comments