From b9d865b756c5fa35199f52a5ce0d33519e8f8a3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Thu, 3 Jan 2019 11:48:49 +0100 Subject: [PATCH] fix: Use new API in get_csv.py Fix #314 --- examples/get_csv.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/examples/get_csv.py b/examples/get_csv.py index 33baf62..5921e53 100755 --- a/examples/get_csv.py +++ b/examples/get_csv.py @@ -1,9 +1,9 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- import argparse -from pymisp import PyMISP +from pymisp import ExpandedPyMISP from keys import misp_url, misp_key, misp_verifycert @@ -14,12 +14,20 @@ if __name__ == '__main__': parser.add_argument("-o", "--object_attribute", nargs='+', help="Object attribute column names") parser.add_argument("-t", "--misp_types", nargs='+', help="MISP types to fetch (ip-src, hostname, ...)") parser.add_argument("-c", "--context", action='store_true', help="Add event level context (tags...)") - parser.add_argument("-i", "--ignore", action='store_true', help="Returns the attributes even if the event isn't published, or the attribute doesn't have the to_ids flag") parser.add_argument("-f", "--outfile", help="Output file to write the CSV.") args = parser.parse_args() - pymisp = PyMISP(misp_url, misp_key, misp_verifycert, debug=True) - response = pymisp.get_csv(args.event_id, args.attribute, args.object_attribute, args.misp_types, args.context, args.ignore) + pymisp = ExpandedPyMISP(misp_url, misp_key, misp_verifycert, debug=True) + attr = [] + if args.attribute: + attr += args.attribute + if args.object_attribute: + attr += args.object_attribute + if not attr: + attr = None + print(args.context) + response = pymisp.search(return_format='csv', eventid=args.event_id, requested_attributes=attr, + type_attribute=args.misp_types, include_context=args.context) if args.outfile: with open(args.outfile, 'w') as f: