Skip to content

Commit 507f5d6

Browse files
committed
change class TTPs to no longer be EntityList - fixes #357
1 parent 01d2441 commit 507f5d6

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

stix/core/stix_package.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def add_ttp(self, ttp):
180180
"""
181181
if self.ttps is None:
182182
self.ttps = TTPs()
183-
self.ttps.append(ttp)
183+
self.ttps.ttp.append(ttp)
184184

185185
def add_report(self, report):
186186
"""Adds a :class:`.Report` object to the :attr:`reports` collection.

stix/core/ttps.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55
from functools import partial
66

77
# mixbox
8-
from mixbox import entities
98
from mixbox import fields
109

1110
# stix
1211
import stix
13-
from stix import utils
1412
from stix.ttp import TTP
1513
from stix.common.kill_chains import KillChains
1614
from stix.bindings import stix_core as core_binding
@@ -19,24 +17,18 @@
1917
from stix.utils.deprecated import IdrefDeprecatedList
2018

2119

22-
class TTPs(stix.EntityList):
20+
class TTPs(stix.Entity):
2321
_binding = core_binding
2422
_binding_class = _binding.TTPsType
2523
_namespace = 'http://stix.mitre.org/stix-1'
2624

27-
ttps = fields.TypedField(
28-
name="TTP",
29-
type_=TTP,
30-
multiple=True,
31-
key_name="ttps",
32-
listfunc=partial(IdrefDeprecatedList, type=TTP)
33-
)
34-
25+
ttp = fields.TypedField("TTP", TTP, multiple=True, key_name="ttps", listfunc=partial(IdrefDeprecatedList, type=TTP))
3526
kill_chains = fields.TypedField("Kill_Chains", KillChains)
3627

3728
def __init__(self, ttps=None):
38-
super(TTPs, self).__init__(ttps)
29+
super(TTPs, self).__init__()
30+
self.ttp = ttps
3931
self.kill_chains = KillChains()
4032

4133
def add_ttp(self, ttp):
42-
self.append(ttp)
34+
self.ttp.append(ttp)

stix/test/extensions/malware/maec_4_1_malware_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,14 @@ def test_parse_malware(self):
134134
"""Test parsing a normal MalwareInstance from XML
135135
"""
136136
stix_pkg = STIXPackage.from_xml(self.XML)
137-
mw = stix_pkg.ttps[0].behavior.malware_instances[0].to_dict()
137+
mw = stix_pkg.ttps.ttp[0].behavior.malware_instances[0].to_dict()
138138
self.assertTrue('names' in mw)
139139

140140
def test_parse_malware_maec(self):
141141
"""Test parsing a MaecInstance from XML
142142
"""
143143
stix_pkg = STIXPackage.from_xml(self.XML_MAEC)
144-
mw = stix_pkg.ttps[0].behavior.malware_instances[0].to_dict()
144+
mw = stix_pkg.ttps.ttp[0].behavior.malware_instances[0].to_dict()
145145
self.assertTrue('names' in mw)
146146

147147

0 commit comments

Comments
 (0)