add a more flexible example for adding file type object#1313
add a more flexible example for adding file type object#1313Delta-Sierra wants to merge 5 commits intoMISP:mainfrom
Conversation
There was a problem hiding this comment.
The script will do the trick, but why not using the CSV loader?
https://github.com/MISP/PyMISP/blob/main/pymisp/tools/csvloader.py
I think it does the same thing for most of the code here, and you just need to iterate over the list of objects it returns to submit it to MISP.
| # -*- coding: utf-8 -*- | ||
|
|
||
| import csv | ||
| from pymisp import ExpandedPyMISP, MISPObject |
There was a problem hiding this comment.
You can (should) use PyMISP and not ExpandedPyMISP. They're the same and ExpandedPyMISP is deprecated.
|
|
||
| pymisp = ExpandedPyMISP(misp_url, misp_key, misp_verifycert) | ||
|
|
||
| f = open(args.attr_file, newline='', encoding="utf-8-sig") |
There was a problem hiding this comment.
Why -sig? utf-8 is default as far as I know.
|
|
||
| for line, row in enumerate(csv_reader, start=2): | ||
| misp_object = MISPObject(name='file') | ||
| for idx, col in matching_columns.items(): |
Cough Probably because I could not find it in the first place... 🤐 Didn't search enough apparently.
If you prefer me to remove it, that's fine by me, otherwise I'll go through the changes you requested :) |
I'm gong to blame the fact it is poorly documented ;)
You have a use case for a script that does what your script does, so I'll definitely merge it. I mostly wanted to make sure we don't duplicate for no reason :) |
No description provided.