Skip to content

Commit

Permalink
change class TTPs to no longer be EntityList - fixes #357
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanvg committed Apr 17, 2020
1 parent 821d4c7 commit 2720066
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
2 changes: 1 addition & 1 deletion stix/core/stix_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def add_ttp(self, ttp):
"""
if self.ttps is None:
self.ttps = TTPs()
self.ttps.append(ttp)
self.ttps.ttp.append(ttp)

def add_related_package(self, related_package):
"""Adds a :class:`.RelatedPackage` object to the
Expand Down
20 changes: 5 additions & 15 deletions stix/core/ttps.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,28 @@
# Copyright (c) 2016, The MITRE Corporation. All rights reserved.
# See LICENSE.txt for complete terms.

# stdlib
from functools import partial

# mixbox
from mixbox import entities
from mixbox import fields

# stix
import stix
from stix import utils
from stix.ttp import TTP
from stix.common.kill_chains import KillChains
from stix.bindings import stix_core as core_binding


class TTPs(stix.EntityList):
class TTPs(stix.Entity):
_binding = core_binding
_binding_class = _binding.TTPsType
_namespace = 'http://stix.mitre.org/stix-1'

ttps = fields.TypedField(
name="TTP",
type_=TTP,
multiple=True,
key_name="ttps"
)

ttp = fields.TypedField("TTP", TTP, multiple=True, key_name="ttps")
kill_chains = fields.TypedField("Kill_Chains", KillChains)

def __init__(self, ttps=None):
super(TTPs, self).__init__(ttps)
super(TTPs, self).__init__()
self.ttp = ttps
self.kill_chains = KillChains()

def add_ttp(self, ttp):
self.append(ttp)
self.ttp.append(ttp)
4 changes: 2 additions & 2 deletions stix/test/extensions/malware/maec_4_1_malware_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ def test_parse_malware(self):
"""Test parsing a normal MalwareInstance from XML
"""
stix_pkg = STIXPackage.from_xml(self.XML)
mw = stix_pkg.ttps[0].behavior.malware_instances[0].to_dict()
mw = stix_pkg.ttps.ttp[0].behavior.malware_instances[0].to_dict()
self.assertTrue('names' in mw)

def test_parse_malware_maec(self):
"""Test parsing a MaecInstance from XML
"""
stix_pkg = STIXPackage.from_xml(self.XML_MAEC)
mw = stix_pkg.ttps[0].behavior.malware_instances[0].to_dict()
mw = stix_pkg.ttps.ttp[0].behavior.malware_instances[0].to_dict()
self.assertTrue('names' in mw)


Expand Down

0 comments on commit 2720066

Please sign in to comment.