MCPcopy Create free account
hub / github.com/STIXProject/python-stix / add

Method add

stix/core/stix_package.py:202–230  ·  view source on GitHub ↗

Adds `entity` to a top-level collection. For example, if `entity` is an Indicator object, the `entity` will be added to the ``indicators`` top-level collection.

(self, entity)

Source from the content-addressed store, hash-verified

200 self.related_packages.append(related_package)
201
202 def add(self, entity):
203 """Adds `entity` to a top-level collection. For example, if `entity` is
204 an Indicator object, the `entity` will be added to the ``indicators``
205 top-level collection.
206
207 """
208 if utils.is_cybox(entity):
209 self.add_observable(entity)
210 return
211
212 tlo_adds = {
213 Campaign: self.add_campaign,
214 CourseOfAction: self.add_course_of_action,
215 ExploitTarget: self.add_exploit_target,
216 Incident: self.add_incident,
217 Indicator: self.add_indicator,
218 ThreatActor: self.add_threat_actor,
219 TTP: self.add_ttp,
220 Report: self.add_report,
221 Observable: self.add_observable,
222 }
223
224 try:
225 add = tlo_adds[entity.__class__]
226 add(entity)
227 except KeyError:
228 error = "Cannot add type '{0}' to a top-level collection"
229 error = error.format(type(entity))
230 raise TypeError(error)
231
232 @classmethod
233 def from_xml(cls, xml_file, encoding=None):

Callers 15

mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
add_observableMethod · 0.45

Calls 1

add_observableMethod · 0.95