cti-python-stix2/stix2/__init__.py

30 lines
730 B
Python
Raw Normal View History

2017-02-10 22:35:02 +01:00
"""Python APIs for STIX 2."""
2017-01-17 21:37:47 +01:00
2017-03-22 14:05:59 +01:00
# flake8: noqa
2017-04-05 23:12:44 +02:00
import json
2017-02-10 22:35:02 +01:00
from .bundle import Bundle
2017-02-24 19:51:21 +01:00
from .common import ExternalReference, KillChainPhase
2017-02-24 18:56:55 +01:00
from .sdo import AttackPattern, Campaign, CourseOfAction, Identity, Indicator, \
IntrusionSet, Malware, ObservedData, Report, ThreatActor, Tool, \
Vulnerability
2017-02-10 22:35:02 +01:00
from .sro import Relationship
2017-04-05 23:12:44 +02:00
def parse(data):
"""Deserialize a string or file-like object into a STIX object"""
try:
obj = json.loads(data)
except TypeError:
obj = json.load(data)
if 'type' not in obj:
# TODO parse external references, kill chain phases, and granular markings
pass
elif obj['type'] == 'malware':
return sdo.Malware(**obj)
return obj