Skip to content

Commit

Permalink
add checks to initialize References() when missing, prevent empty TTP…
Browse files Browse the repository at this point in the history
…s tags. closes #366
  • Loading branch information
emmanvg committed May 1, 2020
1 parent ccbda57 commit 29140e8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions stix/common/information_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def add_contributing_source(self, value):
def add_reference(self, value):
if not value:
return
if self.references is None:
self.references = References()
# TODO: Check if it's a valid URI?
self.references.append(value)

Expand Down
2 changes: 1 addition & 1 deletion stix/core/stix_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def __init__(self, id_=None, idref=None, timestamp=None, stix_header=None,
self.indicators = indicators or Indicators()
self.incidents = incidents or Incidents()
self.threat_actors = threat_actors or ThreatActors()
self.ttps = ttps or TTPs()
self.ttps = ttps
self.related_packages = related_packages
self.timestamp = timestamp

Expand Down
5 changes: 5 additions & 0 deletions stix/core/ttps.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ def __init__(self, ttps=None):

def add_ttp(self, ttp):
self.ttp.append(ttp)

def add_kill_chain(self, kc):
if self.kill_chains is None:
self.kill_chains = KillChains()
self.kill_chains.kill_chain.append(kc)
7 changes: 4 additions & 3 deletions stix/exploit_target/vulnerability.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,19 @@ class Vulnerability(stix.Entity):
affected_software = fields.TypedField("Affected_Software", "stix.exploit_target.vulnerability.AffectedSoftware")
references = fields.TypedField("References", References)

def __init__(self, title=None, description=None, short_description=None):
def __init__(self, title=None, description=None, short_description=None, references=None):
super(Vulnerability, self).__init__()

self.title = title
self.description = description
self.short_description = short_description
self.references = []
self.references = references

def add_reference(self, reference):
if not reference:
return

if self.references is None:
self.references = References()
self.references.append(reference)


Expand Down

0 comments on commit 29140e8

Please sign in to comment.