mirror of https://github.com/MISP/PyMISP
chg: Use MISPObject instead of GenericObjectGenerator
parent
b9ee5c69bb
commit
808e8132f2
|
@ -1,9 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import json
|
||||
from pymisp import ExpandedPyMISP
|
||||
from pymisp.tools import GenericObjectGenerator
|
||||
from pymisp import PyMISP
|
||||
from pymisp import MISPObject
|
||||
from pymisp.tools import update_objects
|
||||
from keys import misp_url, misp_key, misp_verifycert
|
||||
import argparse
|
||||
|
@ -39,20 +38,17 @@ if __name__ == '__main__':
|
|||
if args.force_template_update:
|
||||
print("Updating MISP Object templates...")
|
||||
update_objects()
|
||||
pymisp = ExpandedPyMISP(misp_url, misp_key, misp_verifycert)
|
||||
pymisp = PyMISP(misp_url, misp_key, misp_verifycert)
|
||||
|
||||
misp_object = GenericObjectGenerator("github-user")
|
||||
github_user = json.loads(r.text)
|
||||
misp_object = MISPObject(name="github-user")
|
||||
github_user = r.json()
|
||||
rfollowers = requests.get(github_user['followers_url'])
|
||||
followers = json.loads(rfollowers.text)
|
||||
followers = rfollowers.json()
|
||||
user_followers = []
|
||||
for follower in followers:
|
||||
user_followers.append({"follower": follower['login']})
|
||||
print(user_followers)
|
||||
github_username = [{"bio": github_user['bio'],
|
||||
"link": github_user['html_url'],
|
||||
"user-fullname": github_user['name'],
|
||||
"username": github_user['login']
|
||||
}]
|
||||
misp_object.generate_attributes(github_username)
|
||||
misp_object.add_attribute("follower", follower['login'])
|
||||
misp_object.add_attribute('bio', github_user['bio'])
|
||||
misp_object.add_attribute('link', github_user['html_url'])
|
||||
misp_object.add_attribute('user-fullname', github_user['name'])
|
||||
misp_object.add_attribute('username', github_user['login'])
|
||||
retcode = pymisp.add_object(args.event, misp_object)
|
||||
|
|
Loading…
Reference in New Issue