-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add a more flexible example for adding file type object #1313
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not using csv.DictReader instead?
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.