Allow to supply mail options as arguments on command line

pull/436/head
Koen Van Impe 2019-08-14 08:46:11 +02:00
parent 3ad3513800
commit 3d2930db12
1 changed files with 11 additions and 0 deletions

View File

@ -351,6 +351,7 @@ if __name__ == '__main__':
parser.add_argument('-t', '--timeframe', required=True, help='Timeframe to include in the report ') parser.add_argument('-t', '--timeframe', required=True, help='Timeframe to include in the report ')
parser.add_argument('-e', '--mispevent', action='store_true', help='Include MISP event titles') parser.add_argument('-e', '--mispevent', action='store_true', help='Include MISP event titles')
parser.add_argument('-m', '--mail', action='store_true', help='Mail the report') parser.add_argument('-m', '--mail', action='store_true', help='Mail the report')
parser.add_argument('-o', '--mailoptions', action='store', help='mailoptions: \'smtp_from=INSERT_FROM;smtp_to=INSERT_TO;smtp_server=localhost\'')
misp = init(misp_url, misp_key, misp_verifycert) misp = init(misp_url, misp_key, misp_verifycert)
args = parser.parse_args() args = parser.parse_args()
@ -363,6 +364,16 @@ if __name__ == '__main__':
smtp_to = 'INSERT_TO' smtp_to = 'INSERT_TO'
smtp_server = 'localhost' smtp_server = 'localhost'
if args.mailoptions:
mailoptions = args.mailoptions.split(';')
for s in mailoptions:
if s.split('=')[0] == 'smtp_from':
smtp_from = s.split('=')[1]
if s.split('=')[0] == 'smtp_to':
smtp_to = s.split('=')[1]
if s.split('=')[0] == 'smtp_server':
smtp_server = s.split('=')[1]
report = get_data(misp, timeframe) report = get_data(misp, timeframe)
if(report): if(report):
report_body, attachments = build_report(report, timeframe, misp_url) report_body, attachments = build_report(report, timeframe, misp_url)