1# Copyright (c) 2017, The MITRE Corporation. All rights reserved. 2# See LICENSE.txt for complete terms. 3 4#!/usr/bin/env python 5# -*- coding: utf-8 -*- 6 7# 8# Generated Thu Apr 11 15:06:26 2013 by generateDS.py version 2.9a. 9# 10 11import sys 12from mixbox.binding_utils import * 13import cybox.bindings.cybox_common as cybox_common_binding 14import cybox.bindings.cybox_core as cybox_core_binding 15 16from stix.bindings import get_type_info, lookup_extension 17 18XML_NS = "http://stix.mitre.org/common-1" 19 20# 21# Data representation classes. 22# 23 24class GenericRelationshipType(GeneratedsSuper): 25 """Allows the expression of relationships between STIX components. It 26 is extended by each component relationship type to add the 27 component itself.""" 28 subclass = None 29 superclass = None 30 def __init__(self, Confidence=None, Information_Source=None, Relationship=None, extensiontype_=None): 31 self.Confidence = Confidence 32 self.Information_Source = Information_Source 33 self.Relationship = Relationship 34 self.extensiontype_ = extensiontype_ 35 def factory(*args_, **kwargs_): 36 if GenericRelationshipType.subclass: 37 return GenericRelationshipType.subclass(*args_, **kwargs_) 38 else: 39 return GenericRelationshipType(*args_, **kwargs_) 40 factory = staticmethod(factory) 41 def get_Confidence(self): return self.Confidence 42 def set_Confidence(self, Confidence): self.Confidence = Confidence 43 def get_Information_Source(self): return self.Information_Source 44 def set_Information_Source(self, Information_Source): self.Information_Source = Information_Source 45 def get_Relationship(self): return self.Relationship 46 def set_Relationship(self, Relationship): self.Relationship = Relationship 47 def get_extensiontype_(self): return self.extensiontype_ 48 def set_extensiontype_(self, extensiontype_): self.extensiontype_ = extensiontype_ 49 def hasContent_(self): 50 if ( 51 self.Confidence is not None or 52 self.Information_Source is not None or 53 self.Relationship is not None 54 ): 55 return True 56 else: 57 return False 58 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='GenericRelationshipType', namespacedef_='', pretty_print=True): 59 if pretty_print: 60 eol_ = '\n' 61 else: 62 eol_ = '' 63 showIndent(lwrite, level, pretty_print) 64 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 65 already_processed = set() 66 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='GenericRelationshipType') 67 if self.hasContent_(): 68 lwrite('>%s' % (eol_, )) 69 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 70 showIndent(lwrite, level, pretty_print) 71 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 72 else: 73 lwrite('/>%s' % (eol_, )) 74 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='GenericRelationshipType'): 75 if self.extensiontype_ is not None and 'xsi:type' not in already_processed: 76 already_processed.add('xsi:type') 77 lwrite(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"') 78 lwrite(' xsi:type="%s"' % self.extensiontype_) 79 pass 80 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='GenericRelationshipType', fromsubclass_=False, pretty_print=True): 81 if pretty_print: 82 eol_ = '\n' 83 else: 84 eol_ = '' 85 if self.Confidence is not None: 86 self.Confidence.export(lwrite, level, nsmap, namespace_, name_='Confidence', pretty_print=pretty_print) 87 if self.Information_Source is not None: 88 self.Information_Source.export(lwrite, level, nsmap, namespace_, name_='Information_Source', pretty_print=pretty_print) 89 if self.Relationship is not None: 90 self.Relationship.export(lwrite, level, nsmap, namespace_, name_='Relationship', pretty_print=pretty_print) 91 def build(self, node): 92 self.__sourcenode__ = node 93 already_processed = set() 94 self.buildAttributes(node, node.attrib, already_processed) 95 for child in node: 96 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 97 self.buildChildren(child, node, nodeName_) 98 def buildAttributes(self, node, attrs, already_processed): 99 value = find_attr_value_('xsi:type', node) 100 if value is not None and 'xsi:type' not in already_processed: 101 already_processed.add('xsi:type') 102 self.extensiontype_ = value 103 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 104 if nodeName_ == 'Confidence': 105 obj_ = ConfidenceType.factory() 106 obj_.build(child_) 107 self.set_Confidence(obj_) 108 elif nodeName_ == 'Information_Source': 109 obj_ = InformationSourceType.factory() 110 obj_.build(child_) 111 self.set_Information_Source(obj_) 112 elif nodeName_ == 'Relationship': 113 obj_ = ControlledVocabularyStringType.factory() 114 obj_.build(child_) 115 self.set_Relationship(obj_) 116# end class GenericRelationshipType 117 118 119class DateTimeWithPrecisionType(GeneratedsSuper): 120 """This type is used as a replacement for the standard xs:dateTime type 121 but allows for the representation of the precision of the 122 dateTime. If the precision is given, consumers must ignore the 123 portions of this field that is more precise than the given 124 precision. Producers should zero-out (fill with zeros) digits in 125 the dateTime that are required by the xs:dateTime datatype but 126 are beyond the specified precision.In order to avoid ambiguity, 127 it is strongly suggested that all dateTimes include a 128 specification of the timezone if it is known.The precision of 129 the associated dateTime. If omitted, the default is "second", 130 meaning the full field value (including fractional seconds).""" 131 subclass = None 132 superclass = None 133 def __init__(self, precision='second', valueOf_=None): 134 self.precision = _cast(None, precision) 135 self.valueOf_ = valueOf_ 136 def factory(*args_, **kwargs_): 137 if DateTimeWithPrecisionType.subclass: 138 return DateTimeWithPrecisionType.subclass(*args_, **kwargs_) 139 else: 140 return DateTimeWithPrecisionType(*args_, **kwargs_) 141 factory = staticmethod(factory) 142 def get_precision(self): return self.precision 143 def set_precision(self, precision): self.precision = precision 144 def get_valueOf_(self): return self.valueOf_ 145 def set_valueOf_(self, valueOf_): self.valueOf_ = valueOf_ 146 def hasContent_(self): 147 if ( 148 self.valueOf_ 149 ): 150 return True 151 else: 152 return False 153 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='DateTimeWithPrecisionType', namespacedef_='', pretty_print=True): 154 if pretty_print: 155 eol_ = '\n' 156 else: 157 eol_ = '' 158 showIndent(lwrite, level, pretty_print) 159 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 160 already_processed = set() 161 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='DateTimeWithPrecisionType') 162 if self.hasContent_(): 163 lwrite('>') 164 lwrite(quote_xml(self.valueOf_)) 165 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 166 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 167 else: 168 lwrite('/>%s' % (eol_, )) 169 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='DateTimeWithPrecisionType'): 170 if self.precision is not None and 'precision' not in already_processed: 171 already_processed.add('precision') 172 lwrite(' precision=%s' % (quote_attrib(self.precision), )) 173 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='DateTimeWithPrecisionType', fromsubclass_=False, pretty_print=True): 174 pass 175 def build(self, node): 176 self.__sourcenode__ = node 177 already_processed = set() 178 self.buildAttributes(node, node.attrib, already_processed) 179 self.valueOf_ = get_all_text_(node) 180 for child in node: 181 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 182 self.buildChildren(child, node, nodeName_) 183 def buildAttributes(self, node, attrs, already_processed): 184 value = find_attr_value_('precision', node) 185 if value is not None and 'precision' not in already_processed: 186 already_processed.add('precision') 187 self.precision = value 188 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 189 pass 190# end class DateTimeWithPrecisionType 191 192class ProfilesType(GeneratedsSuper): 193 """The ProfilesType represents a list of STIX Profiles""" 194 subclass = None 195 superclass = None 196 def __init__(self, Profile=None): 197 if Profile is None: 198 self.Profile = [] 199 else: 200 self.Profile = Profile 201 def factory(*args_, **kwargs_): 202 if ProfilesType.subclass: 203 return ProfilesType.subclass(*args_, **kwargs_) 204 else: 205 return ProfilesType(*args_, **kwargs_) 206 factory = staticmethod(factory) 207 def get_Profile(self): return self.Profile 208 def set_Profile(self, Profile): self.Profile = Profile 209 def add_Profile(self, value): self.Profile.append(value) 210 def insert_Profile(self, index, value): self.Profile[index] = value 211 def hasContent_(self): 212 if ( 213 self.Profile 214 ): 215 return True 216 else: 217 return False 218 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='ProfilesType', namespacedef_='', pretty_print=True): 219 if pretty_print: 220 eol_ = '\n' 221 else: 222 eol_ = '' 223 showIndent(lwrite, level, pretty_print) 224 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 225 already_processed = set() 226 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='ProfilesType') 227 if self.hasContent_(): 228 lwrite('>%s' % (eol_, )) 229 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 230 showIndent(lwrite, level, pretty_print) 231 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 232 else: 233 lwrite('/>%s' % (eol_, )) 234 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='ProfilesType'): 235 pass 236 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='ProfilesType', fromsubclass_=False, pretty_print=True): 237 if pretty_print: 238 eol_ = '\n' 239 else: 240 eol_ = '' 241 for Profile_ in self.Profile: 242 showIndent(lwrite, level, pretty_print) 243 lwrite('<%s:Profile>%s</%s:Profile>%s' % (nsmap[namespace_],quote_xml(Profile_), nsmap[namespace_], eol_)) 244 def build(self, node): 245 self.__sourcenode__ = node 246 already_processed = set() 247 self.buildAttributes(node, node.attrib, already_processed) 248 for child in node: 249 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 250 self.buildChildren(child, node, nodeName_) 251 def buildAttributes(self, node, attrs, already_processed): 252 pass 253 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 254 if nodeName_ == 'Profile': 255 Profile_ = child_.text 256 Profile_ = self.gds_validate_string(Profile_, node, 'Profile') 257 self.Profile.append(Profile_) 258# end class ProfilesType 259 260 261class RelatedPackageRefType(GenericRelationshipType): 262 """Identifies or characterizes a relationship to a Package.Specifies a 263 globally unique identifier of a STIX Package specified 264 elsewhere.In conjunction with the idref, this field may be used 265 to reference a specific version of a STIX Package defined 266 elsewhere. The referenced version timestamp is contained in the 267 STIX_Header/Information_Source/Time/Produced_Time field of the 268 related package and must be an exact match.This field must only 269 be used in conjunction with the idref field.""" 270 subclass = None 271 superclass = GenericRelationshipType 272 def __init__(self, Confidence=None, Information_Source=None, Relationship=None, idref=None, timestamp=None): 273 super(RelatedPackageRefType, self).__init__(Confidence=Confidence, Information_Source=Information_Source, Relationship=Relationship) 274 self.idref = _cast(None, idref) 275 self.timestamp = _cast(None, timestamp) 276 pass 277 def factory(*args_, **kwargs_): 278 if RelatedPackageRefType.subclass: 279 return RelatedPackageRefType.subclass(*args_, **kwargs_) 280 else: 281 return RelatedPackageRefType(*args_, **kwargs_) 282 factory = staticmethod(factory) 283 def get_idref(self): return self.idref 284 def set_idref(self, idref): self.idref = idref 285 def get_timestamp(self): return self.timestamp 286 def set_timestamp(self, timestamp): self.timestamp = timestamp 287 def hasContent_(self): 288 if ( 289 super(RelatedPackageRefType, self).hasContent_() 290 ): 291 return True 292 else: 293 return False 294 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedPackageRefType', namespacedef_='', pretty_print=True): 295 if pretty_print: 296 eol_ = '\n' 297 else: 298 eol_ = '' 299 showIndent(lwrite, level, pretty_print) 300 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 301 already_processed = set() 302 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='RelatedPackageRefType') 303 if self.hasContent_(): 304 lwrite('>%s' % (eol_, )) 305 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 306 showIndent(lwrite, level, pretty_print) 307 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 308 else: 309 lwrite('/>%s' % (eol_, )) 310 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='RelatedPackageRefType'): 311 super(RelatedPackageRefType, self).exportAttributes(lwrite, level, already_processed, namespace_, name_='RelatedPackageRefType') 312 if self.idref is not None and 'idref' not in already_processed: 313 already_processed.add('idref') 314 lwrite(' idref=%s' % (quote_attrib(self.idref), )) 315 if self.timestamp is not None and 'timestamp' not in already_processed: 316 already_processed.add('timestamp') 317 lwrite(' timestamp="%s"' % self.gds_format_datetime(self.timestamp, input_name='timestamp')) 318 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedPackageRefType', fromsubclass_=False, pretty_print=True): 319 super(RelatedPackageRefType, self).exportChildren(lwrite, level, nsmap, namespace_, name_, True, pretty_print=pretty_print) 320 def build(self, node): 321 self.__sourcenode__ = node 322 already_processed = set() 323 self.buildAttributes(node, node.attrib, already_processed) 324 for child in node: 325 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 326 self.buildChildren(child, node, nodeName_) 327 def buildAttributes(self, node, attrs, already_processed): 328 value = find_attr_value_('idref', node) 329 if value is not None and 'idref' not in already_processed: 330 already_processed.add('idref') 331 self.idref = value 332 value = find_attr_value_('timestamp', node) 333 if value is not None and 'timestamp' not in already_processed: 334 already_processed.add('timestamp') 335 try: 336 self.timestamp = self.gds_parse_datetime(value, node, 'timestamp') 337 except ValueError as exp: 338 raise ValueError('Bad date-time attribute (timestamp): %s' % exp) 339 super(RelatedPackageRefType, self).buildAttributes(node, attrs, already_processed) 340 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 341 super(RelatedPackageRefType, self).buildChildren(child_, node, nodeName_, True) 342 pass 343# end class RelatedPackageRefType 344 345 346class RelatedPackageRefsType(GeneratedsSuper): 347 """Identifies or characterizes relationships to set of related 348 Packages.""" 349 subclass = None 350 superclass = None 351 def __init__(self, Package_Reference=None): 352 if Package_Reference is None: 353 self.Package_Reference = [] 354 else: 355 self.Package_Reference = Package_Reference 356 def factory(*args_, **kwargs_): 357 if RelatedPackageRefsType.subclass: 358 return RelatedPackageRefsType.subclass(*args_, **kwargs_) 359 else: 360 return RelatedPackageRefsType(*args_, **kwargs_) 361 factory = staticmethod(factory) 362 def get_Package_Reference(self): return self.Package_Reference 363 def set_Package_Reference(self, Package_Reference): self.Package_Reference = Package_Reference 364 def add_Package_Reference(self, value): self.Package_Reference.append(value) 365 def insert_Package_Reference(self, index, value): self.Package_Reference[index] = value 366 def hasContent_(self): 367 if ( 368 self.Package_Reference 369 ): 370 return True 371 else: 372 return False 373 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedPackageRefsType', namespacedef_='', pretty_print=True): 374 if pretty_print: 375 eol_ = '\n' 376 else: 377 eol_ = '' 378 showIndent(lwrite, level, pretty_print) 379 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 380 already_processed = set() 381 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='RelatedPackageRefsType') 382 if self.hasContent_(): 383 lwrite('>%s' % (eol_, )) 384 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 385 showIndent(lwrite, level, pretty_print) 386 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 387 else: 388 lwrite('/>%s' % (eol_, )) 389 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='RelatedPackageRefsType'): 390 pass 391 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedPackageRefsType', fromsubclass_=False, pretty_print=True): 392 if pretty_print: 393 eol_ = '\n' 394 else: 395 eol_ = '' 396 for Package_Reference_ in self.Package_Reference: 397 Package_Reference_.export(lwrite, level, nsmap, namespace_, name_='Package_Reference', pretty_print=pretty_print) 398 def build(self, node): 399 self.__sourcenode__ = node 400 already_processed = set() 401 self.buildAttributes(node, node.attrib, already_processed) 402 for child in node: 403 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 404 self.buildChildren(child, node, nodeName_) 405 def buildAttributes(self, node, attrs, already_processed): 406 pass 407 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 408 if nodeName_ == 'Package_Reference': 409 obj_ = RelatedPackageRefType.factory() 410 obj_.build(child_) 411 self.Package_Reference.append(obj_) 412# end class RelatedPackageRefsType 413 414class ToolInformationType(cybox_common_binding.ToolInformationType): 415 """The ToolInformationType is intended to characterize the properties 416 of a hardware or software tool, including those related to 417 instances of its use.The id field specifies a unique ID for this 418 Tool.The idref field specifies reference to a unique ID for this 419 Tool.When idref is specified, the id attribute must not be 420 specified, and any instance of this type should not hold content 421 unless an extension of the type allows it.""" 422 subclass = None 423 superclass = None 424 def __init__(self, idref=None, id=None, Name=None, Type=None, Description=None, References=None, Vendor=None, Version=None, Service_Pack=None, Tool_Specific_Data=None, Tool_Hashes=None, Tool_Configuration=None, Execution_Environment=None, Errors=None, Metadata=None, Compensation_Model=None, Title=None, Short_Description=None, extensiontype_=None): 425 super(ToolInformationType, self).__init__(idref=idref, id=id, Name=Name, Type=Type, Description=Description, References=References, Vendor=Vendor, Version=Version, Service_Pack=Service_Pack, Tool_Specific_Data=Tool_Specific_Data, Execution_Environment=Execution_Environment, Errors=Errors, Metadata=Metadata, Compensation_Model=Compensation_Model) 426 self.Title = Title 427 if Short_Description is None: 428 self.Short_Description = [] 429 else: 430 self.Short_Description = Short_Description 431 self.extensiontype_ = extensiontype_ 432 def factory(*args_, **kwargs_): 433 if ToolInformationType.subclass: 434 return ToolInformationType.subclass(*args_, **kwargs_) 435 else: 436 return ToolInformationType(*args_, **kwargs_) 437 438 factory = staticmethod(factory) 439 def get_Title(self): return self.Title 440 def set_Title(self, Title): self.Title = Title 441 def add_Short_Description(self, Short_Description): self.Short_Description.append(Short_Description) 442 def insert_Short_Description(self, index, Short_Description): self.Short_Description[index] = Short_Description 443 def get_Short_Description(self): return self.Short_Description 444 def set_Short_Description(self, Short_Description): self.Short_Description = Short_Description 445 def hasContent_(self): 446 if ( 447 super(ToolInformationType, self).hasContent_() or 448 self.Title is not None or 449 self.Short_Description 450 ): 451 return True 452 else: 453 return False 454 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='ToolInformationType', namespacedef_='', pretty_print=True): 455 if pretty_print: 456 eol_ = '\n' 457 else: 458 eol_ = '' 459 showIndent(lwrite, level, pretty_print) 460 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 461 already_processed = set() 462 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='ToolInformationType') 463 if self.hasContent_(): 464 lwrite('>%s' % (eol_, )) 465 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 466 showIndent(lwrite, level, pretty_print) 467 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 468 else: 469 lwrite('/>%s' % (eol_, )) 470 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='ToolInformationType'): 471 super(ToolInformationType, self).exportAttributes(lwrite, level, already_processed, namespace_="cyboxCommon:", name_=name_) 472 if self.extensiontype_ is not None and 'xsi:type' not in already_processed: 473 already_processed.add('xsi:type') 474 lwrite(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"') 475 lwrite(' xsi:type="%s"' % self.extensiontype_) 476 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='ToolInformationType', fromsubclass_=False, pretty_print=True): 477 super(ToolInformationType, self).exportChildren(lwrite, level, namespace_="cyboxCommon:", name_=name_, fromsubclass_=True, pretty_print=pretty_print) # exporting cyboxCommon-defined children 478 if pretty_print: 479 eol_ = '\n' 480 else: 481 eol_ = '' 482 if self.Title: 483 showIndent(lwrite, level, pretty_print) 484 lwrite('<%s:Title>%s</%s:Title>%s' % (nsmap[namespace_],quote_xml(self.Title), nsmap[namespace_], eol_)) 485 for Short_Description in self.Short_Description: 486 Short_Description.export(lwrite, level, nsmap, namespace_, name_='Short_Description', pretty_print=pretty_print) 487 def build(self, node): 488 self.__sourcenode__ = node 489 already_processed = set() 490 self.buildAttributes(node, node.attrib, already_processed) 491 for child in node: 492 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 493 self.buildChildren(child, node, nodeName_) 494 def buildAttributes(self, node, attrs, already_processed): 495 super(ToolInformationType, self).buildAttributes(node, attrs, already_processed) 496 value = find_attr_value_('xsi:type', node) 497 if value is not None and 'xsi:type' not in already_processed: 498 already_processed.add('xsi:type') 499 self.extensiontype_ = value 500 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 501 super(ToolInformationType, self).buildChildren(child_, node, nodeName_, fromsubclass_=True) 502 if nodeName_ == 'Title': 503 Title_ = child_.text 504 Title_ = self.gds_validate_string(Title_, node, 'Title') 505 self.Title = Title_ 506 elif nodeName_ == 'Short_Description': 507 obj_ = StructuredTextType.factory() 508 obj_.build(child_) 509 self.add_Short_Description(obj_) 510# end class ToolInformationType 511 512class InformationSourceType(GeneratedsSuper): 513 """The InformationSourceType details the source of a given data entry.""" 514 subclass = None 515 superclass = None 516 def __init__(self, Description=None, Identity=None, Role=None, Contributing_Sources=None, Time=None, Tools=None, References=None): 517 if Description is None: 518 self.Description = [] 519 else: 520 self.Description = Description 521 self.Identity = Identity 522 if Role is None: 523 self.Role = [] 524 else: 525 self.Role = Role 526 self.Contributing_Sources = Contributing_Sources 527 self.Time = Time 528 self.Tools = Tools 529 self.References = References 530 def factory(*args_, **kwargs_): 531 if InformationSourceType.subclass: 532 return InformationSourceType.subclass(*args_, **kwargs_) 533 else: 534 return InformationSourceType(*args_, **kwargs_) 535 factory = staticmethod(factory) 536 def add_Description(self, Description): self.Description.append(Description) 537 def insert_Description(self, index, Description): self.Description[index] = Description 538 def get_Description(self): return self.Description 539 def set_Description(self, Description): self.Description = Description 540 def get_Identity(self): return self.Identity 541 def set_Identity(self, Identity): self.Identity = Identity 542 def get_Role(self): return self.Role 543 def set_Role(self, Role): self.Role = Role 544 def add_Role(self, value): self.Role.append(value) 545 def insert_Role(self, index, value): self.Role[index] = value 546 def get_Contributing_Sources(self): return self.Contributing_Sources 547 def set_Contributing_Sources(self, Contributing_Sources): self.Contributing_Sources = Contributing_Sources 548 def get_Time(self): return self.Time 549 def set_Time(self, Time): self.Time = Time 550 def get_Tools(self): return self.Tools 551 def set_Tools(self, Tools): self.Tools = Tools 552 def get_References(self): return self.References 553 def set_References(self, References): self.References = References 554 def hasContent_(self): 555 if ( 556 self.Description or 557 self.Identity is not None or 558 self.Role or 559 self.Contributing_Sources is not None or 560 self.Time is not None or 561 self.Tools is not None or 562 self.References is not None 563 ): 564 return True 565 else: 566 return False 567 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='InformationSourceType', namespacedef_='', pretty_print=True): 568 if pretty_print: 569 eol_ = '\n' 570 else: 571 eol_ = '' 572 showIndent(lwrite, level, pretty_print) 573 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 574 already_processed = set() 575 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='InformationSourceType') 576 if self.hasContent_(): 577 lwrite('>%s' % (eol_, )) 578 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 579 showIndent(lwrite, level, pretty_print) 580 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 581 else: 582 lwrite('/>%s' % (eol_, )) 583 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='InformationSourceType'): 584 pass 585 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='InformationSourceType', fromsubclass_=False, pretty_print=True): 586 if pretty_print: 587 eol_ = '\n' 588 else: 589 eol_ = '' 590 for Description in self.Description: 591 Description.export(lwrite, level, nsmap, namespace_, name_='Description', pretty_print=pretty_print) 592 if self.Identity is not None: 593 self.Identity.export(lwrite, level, nsmap, namespace_, name_='Identity', pretty_print=pretty_print) 594 for Role_ in self.Role: 595 Role_.export(lwrite, level, nsmap, namespace_, name_='Role', pretty_print=pretty_print) 596 if self.Contributing_Sources is not None: 597 self.Contributing_Sources.export(lwrite, level, nsmap, namespace_, name_='Contributing_Sources', pretty_print=pretty_print) 598 if self.Time is not None: 599 self.Time.export(lwrite, level, "%s:" % (nsmap[namespace_]), name_='Time', pretty_print=pretty_print) 600 if self.Tools is not None: 601 self.Tools.export(lwrite, level, "%s:" % (nsmap[namespace_]), name_='Tools', pretty_print=pretty_print) 602 if self.References is not None: 603 self.References.export(lwrite, level, nsmap, namespace_, name_='References', pretty_print=pretty_print) 604 def build(self, node): 605 self.__sourcenode__ = node 606 already_processed = set() 607 self.buildAttributes(node, node.attrib, already_processed) 608 for child in node: 609 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 610 self.buildChildren(child, node, nodeName_) 611 def buildAttributes(self, node, attrs, already_processed): 612 pass 613 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 614 if nodeName_ == 'Description': 615 obj_ = StructuredTextType.factory() 616 obj_.build(child_) 617 self.add_Description(obj_) 618 elif nodeName_ == 'Identity': 619 from .extensions.identity import ciq_identity_3_0 620 obj_ = lookup_extension(child_, IdentityType).factory() 621 obj_.build(child_) 622 self.set_Identity(obj_) 623 elif nodeName_ == 'Role': 624 obj_ = ControlledVocabularyStringType.factory() 625 obj_.build(child_) 626 self.Role.append(obj_) 627 elif nodeName_ == 'Contributing_Sources': 628 obj_ = ContributingSourcesType.factory() 629 obj_.build(child_) 630 self.set_Contributing_Sources(obj_) 631 elif nodeName_ == 'Time': 632 obj_ = cybox_common_binding.TimeType.factory() 633 obj_.build(child_) 634 self.set_Time(obj_) 635 elif nodeName_ == 'Tools': 636 obj_ = cybox_common_binding.ToolsInformationType.factory() 637 obj_.build(child_) 638 self.set_Tools(obj_) 639 elif nodeName_ == 'References': 640 obj_ = ReferencesType.factory() 641 obj_.build(child_) 642 self.set_References(obj_) 643# end class InformationSourceType 644 645class ConfidenceType(GeneratedsSuper): 646 """The ConfidenceType specifies a level of Confidence held in some 647 assertion.Specifies the time of this Confidence assertion.""" 648 subclass = None 649 superclass = None 650 def __init__(self, timestamp=None, timestamp_precision='second', Value=None, Description=None, Source=None, Confidence_Assertion_Chain=None): 651 self.timestamp = _cast(None, timestamp) 652 self.timestamp_precision = _cast(None, timestamp_precision) 653 self.Value = Value 654 if Description is None: 655 self.Description = [] 656 else: 657 self.Description = Description 658 self.Source = Source 659 self.Confidence_Assertion_Chain = Confidence_Assertion_Chain 660 def factory(*args_, **kwargs_): 661 if ConfidenceType.subclass: 662 return ConfidenceType.subclass(*args_, **kwargs_) 663 else: 664 return ConfidenceType(*args_, **kwargs_) 665 factory = staticmethod(factory) 666 def get_Value(self): return self.Value 667 def set_Value(self, Value): self.Value = Value 668 def add_Description(self, Description): self.Description.append(Description) 669 def insert_Description(self, index, Description): self.Description[index] = Description 670 def get_Description(self): return self.Description 671 def set_Description(self, Description): self.Description = Description 672 def get_Source(self): return self.Source 673 def set_Source(self, Source): self.Source = Source 674 def get_Confidence_Assertion_Chain(self): return self.Confidence_Assertion_Chain 675 def set_Confidence_Assertion_Chain(self, Confidence_Assertion_Chain): self.Confidence_Assertion_Chain = Confidence_Assertion_Chain 676 def get_timestamp(self): return self.timestamp 677 def set_timestamp(self, timestamp): self.timestamp = timestamp 678 def get_timestamp_precision(self): return self.timestamp_precision 679 def set_timestamp_precision(self, timestamp_precision): self.timestamp_precision = timestamp_precision 680 def hasContent_(self): 681 if ( 682 self.Value is not None or 683 self.Description or 684 self.Source is not None or 685 self.Confidence_Assertion_Chain is not None 686 ): 687 return True 688 else: 689 return False 690 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='ConfidenceType', namespacedef_='', pretty_print=True): 691 if pretty_print: 692 eol_ = '\n' 693 else: 694 eol_ = '' 695 showIndent(lwrite, level, pretty_print) 696 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 697 already_processed = set() 698 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='ConfidenceType') 699 if self.hasContent_(): 700 lwrite('>%s' % (eol_, )) 701 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 702 showIndent(lwrite, level, pretty_print) 703 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 704 else: 705 lwrite('/>%s' % (eol_, )) 706 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='ConfidenceType'): 707 if self.timestamp is not None and 'timestamp' not in already_processed: 708 already_processed.add('timestamp') 709 lwrite(' timestamp="%s"' % self.gds_format_datetime(self.timestamp, input_name='timestamp')) 710 if self.timestamp_precision not in (None, 'second') and 'timestamp_precision' not in already_processed: 711 already_processed.add('timestamp_precision') 712 lwrite(' timestamp_precision=%s' % (quote_attrib(self.timestamp_precision), )) 713 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='ConfidenceType', fromsubclass_=False, pretty_print=True): 714 if pretty_print: 715 eol_ = '\n' 716 else: 717 eol_ = '' 718 if self.Value is not None: 719 self.Value.export(lwrite, level, nsmap, namespace_, name_='Value', pretty_print=pretty_print) 720 for Description in self.Description: 721 Description.export(lwrite, level, nsmap, namespace_, name_='Description', pretty_print=pretty_print) 722 if self.Source is not None: 723 self.Source.export(lwrite, level, nsmap, namespace_, name_='Source', pretty_print=pretty_print) 724 if self.Confidence_Assertion_Chain is not None: 725 self.Confidence_Assertion_Chain.export(lwrite, level, nsmap, namespace_, name_='Confidence_Assertion_Chain', pretty_print=pretty_print) 726 def build(self, node): 727 self.__sourcenode__ = node 728 already_processed = set() 729 self.buildAttributes(node, node.attrib, already_processed) 730 for child in node: 731 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 732 self.buildChildren(child, node, nodeName_) 733 def buildAttributes(self, node, attrs, already_processed): 734 value = find_attr_value_('timestamp', node) 735 if value is not None and 'timestamp' not in already_processed: 736 already_processed.add('timestamp') 737 try: 738 self.timestamp = self.gds_parse_datetime(value, node, 'timestamp') 739 except ValueError as exp: 740 raise ValueError('Bad date-time attribute (timestamp): %s' % exp) 741 742 value = find_attr_value_('timestamp_precision', node) 743 if value is not None and 'timestamp_precision' not in already_processed: 744 already_processed.add('timestamp_precision') 745 self.timestamp_precision = value 746 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 747 if nodeName_ == 'Value': 748 obj_ = ControlledVocabularyStringType.factory() 749 obj_.build(child_) 750 self.set_Value(obj_) 751 elif nodeName_ == 'Description': 752 obj_ = StructuredTextType.factory() 753 obj_.build(child_) 754 self.add_Description(obj_) 755 elif nodeName_ == 'Source': 756 obj_ = InformationSourceType.factory() 757 obj_.build(child_) 758 self.set_Source(obj_) 759 elif nodeName_ == 'Confidence_Assertion_Chain': 760 obj_ = ConfidenceAssertionChainType.factory() 761 obj_.build(child_) 762 self.set_Confidence_Assertion_Chain(obj_) 763# end class ConfidenceType 764 765class ActivityType(GeneratedsSuper): 766 subclass = None 767 superclass = None 768 def __init__(self, Date_Time=None, Description=None): 769 self.Date_Time = Date_Time 770 if Description is None: 771 self.Description = [] 772 else: 773 self.Description = Description 774 def factory(*args_, **kwargs_): 775 if ActivityType.subclass: 776 return ActivityType.subclass(*args_, **kwargs_) 777 else: 778 return ActivityType(*args_, **kwargs_) 779 factory = staticmethod(factory) 780 def get_Date_Time(self): return self.Date_Time 781 def set_Date_Time(self, Date_Time): self.Date_Time = Date_Time 782 def add_Description(self, Description): self.Description.append(Description) 783 def insert_Description(self, index, Description): self.Description[index] = Description 784 def get_Description(self): return self.Description 785 def set_Description(self, Description): self.Description = Description 786 def hasContent_(self): 787 if ( 788 self.Date_Time is not None or 789 self.Description 790 ): 791 return True 792 else: 793 return False 794 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='ActivityType', namespacedef_='', pretty_print=True): 795 if pretty_print: 796 eol_ = '\n' 797 else: 798 eol_ = '' 799 showIndent(lwrite, level, pretty_print) 800 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 801 already_processed = set() 802 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='ActivityType') 803 if self.hasContent_(): 804 lwrite('>%s' % (eol_, )) 805 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 806 showIndent(lwrite, level, pretty_print) 807 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 808 else: 809 lwrite('/>%s' % (eol_, )) 810 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='ActivityType'): 811 pass 812 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='ActivityType', fromsubclass_=False, pretty_print=True): 813 if pretty_print: 814 eol_ = '\n' 815 else: 816 eol_ = '' 817 if self.Date_Time is not None: 818 self.Date_Time.export(lwrite, level, nsmap, namespace_, name_='Date_Time', pretty_print=pretty_print) 819 for Description in self.Description: 820 Description.export(lwrite, level, nsmap, namespace_, name_='Description', pretty_print=pretty_print) 821 def build(self, node): 822 self.__sourcenode__ = node 823 already_processed = set() 824 self.buildAttributes(node, node.attrib, already_processed) 825 for child in node: 826 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 827 self.buildChildren(child, node, nodeName_) 828 def buildAttributes(self, node, attrs, already_processed): 829 pass 830 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 831 if nodeName_ == 'Date_Time': 832 obj_ = DateTimeWithPrecisionType.factory() 833 obj_.build(child_) 834 self.set_Date_Time(obj_) 835 elif nodeName_ == 'Description': 836 obj_ = StructuredTextType.factory() 837 obj_.build(child_) 838 self.add_Description(obj_) 839# end class ActivityType 840 841class KillChainsType(GeneratedsSuper): 842 subclass = None 843 superclass = None 844 def __init__(self, Kill_Chain=None): 845 if Kill_Chain is None: 846 self.Kill_Chain = [] 847 else: 848 self.Kill_Chain = Kill_Chain 849 def factory(*args_, **kwargs_): 850 if KillChainsType.subclass: 851 return KillChainsType.subclass(*args_, **kwargs_) 852 else: 853 return KillChainsType(*args_, **kwargs_) 854 factory = staticmethod(factory) 855 def get_Kill_Chain(self): return self.Kill_Chain 856 def set_Kill_Chain(self, Kill_Chain): self.Kill_Chain = Kill_Chain 857 def add_Kill_Chain(self, value): self.Kill_Chain.append(value) 858 def insert_Kill_Chain(self, index, value): self.Kill_Chain[index] = value 859 def hasContent_(self): 860 if ( 861 self.Kill_Chain 862 ): 863 return True 864 else: 865 return False 866 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='KillChainsType', namespacedef_='', pretty_print=True): 867 if pretty_print: 868 eol_ = '\n' 869 else: 870 eol_ = '' 871 showIndent(lwrite, level, pretty_print) 872 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 873 already_processed = set() 874 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='KillChainsType') 875 if self.hasContent_(): 876 lwrite('>%s' % (eol_, )) 877 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 878 showIndent(lwrite, level, pretty_print) 879 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 880 else: 881 lwrite('/>%s' % (eol_, )) 882 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='KillChainsType'): 883 pass 884 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='KillChainsType', fromsubclass_=False, pretty_print=True): 885 if pretty_print: 886 eol_ = '\n' 887 else: 888 eol_ = '' 889 for Kill_Chain_ in self.Kill_Chain: 890 Kill_Chain_.export(lwrite, level, nsmap, namespace_, name_='Kill_Chain', pretty_print=pretty_print) 891 def build(self, node): 892 self.__sourcenode__ = node 893 already_processed = set() 894 self.buildAttributes(node, node.attrib, already_processed) 895 for child in node: 896 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 897 self.buildChildren(child, node, nodeName_) 898 def buildAttributes(self, node, attrs, already_processed): 899 pass 900 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 901 if nodeName_ == 'Kill_Chain': 902 obj_ = KillChainType.factory() 903 obj_.build(child_) 904 self.Kill_Chain.append(obj_) 905# end class KillChainsType 906 907class KillChainType(GeneratedsSuper): 908 """The KillChainType characterizes a specific Kill Chain definition for 909 reference within specific TTP entries, Indicators and 910 elsewhere.A globally unique identifier for this kill chain 911 definition.A descriptive name for this kill chain definition.The 912 organization or individual responsible for this kill chain 913 definition.A resource reference for this kill chain 914 definition.The number of phases in this kill chain definition.""" 915 subclass = None 916 superclass = None 917 def __init__(self, reference=None, number_of_phases=None, id=None, definer=None, name=None, Kill_Chain_Phase=None): 918 self.reference = _cast(None, reference) 919 self.number_of_phases = _cast(None, number_of_phases) 920 self.id = _cast(None, id) 921 self.definer = _cast(None, definer) 922 self.name = _cast(None, name) 923 if Kill_Chain_Phase is None: 924 self.Kill_Chain_Phase = [] 925 else: 926 self.Kill_Chain_Phase = Kill_Chain_Phase 927 def factory(*args_, **kwargs_): 928 if KillChainType.subclass: 929 return KillChainType.subclass(*args_, **kwargs_) 930 else: 931 return KillChainType(*args_, **kwargs_) 932 factory = staticmethod(factory) 933 def get_Kill_Chain_Phase(self): return self.Kill_Chain_Phase 934 def set_Kill_Chain_Phase(self, Kill_Chain_Phase): self.Kill_Chain_Phase = Kill_Chain_Phase 935 def add_Kill_Chain_Phase(self, value): self.Kill_Chain_Phase.append(value) 936 def insert_Kill_Chain_Phase(self, index, value): self.Kill_Chain_Phase[index] = value 937 def get_reference(self): return self.reference 938 def set_reference(self, reference): self.reference = reference 939 def get_number_of_phases(self): return self.number_of_phases 940 def set_number_of_phases(self, number_of_phases): self.number_of_phases = number_of_phases 941 def get_id(self): return self.id 942 def set_id(self, id): self.id = id 943 def get_definer(self): return self.definer 944 def set_definer(self, definer): self.definer = definer 945 def get_name(self): return self.name 946 def set_name(self, name): self.name = name 947 def hasContent_(self): 948 if ( 949 self.Kill_Chain_Phase 950 ): 951 return True 952 else: 953 return False 954 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='KillChainType', namespacedef_='', pretty_print=True): 955 if pretty_print: 956 eol_ = '\n' 957 else: 958 eol_ = '' 959 showIndent(lwrite, level, pretty_print) 960 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 961 already_processed = set() 962 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='KillChainType') 963 if self.hasContent_(): 964 lwrite('>%s' % (eol_, )) 965 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 966 showIndent(lwrite, level, pretty_print) 967 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 968 else: 969 lwrite('/>%s' % (eol_, )) 970 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='KillChainType'): 971 if self.reference is not None and 'reference' not in already_processed: 972 already_processed.add('reference') 973 lwrite(' reference=%s' % (quote_attrib(self.reference), )) 974 if self.number_of_phases is not None and 'number_of_phases' not in already_processed: 975 already_processed.add('number_of_phases') 976 lwrite(' number_of_phases=%s' % (quote_attrib(self.number_of_phases), )) 977 if self.id is not None and 'id' not in already_processed: 978 already_processed.add('id') 979 lwrite(' id=%s' % (quote_attrib(self.id), )) 980 if self.definer is not None and 'definer' not in already_processed: 981 already_processed.add('definer') 982 lwrite(' definer=%s' % (quote_attrib(self.definer), )) 983 if self.name is not None and 'name' not in already_processed: 984 already_processed.add('name') 985 lwrite(' name=%s' % (quote_attrib(self.name), )) 986 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='KillChainType', fromsubclass_=False, pretty_print=True): 987 if pretty_print: 988 eol_ = '\n' 989 else: 990 eol_ = '' 991 for Kill_Chain_Phase_ in self.Kill_Chain_Phase: 992 Kill_Chain_Phase_.export(lwrite, level, nsmap, namespace_, name_='Kill_Chain_Phase', pretty_print=pretty_print) 993 def build(self, node): 994 self.__sourcenode__ = node 995 already_processed = set() 996 self.buildAttributes(node, node.attrib, already_processed) 997 for child in node: 998 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 999 self.buildChildren(child, node, nodeName_) 1000 def buildAttributes(self, node, attrs, already_processed): 1001 value = find_attr_value_('reference', node) 1002 if value is not None and 'reference' not in already_processed: 1003 already_processed.add('reference') 1004 self.reference = value 1005 value = find_attr_value_('number_of_phases', node) 1006 if value is not None and 'number_of_phases' not in already_processed: 1007 already_processed.add('number_of_phases') 1008 self.number_of_phases = value 1009 value = find_attr_value_('id', node) 1010 if value is not None and 'id' not in already_processed: 1011 already_processed.add('id') 1012 self.id = value 1013 value = find_attr_value_('definer', node) 1014 if value is not None and 'definer' not in already_processed: 1015 already_processed.add('definer') 1016 self.definer = value 1017 value = find_attr_value_('name', node) 1018 if value is not None and 'name' not in already_processed: 1019 already_processed.add('name') 1020 self.name = value 1021 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 1022 if nodeName_ == 'Kill_Chain_Phase': 1023 obj_ = KillChainPhaseType.factory() 1024 obj_.build(child_) 1025 self.Kill_Chain_Phase.append(obj_) 1026# end class KillChainType 1027 1028class KillChainPhaseType(GeneratedsSuper): 1029 """The KillChainPhaseType characterizes an individual phase within a 1030 kill chain definition.This field specifies the ID for the 1031 relevant kill chain phase.This field specifies the descriptive 1032 name of the relevant kill chain phase.This field specifies the 1033 ordinality (e.g. 1, 2 or 3) of this phase within this kill chain 1034 definition.""" 1035 subclass = None 1036 superclass = None 1037 def __init__(self, ordinality=None, name=None, phase_id=None, extensiontype_=None): 1038 self.ordinality = _cast(int, ordinality) 1039 self.name = _cast(None, name) 1040 self.phase_id = _cast(None, phase_id) 1041 self.extensiontype_ = extensiontype_ 1042 def factory(*args_, **kwargs_): 1043 if KillChainPhaseType.subclass: 1044 return KillChainPhaseType.subclass(*args_, **kwargs_) 1045 else: 1046 return KillChainPhaseType(*args_, **kwargs_) 1047 factory = staticmethod(factory) 1048 def get_ordinality(self): return self.ordinality 1049 def set_ordinality(self, ordinality): self.ordinality = ordinality 1050 def get_name(self): return self.name 1051 def set_name(self, name): self.name = name 1052 def get_phase_id(self): return self.phase_id 1053 def set_phase_id(self, phase_id): self.phase_id = phase_id 1054 def get_extensiontype_(self): return self.extensiontype_ 1055 def set_extensiontype_(self, extensiontype_): self.extensiontype_ = extensiontype_ 1056 def hasContent_(self): 1057 if ( 1058 1059 ): 1060 return True 1061 else: 1062 return False 1063 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='KillChainPhaseType', namespacedef_='', pretty_print=True): 1064 if pretty_print: 1065 eol_ = '\n' 1066 else: 1067 eol_ = '' 1068 showIndent(lwrite, level, pretty_print) 1069 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 1070 already_processed = set() 1071 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='KillChainPhaseType') 1072 if self.hasContent_(): 1073 lwrite('>%s' % (eol_, )) 1074 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 1075 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 1076 else: 1077 lwrite('/>%s' % (eol_, )) 1078 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='KillChainPhaseType'): 1079 if self.ordinality is not None and 'ordinality' not in already_processed: 1080 already_processed.add('ordinality') 1081 lwrite(' ordinality="%s"' % self.gds_format_integer(self.ordinality, input_name='ordinality')) 1082 if self.name is not None and 'name' not in already_processed: 1083 already_processed.add('name') 1084 lwrite(' name=%s' % (quote_attrib(self.name), )) 1085 if self.phase_id is not None and 'phase_id' not in already_processed: 1086 already_processed.add('phase_id') 1087 lwrite(' phase_id=%s' % (quote_attrib(self.phase_id), )) 1088 if self.extensiontype_ is not None and 'xsi:type' not in already_processed: 1089 already_processed.add('xsi:type') 1090 lwrite(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"') 1091 lwrite(' xsi:type="%s"' % self.extensiontype_) 1092 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='KillChainPhaseType', fromsubclass_=False, pretty_print=True): 1093 pass 1094 def build(self, node): 1095 self.__sourcenode__ = node 1096 already_processed = set() 1097 self.buildAttributes(node, node.attrib, already_processed) 1098 for child in node: 1099 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 1100 self.buildChildren(child, node, nodeName_) 1101 def buildAttributes(self, node, attrs, already_processed): 1102 value = find_attr_value_('ordinality', node) 1103 if value is not None and 'ordinality' not in already_processed: 1104 already_processed.add('ordinality') 1105 try: 1106 self.ordinality = int(value) 1107 except ValueError as exp: 1108 raise_parse_error(node, 'Bad integer attribute: %s' % exp) 1109 value = find_attr_value_('name', node) 1110 if value is not None and 'name' not in already_processed: 1111 already_processed.add('name') 1112 self.name = value 1113 value = find_attr_value_('phase_id', node) 1114 if value is not None and 'phase_id' not in already_processed: 1115 already_processed.add('phase_id') 1116 self.phase_id = value 1117 value = find_attr_value_('xsi:type', node) 1118 if value is not None and 'xsi:type' not in already_processed: 1119 already_processed.add('xsi:type') 1120 self.extensiontype_ = value 1121 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 1122 pass 1123# end class KillChainPhaseType 1124 1125class KillChainPhasesReferenceType(GeneratedsSuper): 1126 subclass = None 1127 superclass = None 1128 def __init__(self, Kill_Chain_Phase=None): 1129 if Kill_Chain_Phase is None: 1130 self.Kill_Chain_Phase = [] 1131 else: 1132 self.Kill_Chain_Phase = Kill_Chain_Phase 1133 def factory(*args_, **kwargs_): 1134 if KillChainPhasesReferenceType.subclass: 1135 return KillChainPhasesReferenceType.subclass(*args_, **kwargs_) 1136 else: 1137 return KillChainPhasesReferenceType(*args_, **kwargs_) 1138 factory = staticmethod(factory) 1139 def get_Kill_Chain_Phase(self): return self.Kill_Chain_Phase 1140 def set_Kill_Chain_Phase(self, Kill_Chain_Phase): self.Kill_Chain_Phase = Kill_Chain_Phase 1141 def add_Kill_Chain_Phase(self, value): self.Kill_Chain_Phase.append(value) 1142 def insert_Kill_Chain_Phase(self, index, value): self.Kill_Chain_Phase[index] = value 1143 def hasContent_(self): 1144 if ( 1145 self.Kill_Chain_Phase 1146 ): 1147 return True 1148 else: 1149 return False 1150 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='KillChainPhasesReferenceType', namespacedef_='', pretty_print=True): 1151 if pretty_print: 1152 eol_ = '\n' 1153 else: 1154 eol_ = '' 1155 showIndent(lwrite, level, pretty_print) 1156 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 1157 already_processed = set() 1158 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='KillChainPhasesReferenceType') 1159 if self.hasContent_(): 1160 lwrite('>%s' % (eol_, )) 1161 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 1162 showIndent(lwrite, level, pretty_print) 1163 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 1164 else: 1165 lwrite('/>%s' % (eol_, )) 1166 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='KillChainPhasesReferenceType'): 1167 pass 1168 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='KillChainPhasesReferenceType', fromsubclass_=False, pretty_print=True): 1169 if pretty_print: 1170 eol_ = '\n' 1171 else: 1172 eol_ = '' 1173 for Kill_Chain_Phase_ in self.Kill_Chain_Phase: 1174 Kill_Chain_Phase_.export(lwrite, level, nsmap, namespace_, name_='Kill_Chain_Phase', pretty_print=pretty_print) 1175 def build(self, node): 1176 self.__sourcenode__ = node 1177 already_processed = set() 1178 self.buildAttributes(node, node.attrib, already_processed) 1179 for child in node: 1180 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 1181 self.buildChildren(child, node, nodeName_) 1182 def buildAttributes(self, node, attrs, already_processed): 1183 pass 1184 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 1185 if nodeName_ == 'Kill_Chain_Phase': 1186 obj_ = KillChainPhaseReferenceType.factory() 1187 obj_.build(child_) 1188 self.Kill_Chain_Phase.append(obj_) 1189# end class KillChainPhasesReferenceType 1190 1191class KillChainPhaseReferenceType(KillChainPhaseType): 1192 """This field specifies the ID for the relevant defined kill chain.This 1193 field specifies the descriptive name of the relevant kill chain.""" 1194 subclass = None 1195 superclass = KillChainPhaseType 1196 def __init__(self, ordinality=None, name=None, phase_id=None, kill_chain_name=None, kill_chain_id=None): 1197 super(KillChainPhaseReferenceType, self).__init__(ordinality=ordinality, name=name, phase_id=phase_id) 1198 self.kill_chain_name = _cast(None, kill_chain_name) 1199 self.kill_chain_id = _cast(None, kill_chain_id) 1200 pass 1201 def factory(*args_, **kwargs_): 1202 if KillChainPhaseReferenceType.subclass: 1203 return KillChainPhaseReferenceType.subclass(*args_, **kwargs_) 1204 else: 1205 return KillChainPhaseReferenceType(*args_, **kwargs_) 1206 factory = staticmethod(factory) 1207 def get_kill_chain_name(self): return self.kill_chain_name 1208 def set_kill_chain_name(self, kill_chain_name): self.kill_chain_name = kill_chain_name 1209 def get_kill_chain_id(self): return self.kill_chain_id 1210 def set_kill_chain_id(self, kill_chain_id): self.kill_chain_id = kill_chain_id 1211 def hasContent_(self): 1212 if ( 1213 super(KillChainPhaseReferenceType, self).hasContent_() 1214 ): 1215 return True 1216 else: 1217 return False 1218 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='KillChainPhaseReferenceType', namespacedef_='', pretty_print=True): 1219 if pretty_print: 1220 eol_ = '\n' 1221 else: 1222 eol_ = '' 1223 showIndent(lwrite, level, pretty_print) 1224 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 1225 already_processed = set() 1226 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='KillChainPhaseReferenceType') 1227 if self.hasContent_(): 1228 lwrite('>%s' % (eol_, )) 1229 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 1230 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 1231 else: 1232 lwrite('/>%s' % (eol_, )) 1233 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='KillChainPhaseReferenceType'): 1234 super(KillChainPhaseReferenceType, self).exportAttributes(lwrite, level, already_processed, namespace_, name_='KillChainPhaseReferenceType') 1235 if self.kill_chain_name is not None and 'kill_chain_name' not in already_processed: 1236 already_processed.add('kill_chain_name') 1237 lwrite(' kill_chain_name=%s' % (quote_attrib(self.kill_chain_name), )) 1238 if self.kill_chain_id is not None and 'kill_chain_id' not in already_processed: 1239 already_processed.add('kill_chain_id') 1240 lwrite(' kill_chain_id=%s' % (quote_attrib(self.kill_chain_id), )) 1241 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='KillChainPhaseReferenceType', fromsubclass_=False, pretty_print=True): 1242 super(KillChainPhaseReferenceType, self).exportChildren(lwrite, level, nsmap, namespace_, name_, True, pretty_print=pretty_print) 1243 pass 1244 def build(self, node): 1245 self.__sourcenode__ = node 1246 already_processed = set() 1247 self.buildAttributes(node, node.attrib, already_processed) 1248 for child in node: 1249 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 1250 self.buildChildren(child, node, nodeName_) 1251 def buildAttributes(self, node, attrs, already_processed): 1252 value = find_attr_value_('kill_chain_name', node) 1253 if value is not None and 'kill_chain_name' not in already_processed: 1254 already_processed.add('kill_chain_name') 1255 self.kill_chain_name = value 1256 value = find_attr_value_('kill_chain_id', node) 1257 if value is not None and 'kill_chain_id' not in already_processed: 1258 already_processed.add('kill_chain_id') 1259 self.kill_chain_id = value 1260 super(KillChainPhaseReferenceType, self).buildAttributes(node, attrs, already_processed) 1261 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 1262 super(KillChainPhaseReferenceType, self).buildChildren(child_, node, nodeName_, True) 1263 pass 1264# end class KillChainPhaseReferenceType 1265 1266class IdentityType(GeneratedsSuper): 1267 """The IdentityType is used to express identity information for both 1268 individuals and organizations. This type is extended through the 1269 xsi:type mechanism. The default type is 1270 CIQIdentity3.0InstanceType in the 1271 http://stix.mitre.org/extensions/Identity#CIQIdentity3.0-1 1272 namespace. This type is defined in the 1273 extensions/identity/ciq_identity_3.0.xsd file or at the URL http 1274 ://stix.mitre.org/XMLSchema/extensions/identity/ciq_identity_3.0 1275 /1.0/ciq_identity_3.0.xsd. Those who wish to express a simple 1276 name may also do so by not specifying an xsi:type and using the 1277 Name field of this type. Specifies a unique ID for this 1278 Identity.Specifies a reference to a unique ID defined elsewhere.""" 1279 subclass = None 1280 superclass = None 1281 def __init__(self, idref=None, id=None, Name=None, Related_Identities=None): 1282 self.idref = _cast(None, idref) 1283 self.id = _cast(None, id) 1284 self.Name = Name 1285 self.Related_Identities = Related_Identities 1286 def factory(*args_, **kwargs_): 1287 if IdentityType.subclass: 1288 return IdentityType.subclass(*args_, **kwargs_) 1289 else: 1290 return IdentityType(*args_, **kwargs_) 1291 factory = staticmethod(factory) 1292 def get_Name(self): return self.Name 1293 def set_Name(self, Name): self.Name = Name 1294 def get_Related_Identities(self): return self.Related_Identities 1295 def set_Related_Identities(self, Related_Identities): self.Related_Identities = Related_Identities 1296 def get_idref(self): return self.idref 1297 def set_idref(self, idref): self.idref = idref 1298 def get_id(self): return self.id 1299 def set_id(self, id): self.id = id 1300 def hasContent_(self): 1301 if ( 1302 self.Name is not None or 1303 self.Related_Identities is not None 1304 ): 1305 return True 1306 else: 1307 return False 1308 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='IdentityType', namespacedef_='', pretty_print=True): 1309 if pretty_print: 1310 eol_ = '\n' 1311 else: 1312 eol_ = '' 1313 showIndent(lwrite, level, pretty_print) 1314 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 1315 already_processed = set() 1316 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='IdentityType') 1317 if self.hasContent_(): 1318 lwrite('>%s' % (eol_, )) 1319 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 1320 showIndent(lwrite, level, pretty_print) 1321 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 1322 else: 1323 lwrite('/>%s' % (eol_, )) 1324 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='IdentityType'): 1325 if self.idref is not None and 'idref' not in already_processed: 1326 already_processed.add('idref') 1327 lwrite(' idref=%s' % (quote_attrib(self.idref), )) 1328 if self.id is not None and 'id' not in already_processed: 1329 already_processed.add('id') 1330 lwrite(' id=%s' % (quote_attrib(self.id), )) 1331 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='IdentityType', fromsubclass_=False, pretty_print=True): 1332 if pretty_print: 1333 eol_ = '\n' 1334 else: 1335 eol_ = '' 1336 if self.Name is not None: 1337 showIndent(lwrite, level, pretty_print) 1338 lwrite('<%s:Name>%s</%s:Name>%s' % (nsmap[namespace_], quote_xml(self.Name), nsmap[namespace_], eol_)) 1339 if self.Related_Identities is not None: 1340 self.Related_Identities.export(lwrite, level, nsmap, namespace_, name_='Related_Identities', pretty_print=pretty_print) 1341 def build(self, node): 1342 self.__sourcenode__ = node 1343 already_processed = set() 1344 self.buildAttributes(node, node.attrib, already_processed) 1345 for child in node: 1346 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 1347 self.buildChildren(child, node, nodeName_) 1348 def buildAttributes(self, node, attrs, already_processed): 1349 value = find_attr_value_('idref', node) 1350 if value is not None and 'idref' not in already_processed: 1351 already_processed.add('idref') 1352 self.idref = value 1353 value = find_attr_value_('id', node) 1354 if value is not None and 'id' not in already_processed: 1355 already_processed.add('id') 1356 self.id = value 1357 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 1358 if nodeName_ == 'Name': 1359 Name_ = child_.text 1360 Name_ = self.gds_validate_string(Name_, node, 'Name') 1361 self.Name = Name_ 1362 elif nodeName_ == 'Related_Identities': 1363 obj_ = RelatedIdentitiesType.factory() 1364 obj_.build(child_) 1365 self.set_Related_Identities(obj_) 1366# end class IdentityType 1367 1368class GenericRelationshipListType(GeneratedsSuper): 1369 """Allows the expression of a list of relationships between STIX 1370 components. It's extended throughout STIX and should not be used 1371 directly. Indicates how multiple related items should be 1372 interpreted in this relationship. If "inclusive" is specified, 1373 then a single conceptual relationship is being defined between 1374 the subject and the collection of objects indicated by the 1375 related items (i.e. the relationship is not necessarily relevant 1376 for any one particular object being referenced, but for the 1377 aggregated collection of objects referenced). If "exclusive" is 1378 specified, then multiple relationships are being defined between 1379 the specific subject and each object individually.""" 1380 subclass = None 1381 superclass = None 1382 def __init__(self, scope='exclusive'): 1383 self.scope = _cast(None, scope) 1384 pass 1385 def factory(*args_, **kwargs_): 1386 if GenericRelationshipListType.subclass: 1387 return GenericRelationshipListType.subclass(*args_, **kwargs_) 1388 else: 1389 return GenericRelationshipListType(*args_, **kwargs_) 1390 factory = staticmethod(factory) 1391 def get_scope(self): return self.scope 1392 def set_scope(self, scope): self.scope = scope 1393 def hasContent_(self): 1394 if ( 1395 1396 ): 1397 return True 1398 else: 1399 return False 1400 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='GenericRelationshipListType', namespacedef_='', pretty_print=True): 1401 if pretty_print: 1402 eol_ = '\n' 1403 else: 1404 eol_ = '' 1405 showIndent(lwrite, level, pretty_print) 1406 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 1407 already_processed = set() 1408 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='GenericRelationshipListType') 1409 if self.hasContent_(): 1410 lwrite('>%s' % (eol_, )) 1411 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 1412 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 1413 else: 1414 lwrite('/>%s' % (eol_, )) 1415 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='GenericRelationshipListType'): 1416 if self.scope is not None and 'scope' not in already_processed: 1417 already_processed.add('scope') 1418 lwrite(' scope=%s' % (quote_attrib(self.scope), )) 1419 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='GenericRelationshipListType', fromsubclass_=False, pretty_print=True): 1420 pass 1421 def build(self, node): 1422 self.__sourcenode__ = node 1423 already_processed = set() 1424 self.buildAttributes(node, node.attrib, already_processed) 1425 for child in node: 1426 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 1427 self.buildChildren(child, node, nodeName_) 1428 def buildAttributes(self, node, attrs, already_processed): 1429 value = find_attr_value_('scope', node) 1430 if value is not None and 'scope' not in already_processed: 1431 already_processed.add('scope') 1432 self.scope = value 1433 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 1434 pass 1435# end class GenericRelationshipListType 1436 1437 1438class RelatedCampaignType(GenericRelationshipType): 1439 """Identifies or characterizes a relationship to a campaign.""" 1440 subclass = None 1441 superclass = GenericRelationshipType 1442 def __init__(self, Confidence=None, Information_Source=None, Relationship=None, Campaign=None): 1443 super(RelatedCampaignType, self).__init__(Confidence=Confidence, Information_Source=Information_Source, Relationship=Relationship) 1444 self.Campaign = Campaign 1445 def factory(*args_, **kwargs_): 1446 if RelatedCampaignType.subclass: 1447 return RelatedCampaignType.subclass(*args_, **kwargs_) 1448 else: 1449 return RelatedCampaignType(*args_, **kwargs_) 1450 factory = staticmethod(factory) 1451 def get_Campaign(self): return self.Campaign 1452 def set_Campaign(self, Campaign): self.Campaign = Campaign 1453 def hasContent_(self): 1454 if ( 1455 self.Campaign is not None or 1456 super(RelatedCampaignType, self).hasContent_() 1457 ): 1458 return True 1459 else: 1460 return False 1461 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedCampaignType', namespacedef_='', pretty_print=True): 1462 if pretty_print: 1463 eol_ = '\n' 1464 else: 1465 eol_ = '' 1466 showIndent(lwrite, level, pretty_print) 1467 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 1468 already_processed = set() 1469 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='RelatedCampaignType') 1470 if self.hasContent_(): 1471 lwrite('>%s' % (eol_, )) 1472 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 1473 showIndent(lwrite, level, pretty_print) 1474 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 1475 else: 1476 lwrite('/>%s' % (eol_, )) 1477 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='RelatedCampaignType'): 1478 super(RelatedCampaignType, self).exportAttributes(lwrite, level, already_processed, namespace_, name_='RelatedCampaignType') 1479 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedCampaignType', fromsubclass_=False, pretty_print=True): 1480 super(RelatedCampaignType, self).exportChildren(lwrite, level, nsmap, namespace_, name_, True, pretty_print=pretty_print) 1481 if pretty_print: 1482 eol_ = '\n' 1483 else: 1484 eol_ = '' 1485 if self.Campaign is not None: 1486 self.Campaign.export(lwrite, level, nsmap, namespace_, name_='Campaign', pretty_print=pretty_print) 1487 def build(self, node): 1488 self.__sourcenode__ = node 1489 already_processed = set() 1490 self.buildAttributes(node, node.attrib, already_processed) 1491 for child in node: 1492 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 1493 self.buildChildren(child, node, nodeName_) 1494 def buildAttributes(self, node, attrs, already_processed): 1495 super(RelatedCampaignType, self).buildAttributes(node, attrs, already_processed) 1496 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 1497 if nodeName_ == 'Campaign': 1498 from . import campaign 1499 obj_ = lookup_extension(child_, CampaignBaseType).factory() 1500 obj_.build(child_) 1501 self.set_Campaign(obj_) 1502 super(RelatedCampaignType, self).buildChildren(child_, node, nodeName_, True) 1503# end class RelatedCampaignType 1504 1505class RelatedCourseOfActionType(GenericRelationshipType): 1506 """Identifies or characterizes a relationship to a course of action.""" 1507 subclass = None 1508 superclass = GenericRelationshipType 1509 def __init__(self, Confidence=None, Information_Source=None, Relationship=None, Course_Of_Action=None): 1510 super(RelatedCourseOfActionType, self).__init__(Confidence=Confidence, Information_Source=Information_Source, Relationship=Relationship) 1511 self.Course_Of_Action = Course_Of_Action 1512 def factory(*args_, **kwargs_): 1513 if RelatedCourseOfActionType.subclass: 1514 return RelatedCourseOfActionType.subclass(*args_, **kwargs_) 1515 else: 1516 return RelatedCourseOfActionType(*args_, **kwargs_) 1517 factory = staticmethod(factory) 1518 def get_Course_Of_Action(self): return self.Course_Of_Action 1519 def set_Course_Of_Action(self, Course_Of_Action): self.Course_Of_Action = Course_Of_Action 1520 def hasContent_(self): 1521 if ( 1522 self.Course_Of_Action is not None or 1523 super(RelatedCourseOfActionType, self).hasContent_() 1524 ): 1525 return True 1526 else: 1527 return False 1528 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedCourseOfActionType', namespacedef_='', pretty_print=True): 1529 if pretty_print: 1530 eol_ = '\n' 1531 else: 1532 eol_ = '' 1533 showIndent(lwrite, level, pretty_print) 1534 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 1535 already_processed = set() 1536 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='RelatedCourseOfActionType') 1537 if self.hasContent_(): 1538 lwrite('>%s' % (eol_, )) 1539 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 1540 showIndent(lwrite, level, pretty_print) 1541 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 1542 else: 1543 lwrite('/>%s' % (eol_, )) 1544 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='RelatedCourseOfActionType'): 1545 super(RelatedCourseOfActionType, self).exportAttributes(lwrite, level, already_processed, namespace_, name_='RelatedCourseOfActionType') 1546 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedCourseOfActionType', fromsubclass_=False, pretty_print=True): 1547 super(RelatedCourseOfActionType, self).exportChildren(lwrite, level, nsmap, namespace_, name_, True, pretty_print=pretty_print) 1548 if pretty_print: 1549 eol_ = '\n' 1550 else: 1551 eol_ = '' 1552 if self.Course_Of_Action is not None: 1553 self.Course_Of_Action.export(lwrite, level, nsmap, namespace_, name_='Course_Of_Action', pretty_print=pretty_print) 1554 def build(self, node): 1555 self.__sourcenode__ = node 1556 already_processed = set() 1557 self.buildAttributes(node, node.attrib, already_processed) 1558 for child in node: 1559 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 1560 self.buildChildren(child, node, nodeName_) 1561 def buildAttributes(self, node, attrs, already_processed): 1562 super(RelatedCourseOfActionType, self).buildAttributes(node, attrs, already_processed) 1563 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 1564 if nodeName_ == 'Course_Of_Action': 1565 from . import course_of_action 1566 obj_ = lookup_extension(child_, CourseOfActionBaseType).factory() 1567 obj_.build(child_) 1568 self.set_Course_Of_Action(obj_) 1569 super(RelatedCourseOfActionType, self).buildChildren(child_, node, nodeName_, True) 1570# end class RelatedCourseOfActionType 1571 1572class RelatedExploitTargetType(GenericRelationshipType): 1573 """Identifies or characterizes a relationship to an exploit target.""" 1574 subclass = None 1575 superclass = GenericRelationshipType 1576 def __init__(self, Confidence=None, Information_Source=None, Relationship=None, Exploit_Target=None): 1577 super(RelatedExploitTargetType, self).__init__(Confidence=Confidence, Information_Source=Information_Source, Relationship=Relationship) 1578 self.Exploit_Target = Exploit_Target 1579 def factory(*args_, **kwargs_): 1580 if RelatedExploitTargetType.subclass: 1581 return RelatedExploitTargetType.subclass(*args_, **kwargs_) 1582 else: 1583 return RelatedExploitTargetType(*args_, **kwargs_) 1584 factory = staticmethod(factory) 1585 def get_Exploit_Target(self): return self.Exploit_Target 1586 def set_Exploit_Target(self, Exploit_Target): self.Exploit_Target = Exploit_Target 1587 def hasContent_(self): 1588 if ( 1589 self.Exploit_Target is not None or 1590 super(RelatedExploitTargetType, self).hasContent_() 1591 ): 1592 return True 1593 else: 1594 return False 1595 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedExploitTargetType', namespacedef_='', pretty_print=True): 1596 if pretty_print: 1597 eol_ = '\n' 1598 else: 1599 eol_ = '' 1600 showIndent(lwrite, level, pretty_print) 1601 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 1602 already_processed = set() 1603 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='RelatedExploitTargetType') 1604 if self.hasContent_(): 1605 lwrite('>%s' % (eol_, )) 1606 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 1607 showIndent(lwrite, level, pretty_print) 1608 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 1609 else: 1610 lwrite('/>%s' % (eol_, )) 1611 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='RelatedExploitTargetType'): 1612 super(RelatedExploitTargetType, self).exportAttributes(lwrite, level, already_processed, namespace_, name_='RelatedExploitTargetType') 1613 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedExploitTargetType', fromsubclass_=False, pretty_print=True): 1614 super(RelatedExploitTargetType, self).exportChildren(lwrite, level, nsmap, namespace_, name_, True, pretty_print=pretty_print) 1615 if pretty_print: 1616 eol_ = '\n' 1617 else: 1618 eol_ = '' 1619 if self.Exploit_Target is not None: 1620 self.Exploit_Target.export(lwrite, level, nsmap, namespace_, name_='Exploit_Target', pretty_print=pretty_print) 1621 def build(self, node): 1622 self.__sourcenode__ = node 1623 already_processed = set() 1624 self.buildAttributes(node, node.attrib, already_processed) 1625 for child in node: 1626 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 1627 self.buildChildren(child, node, nodeName_) 1628 def buildAttributes(self, node, attrs, already_processed): 1629 super(RelatedExploitTargetType, self).buildAttributes(node, attrs, already_processed) 1630 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 1631 if nodeName_ == 'Exploit_Target': 1632 obj_ = lookup_extension(child_, ExploitTargetBaseType).factory() 1633 obj_.build(child_) 1634 self.set_Exploit_Target(obj_) 1635 super(RelatedExploitTargetType, self).buildChildren(child_, node, nodeName_, True) 1636# end class RelatedExploitTargetType 1637 1638class RelatedIncidentType(GenericRelationshipType): 1639 """Identifies or characterizes a relationship to an incident.""" 1640 subclass = None 1641 superclass = GenericRelationshipType 1642 def __init__(self, Confidence=None, Information_Source=None, Relationship=None, Incident=None): 1643 super(RelatedIncidentType, self).__init__(Confidence=Confidence, Information_Source=Information_Source, Relationship=Relationship) 1644 self.Incident = Incident 1645 def factory(*args_, **kwargs_): 1646 if RelatedIncidentType.subclass: 1647 return RelatedIncidentType.subclass(*args_, **kwargs_) 1648 else: 1649 return RelatedIncidentType(*args_, **kwargs_) 1650 factory = staticmethod(factory) 1651 def get_Incident(self): return self.Incident 1652 def set_Incident(self, Incident): self.Incident = Incident 1653 def hasContent_(self): 1654 if ( 1655 self.Incident is not None or 1656 super(RelatedIncidentType, self).hasContent_() 1657 ): 1658 return True 1659 else: 1660 return False 1661 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedIncidentType', namespacedef_='', pretty_print=True): 1662 if pretty_print: 1663 eol_ = '\n' 1664 else: 1665 eol_ = '' 1666 showIndent(lwrite, level, pretty_print) 1667 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 1668 already_processed = set() 1669 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='RelatedIncidentType') 1670 if self.hasContent_(): 1671 lwrite('>%s' % (eol_, )) 1672 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 1673 showIndent(lwrite, level, pretty_print) 1674 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 1675 else: 1676 lwrite('/>%s' % (eol_, )) 1677 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='RelatedIncidentType'): 1678 super(RelatedIncidentType, self).exportAttributes(lwrite, level, already_processed, namespace_, name_='RelatedIncidentType') 1679 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedIncidentType', fromsubclass_=False, pretty_print=True): 1680 super(RelatedIncidentType, self).exportChildren(lwrite, level, nsmap, namespace_, name_, True, pretty_print=pretty_print) 1681 if pretty_print: 1682 eol_ = '\n' 1683 else: 1684 eol_ = '' 1685 if self.Incident is not None: 1686 self.Incident.export(lwrite, level, nsmap, namespace_, name_='Incident', pretty_print=pretty_print) 1687 def build(self, node): 1688 self.__sourcenode__ = node 1689 already_processed = set() 1690 self.buildAttributes(node, node.attrib, already_processed) 1691 for child in node: 1692 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 1693 self.buildChildren(child, node, nodeName_) 1694 def buildAttributes(self, node, attrs, already_processed): 1695 super(RelatedIncidentType, self).buildAttributes(node, attrs, already_processed) 1696 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 1697 if nodeName_ == 'Incident': 1698 from . import incident 1699 obj_ = lookup_extension(child_, IncidentBaseType).factory() 1700 obj_.build(child_) 1701 self.set_Incident(obj_) 1702 super(RelatedIncidentType, self).buildChildren(child_, node, nodeName_, True) 1703# end class RelatedIncidentType 1704 1705class RelatedIndicatorType(GenericRelationshipType): 1706 """Identifies or characterizes a relationship to an indicator.""" 1707 subclass = None 1708 superclass = GenericRelationshipType 1709 def __init__(self, Confidence=None, Information_Source=None, Relationship=None, Indicator=None): 1710 super(RelatedIndicatorType, self).__init__(Confidence=Confidence, Information_Source=Information_Source, Relationship=Relationship) 1711 self.Indicator = Indicator 1712 def factory(*args_, **kwargs_): 1713 if RelatedIndicatorType.subclass: 1714 return RelatedIndicatorType.subclass(*args_, **kwargs_) 1715 else: 1716 return RelatedIndicatorType(*args_, **kwargs_) 1717 factory = staticmethod(factory) 1718 def get_Indicator(self): return self.Indicator 1719 def set_Indicator(self, Indicator): self.Indicator = Indicator 1720 def hasContent_(self): 1721 if ( 1722 self.Indicator is not None or 1723 super(RelatedIndicatorType, self).hasContent_() 1724 ): 1725 return True 1726 else: 1727 return False 1728 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedIndicatorType', namespacedef_='', pretty_print=True): 1729 if pretty_print: 1730 eol_ = '\n' 1731 else: 1732 eol_ = '' 1733 showIndent(lwrite, level, pretty_print) 1734 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 1735 already_processed = set() 1736 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='RelatedIndicatorType') 1737 if self.hasContent_(): 1738 lwrite('>%s' % (eol_, )) 1739 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 1740 showIndent(lwrite, level, pretty_print) 1741 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 1742 else: 1743 lwrite('/>%s' % (eol_, )) 1744 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='RelatedIndicatorType'): 1745 super(RelatedIndicatorType, self).exportAttributes(lwrite, level, already_processed, namespace_, name_='RelatedIndicatorType') 1746 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedIndicatorType', fromsubclass_=False, pretty_print=True): 1747 super(RelatedIndicatorType, self).exportChildren(lwrite, level, nsmap, namespace_, name_, True, pretty_print=pretty_print) 1748 if pretty_print: 1749 eol_ = '\n' 1750 else: 1751 eol_ = '' 1752 if self.Indicator is not None: 1753 self.Indicator.export(lwrite, level, nsmap, namespace_, name_='Indicator', pretty_print=pretty_print) 1754 def build(self, node): 1755 self.__sourcenode__ = node 1756 already_processed = set() 1757 self.buildAttributes(node, node.attrib, already_processed) 1758 for child in node: 1759 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 1760 self.buildChildren(child, node, nodeName_) 1761 def buildAttributes(self, node, attrs, already_processed): 1762 super(RelatedIndicatorType, self).buildAttributes(node, attrs, already_processed) 1763 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 1764 if nodeName_ == 'Indicator': 1765 from . import indicator 1766 obj_ = lookup_extension(child_, IncidentBaseType).factory() 1767 obj_.build(child_) 1768 self.set_Indicator(obj_) 1769 super(RelatedIndicatorType, self).buildChildren(child_, node, nodeName_, True) 1770# end class RelatedIndicatorType 1771 1772class RelatedObservableType(GenericRelationshipType): 1773 """Identifies or characterizes a relationship to a cyber observable.""" 1774 subclass = None 1775 superclass = GenericRelationshipType 1776 def __init__(self, Confidence=None, Information_Source=None, Relationship=None, Observable=None): 1777 super(RelatedObservableType, self).__init__(Confidence=Confidence, Information_Source=Information_Source, Relationship=Relationship) 1778 self.Observable = Observable 1779 def factory(*args_, **kwargs_): 1780 if RelatedObservableType.subclass: 1781 return RelatedObservableType.subclass(*args_, **kwargs_) 1782 else: 1783 return RelatedObservableType(*args_, **kwargs_) 1784 factory = staticmethod(factory) 1785 def get_Observable(self): return self.Observable 1786 def set_Observable(self, Observable): self.Observable = Observable 1787 def hasContent_(self): 1788 if ( 1789 self.Observable is not None or 1790 super(RelatedObservableType, self).hasContent_() 1791 ): 1792 return True 1793 else: 1794 return False 1795 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedObservableType', namespacedef_='', pretty_print=True): 1796 if pretty_print: 1797 eol_ = '\n' 1798 else: 1799 eol_ = '' 1800 showIndent(lwrite, level, pretty_print) 1801 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 1802 already_processed = set() 1803 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='RelatedObservableType') 1804 if self.hasContent_(): 1805 lwrite('>%s' % (eol_, )) 1806 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 1807 showIndent(lwrite, level, pretty_print) 1808 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 1809 else: 1810 lwrite('/>%s' % (eol_, )) 1811 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='RelatedObservableType'): 1812 super(RelatedObservableType, self).exportAttributes(lwrite, level, already_processed, namespace_, name_='RelatedObservableType') 1813 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedObservableType', fromsubclass_=False, pretty_print=True): 1814 super(RelatedObservableType, self).exportChildren(lwrite, level, nsmap, namespace_, name_, True, pretty_print=pretty_print) 1815 if pretty_print: 1816 eol_ = '\n' 1817 else: 1818 eol_ = '' 1819 if self.Observable is not None: 1820 self.Observable.export(lwrite, level, "%s:" % (nsmap[namespace_]), name_='Observable', pretty_print=pretty_print) 1821 def build(self, node): 1822 self.__sourcenode__ = node 1823 already_processed = set() 1824 self.buildAttributes(node, node.attrib, already_processed) 1825 for child in node: 1826 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 1827 self.buildChildren(child, node, nodeName_) 1828 def buildAttributes(self, node, attrs, already_processed): 1829 super(RelatedObservableType, self).buildAttributes(node, attrs, already_processed) 1830 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 1831 if nodeName_ == 'Observable': 1832 obj_ = cybox_core_binding.ObservableType.factory() 1833 obj_.build(child_) 1834 self.set_Observable(obj_) 1835 super(RelatedObservableType, self).buildChildren(child_, node, nodeName_, True) 1836# end class RelatedObservableType 1837 1838class RelatedThreatActorType(GenericRelationshipType): 1839 """Identifies or characterizes a relationship to a threat actor.""" 1840 subclass = None 1841 superclass = GenericRelationshipType 1842 def __init__(self, Confidence=None, Information_Source=None, Relationship=None, Threat_Actor=None): 1843 super(RelatedThreatActorType, self).__init__(Confidence=Confidence, Information_Source=Information_Source, Relationship=Relationship) 1844 self.Threat_Actor = Threat_Actor 1845 def factory(*args_, **kwargs_): 1846 if RelatedThreatActorType.subclass: 1847 return RelatedThreatActorType.subclass(*args_, **kwargs_) 1848 else: 1849 return RelatedThreatActorType(*args_, **kwargs_) 1850 factory = staticmethod(factory) 1851 def get_Threat_Actor(self): return self.Threat_Actor 1852 def set_Threat_Actor(self, Threat_Actor): self.Threat_Actor = Threat_Actor 1853 def hasContent_(self): 1854 if ( 1855 self.Threat_Actor is not None or 1856 super(RelatedThreatActorType, self).hasContent_() 1857 ): 1858 return True 1859 else: 1860 return False 1861 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedThreatActorType', namespacedef_='', pretty_print=True): 1862 if pretty_print: 1863 eol_ = '\n' 1864 else: 1865 eol_ = '' 1866 showIndent(lwrite, level, pretty_print) 1867 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 1868 already_processed = set() 1869 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='RelatedThreatActorType') 1870 if self.hasContent_(): 1871 lwrite('>%s' % (eol_, )) 1872 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 1873 showIndent(lwrite, level, pretty_print) 1874 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 1875 else: 1876 lwrite('/>%s' % (eol_, )) 1877 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='RelatedThreatActorType'): 1878 super(RelatedThreatActorType, self).exportAttributes(lwrite, level, already_processed, namespace_, name_='RelatedThreatActorType') 1879 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedThreatActorType', fromsubclass_=False, pretty_print=True): 1880 super(RelatedThreatActorType, self).exportChildren(lwrite, level, nsmap, namespace_, name_, True, pretty_print=pretty_print) 1881 if pretty_print: 1882 eol_ = '\n' 1883 else: 1884 eol_ = '' 1885 if self.Threat_Actor is not None: 1886 self.Threat_Actor.export(lwrite, level, nsmap, namespace_, name_='Threat_Actor', pretty_print=pretty_print) 1887 def build(self, node): 1888 self.__sourcenode__ = node 1889 already_processed = set() 1890 self.buildAttributes(node, node.attrib, already_processed) 1891 for child in node: 1892 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 1893 self.buildChildren(child, node, nodeName_) 1894 def buildAttributes(self, node, attrs, already_processed): 1895 super(RelatedThreatActorType, self).buildAttributes(node, attrs, already_processed) 1896 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 1897 if nodeName_ == 'Threat_Actor': 1898 from . import threat_actor 1899 obj_ = lookup_extension(child_, ThreatActorBaseType).factory() 1900 obj_.build(child_) 1901 self.set_Threat_Actor(obj_) 1902 super(RelatedThreatActorType, self).buildChildren(child_, node, nodeName_, True) 1903# end class RelatedThreatActorType 1904 1905class RelatedTTPType(GenericRelationshipType): 1906 """Identifies or characterizes a relationship to an TTP.""" 1907 subclass = None 1908 superclass = GenericRelationshipType 1909 def __init__(self, Confidence=None, Information_Source=None, Relationship=None, TTP=None): 1910 super(RelatedTTPType, self).__init__(Confidence=Confidence, Information_Source=Information_Source, Relationship=Relationship) 1911 self.TTP = TTP 1912 def factory(*args_, **kwargs_): 1913 if RelatedTTPType.subclass: 1914 return RelatedTTPType.subclass(*args_, **kwargs_) 1915 else: 1916 return RelatedTTPType(*args_, **kwargs_) 1917 factory = staticmethod(factory) 1918 def get_TTP(self): return self.TTP 1919 def set_TTP(self, TTP): self.TTP = TTP 1920 def hasContent_(self): 1921 if ( 1922 self.TTP is not None or 1923 super(RelatedTTPType, self).hasContent_() 1924 ): 1925 return True 1926 else: 1927 return False 1928 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedTTPType', namespacedef_='', pretty_print=True): 1929 if pretty_print: 1930 eol_ = '\n' 1931 else: 1932 eol_ = '' 1933 showIndent(lwrite, level, pretty_print) 1934 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 1935 already_processed = set() 1936 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='RelatedTTPType') 1937 if self.hasContent_(): 1938 lwrite('>%s' % (eol_, )) 1939 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 1940 showIndent(lwrite, level, pretty_print) 1941 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 1942 else: 1943 lwrite('/>%s' % (eol_, )) 1944 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='RelatedTTPType'): 1945 super(RelatedTTPType, self).exportAttributes(lwrite, level, already_processed, namespace_, name_='RelatedTTPType') 1946 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedTTPType', fromsubclass_=False, pretty_print=True): 1947 super(RelatedTTPType, self).exportChildren(lwrite, level, nsmap, namespace_, name_, True, pretty_print=pretty_print) 1948 if pretty_print: 1949 eol_ = '\n' 1950 else: 1951 eol_ = '' 1952 if self.TTP is not None: 1953 self.TTP.export(lwrite, level, nsmap, namespace_, name_='TTP', pretty_print=pretty_print) 1954 def build(self, node): 1955 self.__sourcenode__ = node 1956 already_processed = set() 1957 self.buildAttributes(node, node.attrib, already_processed) 1958 for child in node: 1959 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 1960 self.buildChildren(child, node, nodeName_) 1961 def buildAttributes(self, node, attrs, already_processed): 1962 super(RelatedTTPType, self).buildAttributes(node, attrs, already_processed) 1963 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 1964 if nodeName_ == 'TTP': 1965 from . import ttp 1966 obj_ = lookup_extension(child_, TTPBaseType).factory() 1967 obj_.build(child_) 1968 self.set_TTP(obj_) 1969 super(RelatedTTPType, self).buildChildren(child_, node, nodeName_, True) 1970# end class RelatedTTPType 1971 1972class RelatedIdentityType(GenericRelationshipType): 1973 """Identifies or characterizes a relationship to an Identity.""" 1974 subclass = None 1975 superclass = GenericRelationshipType 1976 def __init__(self, Confidence=None, Information_Source=None, Relationship=None, Identity=None): 1977 super(RelatedIdentityType, self).__init__(Confidence=Confidence, Information_Source=Information_Source, Relationship=Relationship) 1978 self.Identity = Identity 1979 def factory(*args_, **kwargs_): 1980 if RelatedIdentityType.subclass: 1981 return RelatedIdentityType.subclass(*args_, **kwargs_) 1982 else: 1983 return RelatedIdentityType(*args_, **kwargs_) 1984 factory = staticmethod(factory) 1985 def get_Identity(self): return self.Identity 1986 def set_Identity(self, Identity): self.Identity = Identity 1987 def hasContent_(self): 1988 if ( 1989 self.Identity is not None or 1990 super(RelatedIdentityType, self).hasContent_() 1991 ): 1992 return True 1993 else: 1994 return False 1995 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedIdentityType', namespacedef_='', pretty_print=True): 1996 if pretty_print: 1997 eol_ = '\n' 1998 else: 1999 eol_ = '' 2000 showIndent(lwrite, level, pretty_print) 2001 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 2002 already_processed = set() 2003 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='RelatedIdentityType') 2004 if self.hasContent_(): 2005 lwrite('>%s' % (eol_, )) 2006 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 2007 showIndent(lwrite, level, pretty_print) 2008 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 2009 else: 2010 lwrite('/>%s' % (eol_, )) 2011 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='RelatedIdentityType'): 2012 super(RelatedIdentityType, self).exportAttributes(lwrite, level, already_processed, namespace_, name_='RelatedIdentityType') 2013 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedIdentityType', fromsubclass_=False, pretty_print=True): 2014 super(RelatedIdentityType, self).exportChildren(lwrite, level, nsmap, namespace_, name_, True, pretty_print=pretty_print) 2015 if pretty_print: 2016 eol_ = '\n' 2017 else: 2018 eol_ = '' 2019 if self.Identity is not None: 2020 self.Identity.export(lwrite, level, nsmap, namespace_, name_='Identity', pretty_print=pretty_print) 2021 def build(self, node): 2022 self.__sourcenode__ = node 2023 already_processed = set() 2024 self.buildAttributes(node, node.attrib, already_processed) 2025 for child in node: 2026 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 2027 self.buildChildren(child, node, nodeName_) 2028 def buildAttributes(self, node, attrs, already_processed): 2029 super(RelatedIdentityType, self).buildAttributes(node, attrs, already_processed) 2030 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 2031 if nodeName_ == 'Identity': 2032 from .extensions.identity import ciq_identity_3_0 2033 obj_ = lookup_extension(child_, IdentityType).factory() 2034 obj_.build(child_) 2035 self.set_Identity(obj_) 2036 super(RelatedIdentityType, self).buildChildren(child_, node, nodeName_, True) 2037# end class RelatedIdentityType 2038 2039class IndicatorBaseType(GeneratedsSuper): 2040 """This type represents the STIX Indicator component. It is extended 2041 using the XML Schema Extension feature by the STIX Indicator 2042 type itself. Users of this type who wish to express a full 2043 indicator using STIX must do so using the xsi:type extension 2044 feature. The STIX-defined Indicator type is IndicatorType in the 2045 http://stix.mitre.org/Indicator-1 namespace. This type is 2046 defined in the indicator.xsd file or at the URL 2047 http://stix.mitre.org/XMLSchema/indicator/1.2/indicator.xsd. 2048 Alternatively, uses that require simply specifying an idref as a 2049 reference to an indicator defined elsewhere can do so without 2050 specifying an xsi:type. Specifies a unique ID for this 2051 Indicator.Specifies a reference to the ID of an Indicator 2052 specified elsewhere.""" 2053 subclass = None 2054 superclass = None 2055 def __init__(self, idref=None, id=None, timestamp=None): 2056 self.idref = _cast(None, idref) 2057 self.id = _cast(None, id) 2058 self.timestamp = _cast(None, timestamp) 2059 def factory(*args_, **kwargs_): 2060 if IndicatorBaseType.subclass: 2061 return IndicatorBaseType.subclass(*args_, **kwargs_) 2062 else: 2063 return IndicatorBaseType(*args_, **kwargs_) 2064 factory = staticmethod(factory) 2065 def get_idref(self): return self.idref 2066 def set_idref(self, idref): self.idref = idref 2067 def get_id(self): return self.id 2068 def set_id(self, id): self.id = id 2069 def get_timestamp(self): return self.timestamp 2070 def set_timestamp(self, timestamp): self.timestamp = timestamp 2071 def hasContent_(self): 2072 if ( 2073 2074 ): 2075 return True 2076 else: 2077 return False 2078 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='IndicatorBaseType', namespacedef_='', pretty_print=True): 2079 if pretty_print: 2080 eol_ = '\n' 2081 else: 2082 eol_ = '' 2083 showIndent(lwrite, level, pretty_print) 2084 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 2085 already_processed = set() 2086 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='IndicatorBaseType') 2087 if self.hasContent_(): 2088 lwrite('>%s' % (eol_, )) 2089 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 2090 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 2091 else: 2092 lwrite('/>%s' % (eol_, )) 2093 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='IndicatorBaseType'): 2094 if self.idref is not None and 'idref' not in already_processed: 2095 already_processed.add('idref') 2096 lwrite(' idref=%s' % (quote_attrib(self.idref), )) 2097 if self.id is not None and 'id' not in already_processed: 2098 already_processed.add('id') 2099 lwrite(' id=%s' % (quote_attrib(self.id), )) 2100 if self.timestamp is not None and 'timestamp' not in already_processed: 2101 already_processed.add('timestamp') 2102 lwrite(' timestamp="%s"' % self.gds_format_datetime(self.timestamp, input_name='timestamp')) 2103 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='IndicatorBaseType', fromsubclass_=False, pretty_print=True): 2104 pass 2105 def build(self, node): 2106 self.__sourcenode__ = node 2107 already_processed = set() 2108 self.buildAttributes(node, node.attrib, already_processed) 2109 for child in node: 2110 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 2111 self.buildChildren(child, node, nodeName_) 2112 def buildAttributes(self, node, attrs, already_processed): 2113 value = find_attr_value_('idref', node) 2114 if value is not None and 'idref' not in already_processed: 2115 already_processed.add('idref') 2116 self.idref = value 2117 value = find_attr_value_('id', node) 2118 if value is not None and 'id' not in already_processed: 2119 already_processed.add('id') 2120 self.id = value 2121 value = find_attr_value_('timestamp', node) 2122 if value is not None and 'timestamp' not in already_processed: 2123 already_processed.add('timestamp') 2124 try: 2125 self.timestamp = self.gds_parse_datetime(value, node, 'timestamp') 2126 except ValueError as exp: 2127 raise ValueError('Bad date-time attribute (timestamp): %s' % exp) 2128 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 2129 pass 2130# end class IndicatorBaseType 2131 2132class IncidentBaseType(GeneratedsSuper): 2133 """This type represents the STIX Incident component. It is extended 2134 using the XML Schema Extension feature by the STIX Incident type 2135 itself. Users of this type who wish to express a full incident 2136 using STIX must do so using the xsi:type extension feature. The 2137 STIX-defined Incident type is IncidentType in the 2138 http://stix.mitre.org/Incident-1 namespace. This type is defined 2139 in the incident.xsd file or at the URL http://stix.mitre.org/XML 2140 Schema/incident/1.1/incident.xsd.Alternatively, uses that 2141 require simply specifying an idref as a reference to an incident 2142 defined elsewhere can do so without specifying an 2143 xsi:type.Specifies a globally unique identifier for this cyber 2144 threat Incident.Specifies a globally unique identifier for a 2145 cyber threat Incident specified elsewhere.When idref is 2146 specified, the id attribute must not be specified, and any 2147 instance of this Incident should not hold content.In conjunction 2148 with the idref, this field may be used to reference a specific 2149 version of an incident defined elsewhere. The referenced version 2150 timestamp is contained in the 2151 Information_Source/Time/Produced_Time field of the related 2152 incident and must be an exact match.This field must only be used 2153 in conjunction with the idref field.""" 2154 subclass = None 2155 superclass = None 2156 def __init__(self, idref=None, id=None, timestamp=None): 2157 self.idref = _cast(None, idref) 2158 self.id = _cast(None, id) 2159 self.timestamp = _cast(None, timestamp) 2160 pass 2161 def factory(*args_, **kwargs_): 2162 if IncidentBaseType.subclass: 2163 return IncidentBaseType.subclass(*args_, **kwargs_) 2164 else: 2165 return IncidentBaseType(*args_, **kwargs_) 2166 factory = staticmethod(factory) 2167 def get_idref(self): return self.idref 2168 def set_idref(self, idref): self.idref = idref 2169 def get_id(self): return self.id 2170 def set_id(self, id): self.id = id 2171 def get_timestamp(self): return self.timestamp 2172 def set_timestamp(self, timestamp): self.timestamp = timestamp 2173 def hasContent_(self): 2174 if ( 2175 2176 ): 2177 return True 2178 else: 2179 return False 2180 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='IncidentBaseType', namespacedef_='', pretty_print=True): 2181 if pretty_print: 2182 eol_ = '\n' 2183 else: 2184 eol_ = '' 2185 showIndent(lwrite, level, pretty_print) 2186 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 2187 already_processed = set() 2188 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='IncidentBaseType') 2189 if self.hasContent_(): 2190 lwrite('>%s' % (eol_, )) 2191 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 2192 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 2193 else: 2194 lwrite('/>%s' % (eol_, )) 2195 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='IncidentBaseType'): 2196 if self.idref is not None and 'idref' not in already_processed: 2197 already_processed.add('idref') 2198 lwrite(' idref=%s' % (quote_attrib(self.idref), )) 2199 if self.id is not None and 'id' not in already_processed: 2200 already_processed.add('id') 2201 lwrite(' id=%s' % (quote_attrib(self.id), )) 2202 if self.timestamp is not None and 'timestamp' not in already_processed: 2203 already_processed.add('timestamp') 2204 lwrite(' timestamp="%s"' % self.gds_format_datetime(self.timestamp, input_name='timestamp')) 2205 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='IncidentBaseType', fromsubclass_=False, pretty_print=True): 2206 pass 2207 def build(self, node): 2208 self.__sourcenode__ = node 2209 already_processed = set() 2210 self.buildAttributes(node, node.attrib, already_processed) 2211 for child in node: 2212 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 2213 self.buildChildren(child, node, nodeName_) 2214 def buildAttributes(self, node, attrs, already_processed): 2215 value = find_attr_value_('idref', node) 2216 if value is not None and 'idref' not in already_processed: 2217 already_processed.add('idref') 2218 self.idref = value 2219 value = find_attr_value_('id', node) 2220 if value is not None and 'id' not in already_processed: 2221 already_processed.add('id') 2222 self.id = value 2223 value = find_attr_value_('timestamp', node) 2224 if value is not None and 'timestamp' not in already_processed: 2225 already_processed.add('timestamp') 2226 try: 2227 self.timestamp = self.gds_parse_datetime(value, node, 'timestamp') 2228 except ValueError as exp: 2229 raise ValueError('Bad date-time attribute (timestamp): %s' % exp) 2230 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 2231 pass 2232# end class IncidentBaseType 2233 2234 2235class TTPBaseType(GeneratedsSuper): 2236 """This type represents the STIX TTP component. It is extended using 2237 the XML Schema Extension feature by the STIX TTP type itself. 2238 Users of this type who wish to express a full TTP using STIX 2239 must do so using the xsi:type extension feature. The STIX- 2240 defined TTP type is TTPType in the http://stix.mitre.org/TTP-1 2241 namespace. This type is defined in the ttp.xsd file or at the 2242 URL 2243 http://stix.mitre.org/XMLSchema/ttp/1.1/ttp.xsd.Alternatively, 2244 uses that require simply specifying an idref as a reference to a 2245 TTP defined elsewhere can do so without specifying an 2246 xsi:type.Specifies a globally unique identifier for this TTP 2247 item. Specifies a globally unique identifier of a TTP item 2248 specified elsewhere.When idref is specified, the id attribute 2249 must not be specified, and any instance of this TTP item should 2250 not hold content.In conjunction with the idref, this field may 2251 be used to reference a specific version of a TTP defined 2252 elsewhere. The referenced version timestamp is contained in the 2253 Information_Source/Time/Produced_Time field of the related TTP 2254 and must be an exact match.This field must only be used in 2255 conjunction with the idref field.""" 2256 subclass = None 2257 superclass = None 2258 def __init__(self, idref=None, id=None, timestamp=None): 2259 self.idref = _cast(None, idref) 2260 self.id = _cast(None, id) 2261 self.timestamp = _cast(None, timestamp) 2262 pass 2263 def factory(*args_, **kwargs_): 2264 if TTPBaseType.subclass: 2265 return TTPBaseType.subclass(*args_, **kwargs_) 2266 else: 2267 return TTPBaseType(*args_, **kwargs_) 2268 factory = staticmethod(factory) 2269 def get_idref(self): return self.idref 2270 def set_idref(self, idref): self.idref = idref 2271 def get_id(self): return self.id 2272 def set_id(self, id): self.id = id 2273 def get_timestamp(self): return self.timestamp 2274 def set_timestamp(self, timestamp): self.timestamp = timestamp 2275 def hasContent_(self): 2276 if ( 2277 2278 ): 2279 return True 2280 else: 2281 return False 2282 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='TTPBaseType', namespacedef_='', pretty_print=True): 2283 if pretty_print: 2284 eol_ = '\n' 2285 else: 2286 eol_ = '' 2287 showIndent(lwrite, level, pretty_print) 2288 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 2289 already_processed = set() 2290 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='TTPBaseType') 2291 if self.hasContent_(): 2292 lwrite('>%s' % (eol_, )) 2293 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 2294 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 2295 else: 2296 lwrite('/>%s' % (eol_, )) 2297 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='TTPBaseType'): 2298 if self.idref is not None and 'idref' not in already_processed: 2299 already_processed.add('idref') 2300 lwrite(' idref=%s' % (quote_attrib(self.idref), )) 2301 if self.id is not None and 'id' not in already_processed: 2302 already_processed.add('id') 2303 lwrite(' id=%s' % (quote_attrib(self.id), )) 2304 if self.timestamp is not None and 'timestamp' not in already_processed: 2305 already_processed.add('timestamp') 2306 lwrite(' timestamp="%s"' % self.gds_format_datetime(self.timestamp, input_name='timestamp')) 2307 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='TTPBaseType', fromsubclass_=False, pretty_print=True): 2308 pass 2309 def build(self, node): 2310 self.__sourcenode__ = node 2311 already_processed = set() 2312 self.buildAttributes(node, node.attrib, already_processed) 2313 for child in node: 2314 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 2315 self.buildChildren(child, node, nodeName_) 2316 def buildAttributes(self, node, attrs, already_processed): 2317 value = find_attr_value_('idref', node) 2318 if value is not None and 'idref' not in already_processed: 2319 already_processed.add('idref') 2320 self.idref = value 2321 value = find_attr_value_('id', node) 2322 if value is not None and 'id' not in already_processed: 2323 already_processed.add('id') 2324 self.id = value 2325 value = find_attr_value_('timestamp', node) 2326 if value is not None and 'timestamp' not in already_processed: 2327 already_processed.add('timestamp') 2328 try: 2329 self.timestamp = self.gds_parse_datetime(value, node, 'timestamp') 2330 except ValueError as exp: 2331 raise ValueError('Bad date-time attribute (timestamp): %s' % exp) 2332 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 2333 pass 2334# end class TTPBaseType 2335 2336class ExploitTargetBaseType(GeneratedsSuper): 2337 """This type represents the STIX Exploit Target component. It is 2338 extended using the XML Schema Extension feature by the STIX 2339 Exploit Target type itself. Users of this type who wish to 2340 express a full exploit target using STIX must do so using the 2341 xsi:type extension feature. The STIX-defined Exploit Target type 2342 is ExploitTargetType in the 2343 http://stix.mitre.org/ExploitTarget-1 namespace. This type is 2344 defined in the exploit_target.xsd file or at the URL http://stix 2345 .mitre.org/XMLSchema/exploit_target/1.1/exploit_target.xsd.Alter 2346 natively, uses that require simply specifying an idref as a 2347 reference to an exploit target defined elsewhere can do so 2348 without specifying an xsi:type.Specifies a globally unique 2349 identifier for this ExploitTarget. Specifies a globally unique 2350 identifier of an ExploitTarget specified elsewhere.When idref is 2351 specified, the id attribute must not be specified, and any 2352 instance of this ExploitTarget should not hold content.In 2353 conjunction with the idref, this field may be used to reference 2354 a specific version of an exploit target defined elsewhere. The 2355 referenced version timestamp is contained in the 2356 Information_Source/Time/Produced_Time field of the related 2357 exploit target and must be an exact match.This field must only 2358 be used in conjunction with the idref field.""" 2359 subclass = None 2360 superclass = None 2361 def __init__(self, idref=None, id=None, timestamp=None): 2362 self.idref = _cast(None, idref) 2363 self.id = _cast(None, id) 2364 self.timestamp = _cast(None, timestamp) 2365 pass 2366 def factory(*args_, **kwargs_): 2367 if ExploitTargetBaseType.subclass: 2368 return ExploitTargetBaseType.subclass(*args_, **kwargs_) 2369 else: 2370 return ExploitTargetBaseType(*args_, **kwargs_) 2371 factory = staticmethod(factory) 2372 def get_idref(self): return self.idref 2373 def set_idref(self, idref): self.idref = idref 2374 def get_id(self): return self.id 2375 def set_id(self, id): self.id = id 2376 def get_timestamp(self): return self.timestamp 2377 def set_timestamp(self, timestamp): self.timestamp = timestamp 2378 def hasContent_(self): 2379 if ( 2380 2381 ): 2382 return True 2383 else: 2384 return False 2385 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='ExploitTargetBaseType', namespacedef_='', pretty_print=True): 2386 if pretty_print: 2387 eol_ = '\n' 2388 else: 2389 eol_ = '' 2390 showIndent(lwrite, level, pretty_print) 2391 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 2392 already_processed = set() 2393 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='ExploitTargetBaseType') 2394 if self.hasContent_(): 2395 lwrite('>%s' % (eol_, )) 2396 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 2397 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 2398 else: 2399 lwrite('/>%s' % (eol_, )) 2400 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='ExploitTargetBaseType'): 2401 if self.idref is not None and 'idref' not in already_processed: 2402 already_processed.add('idref') 2403 lwrite(' idref=%s' % (quote_attrib(self.idref), )) 2404 if self.id is not None and 'id' not in already_processed: 2405 already_processed.add('id') 2406 lwrite(' id=%s' % (quote_attrib(self.id), )) 2407 if self.timestamp is not None and 'timestamp' not in already_processed: 2408 already_processed.add('timestamp') 2409 lwrite(' timestamp="%s"' % self.gds_format_datetime(self.timestamp, input_name='timestamp')) 2410 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='ExploitTargetBaseType', fromsubclass_=False, pretty_print=True): 2411 pass 2412 def build(self, node): 2413 self.__sourcenode__ = node 2414 already_processed = set() 2415 self.buildAttributes(node, node.attrib, already_processed) 2416 for child in node: 2417 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 2418 self.buildChildren(child, node, nodeName_) 2419 def buildAttributes(self, node, attrs, already_processed): 2420 value = find_attr_value_('idref', node) 2421 if value is not None and 'idref' not in already_processed: 2422 already_processed.add('idref') 2423 self.idref = value 2424 value = find_attr_value_('id', node) 2425 if value is not None and 'id' not in already_processed: 2426 already_processed.add('id') 2427 self.id = value 2428 value = find_attr_value_('timestamp', node) 2429 if value is not None and 'timestamp' not in already_processed: 2430 already_processed.add('timestamp') 2431 try: 2432 self.timestamp = self.gds_parse_datetime(value, node, 'timestamp') 2433 except ValueError as exp: 2434 raise ValueError('Bad date-time attribute (timestamp): %s' % exp) 2435 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 2436 pass 2437# end class ExploitTargetBaseType 2438 2439class CourseOfActionBaseType(GeneratedsSuper): 2440 """This type represents the STIX Course of Action component. It is 2441 extended using the XML Schema Extension feature by the STIX 2442 Course of Action type itself. Users of this type who wish to 2443 express a full course of action using STIX must do so using the 2444 xsi:type extension feature. The STIX-defined Course of Action 2445 type is CourseOfActionType in the 2446 http://stix.mitre.org/CourseOfAction-1 namespace. This type is 2447 defined in the course_of_action.xsd file or at the URL http://st 2448 ix.mitre.org/XMLSchema/course_of_action/1.1/course_of_action.xsd 2449 .Alternatively, uses that require simply specifying an idref as 2450 a reference to a course of action defined elsewhere can do so 2451 without specifying an xsi:type.Specifies a globally unique 2452 identifier for this COA. Specifies a globally unique identifier 2453 of a COA specified elsewhere.When idref is specified, the id 2454 attribute must not be specified, and any instance of this COA 2455 should not hold content.In conjunction with the idref, this 2456 field may be used to reference a specific version of a course of 2457 action defined elsewhere. The referenced version timestamp is 2458 contained in the Information_Source/Time/Produced_Time field of 2459 the related course of action and must be an exact match.This 2460 field must only be used in conjunction with the idref field.""" 2461 subclass = None 2462 superclass = None 2463 def __init__(self, idref=None, id=None, timestamp=None): 2464 self.idref = _cast(None, idref) 2465 self.id = _cast(None, id) 2466 self.timestamp = _cast(None, timestamp) 2467 pass 2468 def factory(*args_, **kwargs_): 2469 if CourseOfActionBaseType.subclass: 2470 return CourseOfActionBaseType.subclass(*args_, **kwargs_) 2471 else: 2472 return CourseOfActionBaseType(*args_, **kwargs_) 2473 factory = staticmethod(factory) 2474 def get_idref(self): return self.idref 2475 def set_idref(self, idref): self.idref = idref 2476 def get_id(self): return self.id 2477 def set_id(self, id): self.id = id 2478 def get_timestamp(self): return self.timestamp 2479 def set_timestamp(self, timestamp): self.timestamp = timestamp 2480 def hasContent_(self): 2481 if ( 2482 2483 ): 2484 return True 2485 else: 2486 return False 2487 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='CourseOfActionBaseType', namespacedef_='', pretty_print=True): 2488 if pretty_print: 2489 eol_ = '\n' 2490 else: 2491 eol_ = '' 2492 showIndent(lwrite, level, pretty_print) 2493 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 2494 already_processed = set() 2495 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='CourseOfActionBaseType') 2496 if self.hasContent_(): 2497 lwrite('>%s' % (eol_, )) 2498 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 2499 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 2500 else: 2501 lwrite('/>%s' % (eol_, )) 2502 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='CourseOfActionBaseType'): 2503 if self.idref is not None and 'idref' not in already_processed: 2504 already_processed.add('idref') 2505 lwrite(' idref=%s' % (quote_attrib(self.idref), )) 2506 if self.id is not None and 'id' not in already_processed: 2507 already_processed.add('id') 2508 lwrite(' id=%s' % (quote_attrib(self.id), )) 2509 if self.timestamp is not None and 'timestamp' not in already_processed: 2510 already_processed.add('timestamp') 2511 lwrite(' timestamp="%s"' % self.gds_format_datetime(self.timestamp, input_name='timestamp')) 2512 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='CourseOfActionBaseType', fromsubclass_=False, pretty_print=True): 2513 pass 2514 def build(self, node): 2515 self.__sourcenode__ = node 2516 already_processed = set() 2517 self.buildAttributes(node, node.attrib, already_processed) 2518 for child in node: 2519 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 2520 self.buildChildren(child, node, nodeName_) 2521 def buildAttributes(self, node, attrs, already_processed): 2522 value = find_attr_value_('idref', node) 2523 if value is not None and 'idref' not in already_processed: 2524 already_processed.add('idref') 2525 self.idref = value 2526 value = find_attr_value_('id', node) 2527 if value is not None and 'id' not in already_processed: 2528 already_processed.add('id') 2529 self.id = value 2530 value = find_attr_value_('timestamp', node) 2531 if value is not None and 'timestamp' not in already_processed: 2532 already_processed.add('timestamp') 2533 try: 2534 self.timestamp = self.gds_parse_datetime(value, node, 'timestamp') 2535 except ValueError as exp: 2536 raise ValueError('Bad date-time attribute (timestamp): %s' % exp) 2537 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 2538 pass 2539# end class CourseOfActionBaseType 2540 2541class RelatedCampaignReferenceType(GenericRelationshipType): 2542 """Identifies or characterizes a relationship by reference to a 2543 campaign.""" 2544 subclass = None 2545 superclass = GenericRelationshipType 2546 def __init__(self, Confidence=None, Information_Source=None, Relationship=None, Campaign=None): 2547 super(RelatedCampaignReferenceType, self).__init__(Confidence=Confidence, Information_Source=Information_Source, Relationship=Relationship) 2548 self.Campaign = Campaign 2549 def factory(*args_, **kwargs_): 2550 if RelatedCampaignReferenceType.subclass: 2551 return RelatedCampaignReferenceType.subclass(*args_, **kwargs_) 2552 else: 2553 return RelatedCampaignReferenceType(*args_, **kwargs_) 2554 factory = staticmethod(factory) 2555 def get_Campaign(self): return self.Campaign 2556 def set_Campaign(self, Campaign): self.Campaign = Campaign 2557 def hasContent_(self): 2558 if ( 2559 self.Campaign is not None or 2560 super(RelatedCampaignReferenceType, self).hasContent_() 2561 ): 2562 return True 2563 else: 2564 return False 2565 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedCampaignReferenceType', namespacedef_='', pretty_print=True): 2566 if pretty_print: 2567 eol_ = '\n' 2568 else: 2569 eol_ = '' 2570 showIndent(lwrite, level, pretty_print) 2571 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 2572 already_processed = set() 2573 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='RelatedCampaignReferenceType') 2574 if self.hasContent_(): 2575 lwrite('>%s' % (eol_, )) 2576 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 2577 showIndent(lwrite, level, pretty_print) 2578 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 2579 else: 2580 lwrite('/>%s' % (eol_, )) 2581 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='RelatedCampaignReferenceType'): 2582 super(RelatedCampaignReferenceType, self).exportAttributes(lwrite, level, already_processed, namespace_, name_='RelatedCampaignReferenceType') 2583 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedCampaignReferenceType', fromsubclass_=False, pretty_print=True): 2584 super(RelatedCampaignReferenceType, self).exportChildren(lwrite, level, nsmap, namespace_, name_, True, pretty_print=pretty_print) 2585 if pretty_print: 2586 eol_ = '\n' 2587 else: 2588 eol_ = '' 2589 if self.Campaign is not None: 2590 self.Campaign.export(lwrite, level, nsmap, namespace_, name_='Campaign', pretty_print=pretty_print) 2591 def build(self, node): 2592 self.__sourcenode__ = node 2593 already_processed = set() 2594 self.buildAttributes(node, node.attrib, already_processed) 2595 for child in node: 2596 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 2597 self.buildChildren(child, node, nodeName_) 2598 def buildAttributes(self, node, attrs, already_processed): 2599 super(RelatedCampaignReferenceType, self).buildAttributes(node, attrs, already_processed) 2600 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 2601 if nodeName_ == 'Campaign': 2602 obj_ = CampaignReferenceType.factory() 2603 obj_.build(child_) 2604 self.set_Campaign(obj_) 2605 super(RelatedCampaignReferenceType, self).buildChildren(child_, node, nodeName_, True) 2606# end class RelatedCampaignReferenceType 2607 2608class CampaignReferenceType(GeneratedsSuper): 2609 """Characterizes a reference to a campaign.Specifies a globally unique 2610 identifier for a cyber threat campaign defined elsewhere.In 2611 conjunction with the idref, this field may be used to reference 2612 a specific version of a campaign defined elsewhere. The 2613 referenced version timestamp is contained in the 2614 Information_Source/Time/Produced_Time field of the related 2615 campaign and must be an exact match.This field must only be used 2616 in conjunction with the idref field.""" 2617 subclass = None 2618 superclass = None 2619 def __init__(self, idref=None, timestamp=None, Names=None): 2620 self.idref = _cast(None, idref) 2621 self.timestamp = _cast(None, timestamp) 2622 self.Names = Names 2623 def factory(*args_, **kwargs_): 2624 if CampaignReferenceType.subclass: 2625 return CampaignReferenceType.subclass(*args_, **kwargs_) 2626 else: 2627 return CampaignReferenceType(*args_, **kwargs_) 2628 factory = staticmethod(factory) 2629 def get_Names(self): return self.Names 2630 def set_Names(self, Names): self.Names = Names 2631 def get_idref(self): return self.idref 2632 def set_idref(self, idref): self.idref = idref 2633 def get_timestamp(self): return self.timestamp 2634 def set_timestamp(self, timestamp): self.timestamp = timestamp 2635 def hasContent_(self): 2636 if ( 2637 self.Names is not None 2638 ): 2639 return True 2640 else: 2641 return False 2642 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='CampaignReferenceType', namespacedef_='', pretty_print=True): 2643 if pretty_print: 2644 eol_ = '\n' 2645 else: 2646 eol_ = '' 2647 showIndent(lwrite, level, pretty_print) 2648 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 2649 already_processed = set() 2650 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='CampaignReferenceType') 2651 if self.hasContent_(): 2652 lwrite('>%s' % (eol_, )) 2653 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 2654 showIndent(lwrite, level, pretty_print) 2655 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 2656 else: 2657 lwrite('/>%s' % (eol_, )) 2658 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='CampaignReferenceType'): 2659 if self.idref is not None and 'idref' not in already_processed: 2660 already_processed.add('idref') 2661 lwrite(' idref=%s' % (quote_attrib(self.idref), )) 2662 if self.timestamp is not None and 'timestamp' not in already_processed: 2663 already_processed.add('timestamp') 2664 lwrite(' timestamp="%s"' % self.gds_format_datetime(self.timestamp, input_name='timestamp')) 2665 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='CampaignReferenceType', fromsubclass_=False, pretty_print=True): 2666 if pretty_print: 2667 eol_ = '\n' 2668 else: 2669 eol_ = '' 2670 if self.Names is not None: 2671 self.Names.export(lwrite, level, nsmap, namespace_, name_='Names', pretty_print=pretty_print) 2672 def build(self, node): 2673 self.__sourcenode__ = node 2674 already_processed = set() 2675 self.buildAttributes(node, node.attrib, already_processed) 2676 for child in node: 2677 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 2678 self.buildChildren(child, node, nodeName_) 2679 def buildAttributes(self, node, attrs, already_processed): 2680 value = find_attr_value_('idref', node) 2681 if value is not None and 'idref' not in already_processed: 2682 already_processed.add('idref') 2683 self.idref = value 2684 value = find_attr_value_('timestamp', node) 2685 if value is not None and 'timestamp' not in already_processed: 2686 already_processed.add('timestamp') 2687 try: 2688 self.timestamp = self.gds_parse_datetime(value, node, 'timestamp') 2689 except ValueError as exp: 2690 raise ValueError('Bad date-time attribute (timestamp): %s' % exp) 2691 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 2692 if nodeName_ == 'Names': 2693 obj_ = NamesType.factory() 2694 obj_.build(child_) 2695 self.set_Names(obj_) 2696# end class CampaignReferenceType 2697 2698class NamesType(GeneratedsSuper): 2699 subclass = None 2700 superclass = None 2701 def __init__(self, Name=None): 2702 if Name is None: 2703 self.Name = [] 2704 else: 2705 self.Name = Name 2706 def factory(*args_, **kwargs_): 2707 if NamesType.subclass: 2708 return NamesType.subclass(*args_, **kwargs_) 2709 else: 2710 return NamesType(*args_, **kwargs_) 2711 factory = staticmethod(factory) 2712 def get_Name(self): return self.Name 2713 def set_Name(self, Name): self.Name = Name 2714 def add_Name(self, value): self.Name.append(value) 2715 def insert_Name(self, index, value): self.Name[index] = value 2716 def hasContent_(self): 2717 if ( 2718 self.Name 2719 ): 2720 return True 2721 else: 2722 return False 2723 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='NamesType', namespacedef_='', pretty_print=True): 2724 if pretty_print: 2725 eol_ = '\n' 2726 else: 2727 eol_ = '' 2728 showIndent(lwrite, level, pretty_print) 2729 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 2730 already_processed = set() 2731 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='NamesType') 2732 if self.hasContent_(): 2733 lwrite('>%s' % (eol_, )) 2734 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 2735 showIndent(lwrite, level, pretty_print) 2736 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 2737 else: 2738 lwrite('/>%s' % (eol_, )) 2739 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='NamesType'): 2740 pass 2741 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='NamesType', fromsubclass_=False, pretty_print=True): 2742 if pretty_print: 2743 eol_ = '\n' 2744 else: 2745 eol_ = '' 2746 for Name_ in self.Name: 2747 Name_.export(lwrite, level, nsmap, namespace_, name_='Name', pretty_print=pretty_print) 2748 def build(self, node): 2749 self.__sourcenode__ = node 2750 already_processed = set() 2751 self.buildAttributes(node, node.attrib, already_processed) 2752 for child in node: 2753 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 2754 self.buildChildren(child, node, nodeName_) 2755 def buildAttributes(self, node, attrs, already_processed): 2756 pass 2757 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 2758 if nodeName_ == 'Name': 2759 obj_ = ControlledVocabularyStringType.factory() 2760 obj_.build(child_) 2761 self.Name.append(obj_) 2762# end class NamesType 2763 2764class CampaignBaseType(GeneratedsSuper): 2765 """This type represents the STIX Campaign component. It is extended 2766 using the XML Schema Extension feature by the STIX Campaign type 2767 itself. Users of this type who wish to express a full campaign 2768 using STIX must do so using the xsi:type extension feature. The 2769 STIX-defined Campaign type is CampaignType in the 2770 http://stix.mitre.org/Campaign-1 namespace. This type is defined 2771 in the campaign.xsd file or at the URL http://stix.mitre.org/XML 2772 Schema/campaign/1.1/campaign.xsd.Alternatively, uses that 2773 require simply specifying an idref as a reference to a campaign 2774 defined elsewhere can do so without specifying an 2775 xsi:type.Specifies a globally unique identifier for this cyber 2776 threat Campaign.Specifies a globally unique identifier for a 2777 cyber threat Campaign specified elsewhere.When idref is 2778 specified, the id attribute must not be specified, and any 2779 instance of this Campaign should not hold content.In conjunction 2780 with the idref, this field may be used to reference a specific 2781 version of a campaign defined elsewhere. The referenced version 2782 timestamp is contained in the 2783 Information_Source/Time/Produced_Time field of the related 2784 campaign and must be an exact match.This field must only be used 2785 in conjunction with the idref field.""" 2786 subclass = None 2787 superclass = None 2788 def __init__(self, idref=None, id=None, timestamp=None): 2789 self.idref = _cast(None, idref) 2790 self.id = _cast(None, id) 2791 self.timestamp = _cast(None, timestamp) 2792 pass 2793 def factory(*args_, **kwargs_): 2794 if CampaignBaseType.subclass: 2795 return CampaignBaseType.subclass(*args_, **kwargs_) 2796 else: 2797 return CampaignBaseType(*args_, **kwargs_) 2798 factory = staticmethod(factory) 2799 def get_idref(self): return self.idref 2800 def set_idref(self, idref): self.idref = idref 2801 def get_id(self): return self.id 2802 def set_id(self, id): self.id = id 2803 def get_timestamp(self): return self.timestamp 2804 def set_timestamp(self, timestamp): self.timestamp = timestamp 2805 def hasContent_(self): 2806 if ( 2807 2808 ): 2809 return True 2810 else: 2811 return False 2812 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='CampaignBaseType', namespacedef_='', pretty_print=True): 2813 if pretty_print: 2814 eol_ = '\n' 2815 else: 2816 eol_ = '' 2817 showIndent(lwrite, level, pretty_print) 2818 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 2819 already_processed = set() 2820 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='CampaignBaseType') 2821 if self.hasContent_(): 2822 lwrite('>%s' % (eol_, )) 2823 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 2824 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 2825 else: 2826 lwrite('/>%s' % (eol_, )) 2827 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='CampaignBaseType'): 2828 if self.idref is not None and 'idref' not in already_processed: 2829 already_processed.add('idref') 2830 lwrite(' idref=%s' % (quote_attrib(self.idref), )) 2831 if self.id is not None and 'id' not in already_processed: 2832 already_processed.add('id') 2833 lwrite(' id=%s' % (quote_attrib(self.id), )) 2834 if self.timestamp is not None and 'timestamp' not in already_processed: 2835 already_processed.add('timestamp') 2836 lwrite(' timestamp="%s"' % self.gds_format_datetime(self.timestamp, input_name='timestamp')) 2837 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='CampaignBaseType', fromsubclass_=False, pretty_print=True): 2838 pass 2839 def build(self, node): 2840 self.__sourcenode__ = node 2841 already_processed = set() 2842 self.buildAttributes(node, node.attrib, already_processed) 2843 for child in node: 2844 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 2845 self.buildChildren(child, node, nodeName_) 2846 def buildAttributes(self, node, attrs, already_processed): 2847 value = find_attr_value_('idref', node) 2848 if value is not None and 'idref' not in already_processed: 2849 already_processed.add('idref') 2850 self.idref = value 2851 value = find_attr_value_('id', node) 2852 if value is not None and 'id' not in already_processed: 2853 already_processed.add('id') 2854 self.id = value 2855 value = find_attr_value_('timestamp', node) 2856 if value is not None and 'timestamp' not in already_processed: 2857 already_processed.add('timestamp') 2858 try: 2859 self.timestamp = self.gds_parse_datetime(value, node, 'timestamp') 2860 except ValueError as exp: 2861 raise ValueError('Bad date-time attribute (timestamp): %s' % exp) 2862 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 2863 pass 2864# end class CampaignBaseType 2865 2866 2867class ThreatActorBaseType(GeneratedsSuper): 2868 """This type represents the STIX Threat Actor component. It is extended 2869 using the XML Schema Extension feature by the STIX Threat Actor 2870 type itself. Users of this type who wish to express a full 2871 threat actor using STIX must do so using the xsi:type extension 2872 feature. The STIX-defined Threat Actor type is ThreatActorType 2873 in the http://stix.mitre.org/ThreatActor-1 namespace. This type 2874 is defined in the threat_actor.xsd file or at the URL http://sti 2875 x.mitre.org/XMLSchema/threat_actor/1.1/threat_actor.xsd.Alternat 2876 ively, uses that require simply specifying an idref as a 2877 reference to a threat actor defined elsewhere can do so without 2878 specifying an xsi:type.Specifies a globally unique identifier 2879 for this ThreatActor. Specifies a globally unique identifier of 2880 a ThreatActor specified elsewhere.When idref is specified, the 2881 id attribute must not be specified, and any instance of this 2882 ThreatActor should not hold content.In conjunction with the 2883 idref, this field may be used to reference a specific version of 2884 a threat actor defined elsewhere. The referenced version 2885 timestamp is contained in the 2886 Information_Source/Time/Produced_Time field of the related 2887 threat actor and must be an exact match.This field must only be 2888 used in conjunction with the idref field.""" 2889 subclass = None 2890 superclass = None 2891 def __init__(self, idref=None, id=None, timestamp=None): 2892 self.idref = _cast(None, idref) 2893 self.id = _cast(None, id) 2894 self.timestamp = _cast(None, timestamp) 2895 pass 2896 def factory(*args_, **kwargs_): 2897 if ThreatActorBaseType.subclass: 2898 return ThreatActorBaseType.subclass(*args_, **kwargs_) 2899 else: 2900 return ThreatActorBaseType(*args_, **kwargs_) 2901 factory = staticmethod(factory) 2902 def get_idref(self): return self.idref 2903 def set_idref(self, idref): self.idref = idref 2904 def get_id(self): return self.id 2905 def set_id(self, id): self.id = id 2906 def get_timestamp(self): return self.timestamp 2907 def set_timestamp(self, timestamp): self.timestamp = timestamp 2908 def hasContent_(self): 2909 if ( 2910 2911 ): 2912 return True 2913 else: 2914 return False 2915 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='ThreatActorBaseType', namespacedef_='', pretty_print=True): 2916 if pretty_print: 2917 eol_ = '\n' 2918 else: 2919 eol_ = '' 2920 showIndent(lwrite, level, pretty_print) 2921 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 2922 already_processed = set() 2923 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='ThreatActorBaseType') 2924 if self.hasContent_(): 2925 lwrite('>%s' % (eol_, )) 2926 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 2927 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 2928 else: 2929 lwrite('/>%s' % (eol_, )) 2930 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='ThreatActorBaseType'): 2931 if self.idref is not None and 'idref' not in already_processed: 2932 already_processed.add('idref') 2933 lwrite(' idref=%s' % (quote_attrib(self.idref), )) 2934 if self.id is not None and 'id' not in already_processed: 2935 already_processed.add('id') 2936 lwrite(' id=%s' % (quote_attrib(self.id), )) 2937 if self.timestamp is not None and 'timestamp' not in already_processed: 2938 already_processed.add('timestamp') 2939 lwrite(' timestamp="%s"' % self.gds_format_datetime(self.timestamp, input_name='timestamp')) 2940 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='ThreatActorBaseType', fromsubclass_=False, pretty_print=True): 2941 pass 2942 def build(self, node): 2943 self.__sourcenode__ = node 2944 already_processed = set() 2945 self.buildAttributes(node, node.attrib, already_processed) 2946 for child in node: 2947 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 2948 self.buildChildren(child, node, nodeName_) 2949 def buildAttributes(self, node, attrs, already_processed): 2950 value = find_attr_value_('idref', node) 2951 if value is not None and 'idref' not in already_processed: 2952 already_processed.add('idref') 2953 self.idref = value 2954 value = find_attr_value_('id', node) 2955 if value is not None and 'id' not in already_processed: 2956 already_processed.add('id') 2957 self.id = value 2958 value = find_attr_value_('timestamp', node) 2959 if value is not None and 'timestamp' not in already_processed: 2960 already_processed.add('timestamp') 2961 try: 2962 self.timestamp = self.gds_parse_datetime(value, node, 'timestamp') 2963 except ValueError as exp: 2964 raise ValueError('Bad date-time attribute (timestamp): %s' % exp) 2965 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 2966 pass 2967# end class ThreatActorBaseType 2968 2969 2970class ExploitTargetsType(GeneratedsSuper): 2971 subclass = None 2972 superclass = None 2973 def __init__(self, Exploit_Target=None): 2974 if Exploit_Target is None: 2975 self.Exploit_Target = [] 2976 else: 2977 self.Exploit_Target = Exploit_Target 2978 def factory(*args_, **kwargs_): 2979 if ExploitTargetsType.subclass: 2980 return ExploitTargetsType.subclass(*args_, **kwargs_) 2981 else: 2982 return ExploitTargetsType(*args_, **kwargs_) 2983 factory = staticmethod(factory) 2984 def get_Exploit_Target(self): return self.Exploit_Target 2985 def set_Exploit_Target(self, Exploit_Target): self.Exploit_Target = Exploit_Target 2986 def add_Exploit_Target(self, value): self.Exploit_Target.append(value) 2987 def insert_Exploit_Target(self, index, value): self.Exploit_Target[index] = value 2988 def hasContent_(self): 2989 if ( 2990 self.Exploit_Target 2991 ): 2992 return True 2993 else: 2994 return False 2995 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='ExploitTargetsType', namespacedef_='', pretty_print=True): 2996 if pretty_print: 2997 eol_ = '\n' 2998 else: 2999 eol_ = '' 3000 showIndent(lwrite, level, pretty_print) 3001 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 3002 already_processed = set() 3003 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='ExploitTargetsType') 3004 if self.hasContent_(): 3005 lwrite('>%s' % (eol_, )) 3006 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 3007 showIndent(lwrite, level, pretty_print) 3008 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 3009 else: 3010 lwrite('/>%s' % (eol_, )) 3011 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='ExploitTargetsType'): 3012 pass 3013 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='ExploitTargetsType', fromsubclass_=False, pretty_print=True): 3014 if pretty_print: 3015 eol_ = '\n' 3016 else: 3017 eol_ = '' 3018 for Exploit_Target_ in self.Exploit_Target: 3019 Exploit_Target_.export(lwrite, level, nsmap, namespace_, name_='Exploit_Target', pretty_print=pretty_print) 3020 def build(self, node): 3021 self.__sourcenode__ = node 3022 already_processed = set() 3023 self.buildAttributes(node, node.attrib, already_processed) 3024 for child in node: 3025 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 3026 self.buildChildren(child, node, nodeName_) 3027 def buildAttributes(self, node, attrs, already_processed): 3028 pass 3029 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 3030 if nodeName_ == 'Exploit_Target': 3031 obj_ = lookup_extension(child_, ExploitTargetBaseType).factory() 3032 obj_.build(child_) 3033 self.Exploit_Target.append(obj_) 3034 3035# end class ExploitTargetsType 3036 3037 3038class AddressAbstractType(GeneratedsSuper): 3039 """The AddressAbstractType is used to express geographic address 3040 information. This type is intended to be extended through the 3041 xsi:type mechanism. The default type is 3042 CIQAddress3.0InstanceType in the 3043 http://stix.mitre.org/extensions/Address#CIQAddress3.0-1 3044 namespace. This type is defined in the 3045 extensions/identity/ciq_address_3.0.xsd file or at the URL http: 3046 //stix.mitre.org/XMLSchema/extensions/address/ciq_address_3.0/1. 3047 0/ciq_address_3.0.xsd.""" 3048 subclass = None 3049 superclass = None 3050 def __init__(self): 3051 pass 3052 def factory(*args_, **kwargs_): 3053 if AddressAbstractType.subclass: 3054 return AddressAbstractType.subclass(*args_, **kwargs_) 3055 else: 3056 return AddressAbstractType(*args_, **kwargs_) 3057 factory = staticmethod(factory) 3058 def hasContent_(self): 3059 if ( 3060 3061 ): 3062 return True 3063 else: 3064 return False 3065 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='AddressAbstractType', namespacedef_='', pretty_print=True): 3066 if pretty_print: 3067 eol_ = '\n' 3068 else: 3069 eol_ = '' 3070 showIndent(lwrite, level, pretty_print) 3071 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 3072 already_processed = set() 3073 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='AddressAbstractType') 3074 if self.hasContent_(): 3075 lwrite('>%s' % (eol_, )) 3076 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 3077 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 3078 else: 3079 lwrite('/>%s' % (eol_, )) 3080 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='AddressAbstractType'): 3081 pass 3082 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='AddressAbstractType', fromsubclass_=False, pretty_print=True): 3083 pass 3084 def build(self, node): 3085 self.__sourcenode__ = node 3086 already_processed = set() 3087 self.buildAttributes(node, node.attrib, already_processed) 3088 for child in node: 3089 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 3090 self.buildChildren(child, node, nodeName_) 3091 def buildAttributes(self, node, attrs, already_processed): 3092 pass 3093 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 3094 pass 3095# end class AddressAbstractType 3096 3097class ContributingSourcesType(GeneratedsSuper): 3098 subclass = None 3099 superclass = None 3100 def __init__(self, Source=None): 3101 if Source is None: 3102 self.Source = [] 3103 else: 3104 self.Source = Source 3105 def factory(*args_, **kwargs_): 3106 if ContributingSourcesType.subclass: 3107 return ContributingSourcesType.subclass(*args_, **kwargs_) 3108 else: 3109 return ContributingSourcesType(*args_, **kwargs_) 3110 factory = staticmethod(factory) 3111 def get_Source(self): return self.Source 3112 def set_Source(self, Source): self.Source = Source 3113 def add_Source(self, value): self.Source.append(value) 3114 def insert_Source(self, index, value): self.Source[index] = value 3115 def hasContent_(self): 3116 if ( 3117 self.Source 3118 ): 3119 return True 3120 else: 3121 return False 3122 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='ContributingSourcesType', namespacedef_='', pretty_print=True): 3123 if pretty_print: 3124 eol_ = '\n' 3125 else: 3126 eol_ = '' 3127 showIndent(lwrite, level, pretty_print) 3128 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 3129 already_processed = set() 3130 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='ContributingSourcesType') 3131 if self.hasContent_(): 3132 lwrite('>%s' % (eol_, )) 3133 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 3134 showIndent(lwrite, level, pretty_print) 3135 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 3136 else: 3137 lwrite('/>%s' % (eol_, )) 3138 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='ContributingSourcesType'): 3139 pass 3140 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='ContributingSourcesType', fromsubclass_=False, pretty_print=True): 3141 if pretty_print: 3142 eol_ = '\n' 3143 else: 3144 eol_ = '' 3145 for Source_ in self.Source: 3146 Source_.export(lwrite, level, nsmap, namespace_, name_='Source', pretty_print=pretty_print) 3147 def build(self, node): 3148 self.__sourcenode__ = node 3149 already_processed = set() 3150 self.buildAttributes(node, node.attrib, already_processed) 3151 for child in node: 3152 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 3153 self.buildChildren(child, node, nodeName_) 3154 def buildAttributes(self, node, attrs, already_processed): 3155 pass 3156 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 3157 if nodeName_ == 'Source': 3158 obj_ = InformationSourceType.factory() 3159 obj_.build(child_) 3160 self.Source.append(obj_) 3161# end class ContributingSourcesType 3162 3163class ReferencesType(GeneratedsSuper): 3164 subclass = None 3165 superclass = None 3166 def __init__(self, Reference=None): 3167 if Reference is None: 3168 self.Reference = [] 3169 else: 3170 self.Reference = Reference 3171 def factory(*args_, **kwargs_): 3172 if ReferencesType.subclass: 3173 return ReferencesType.subclass(*args_, **kwargs_) 3174 else: 3175 return ReferencesType(*args_, **kwargs_) 3176 factory = staticmethod(factory) 3177 def get_Reference(self): return self.Reference 3178 def set_Reference(self, Reference): self.Reference = Reference 3179 def add_Reference(self, value): self.Reference.append(value) 3180 def insert_Reference(self, index, value): self.Reference[index] = value 3181 def hasContent_(self): 3182 if ( 3183 self.Reference 3184 ): 3185 return True 3186 else: 3187 return False 3188 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='ReferencesType', namespacedef_='', pretty_print=True): 3189 if pretty_print: 3190 eol_ = '\n' 3191 else: 3192 eol_ = '' 3193 showIndent(lwrite, level, pretty_print) 3194 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 3195 already_processed = set() 3196 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='ReferencesType') 3197 if self.hasContent_(): 3198 lwrite('>%s' % (eol_, )) 3199 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 3200 showIndent(lwrite, level, pretty_print) 3201 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 3202 else: 3203 lwrite('/>%s' % (eol_, )) 3204 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='ReferencesType'): 3205 pass 3206 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='ReferencesType', fromsubclass_=False, pretty_print=True): 3207 if pretty_print: 3208 eol_ = '\n' 3209 else: 3210 eol_ = '' 3211 for Reference_ in self.Reference: 3212 showIndent(lwrite, level, pretty_print) 3213 lwrite('<%s:Reference>%s</%s:Reference>%s' % (nsmap[namespace_], quote_xml(Reference_), nsmap[namespace_], eol_)) 3214 def build(self, node): 3215 self.__sourcenode__ = node 3216 already_processed = set() 3217 self.buildAttributes(node, node.attrib, already_processed) 3218 for child in node: 3219 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 3220 self.buildChildren(child, node, nodeName_) 3221 def buildAttributes(self, node, attrs, already_processed): 3222 pass 3223 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 3224 if nodeName_ == 'Reference': 3225 Reference_ = child_.text 3226 Reference_ = self.gds_validate_string(Reference_, node, 'Reference') 3227 self.Reference.append(Reference_) 3228# end class ReferencesType 3229 3230class RelatedIdentitiesType(GeneratedsSuper): 3231 subclass = None 3232 superclass = None 3233 def __init__(self, Related_Identity=None): 3234 if Related_Identity is None: 3235 self.Related_Identity = [] 3236 else: 3237 self.Related_Identity = Related_Identity 3238 def factory(*args_, **kwargs_): 3239 if RelatedIdentitiesType.subclass: 3240 return RelatedIdentitiesType.subclass(*args_, **kwargs_) 3241 else: 3242 return RelatedIdentitiesType(*args_, **kwargs_) 3243 factory = staticmethod(factory) 3244 def get_Related_Identity(self): return self.Related_Identity 3245 def set_Related_Identity(self, Related_Identity): self.Related_Identity = Related_Identity 3246 def add_Related_Identity(self, value): self.Related_Identity.append(value) 3247 def insert_Related_Identity(self, index, value): self.Related_Identity[index] = value 3248 def hasContent_(self): 3249 if ( 3250 self.Related_Identity 3251 ): 3252 return True 3253 else: 3254 return False 3255 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedIdentitiesType', namespacedef_='', pretty_print=True): 3256 if pretty_print: 3257 eol_ = '\n' 3258 else: 3259 eol_ = '' 3260 showIndent(lwrite, level, pretty_print) 3261 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 3262 already_processed = set() 3263 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='RelatedIdentitiesType') 3264 if self.hasContent_(): 3265 lwrite('>%s' % (eol_, )) 3266 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 3267 showIndent(lwrite, level, pretty_print) 3268 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 3269 else: 3270 lwrite('/>%s' % (eol_, )) 3271 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='RelatedIdentitiesType'): 3272 pass 3273 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedIdentitiesType', fromsubclass_=False, pretty_print=True): 3274 if pretty_print: 3275 eol_ = '\n' 3276 else: 3277 eol_ = '' 3278 for Related_Identity_ in self.Related_Identity: 3279 Related_Identity_.export(lwrite, level, nsmap, namespace_, name_='Related_Identity', pretty_print=pretty_print) 3280 def build(self, node): 3281 self.__sourcenode__ = node 3282 already_processed = set() 3283 self.buildAttributes(node, node.attrib, already_processed) 3284 for child in node: 3285 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 3286 self.buildChildren(child, node, nodeName_) 3287 def buildAttributes(self, node, attrs, already_processed): 3288 pass 3289 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 3290 if nodeName_ == 'Related_Identity': 3291 obj_ = RelatedIdentityType.factory() 3292 obj_.build(child_) 3293 self.Related_Identity.append(obj_) 3294# end class RelatedIdentitiesType 3295 3296class ConfidenceAssertionChainType(GeneratedsSuper): 3297 subclass = None 3298 superclass = None 3299 def __init__(self, Confidence_Assertion=None): 3300 if Confidence_Assertion is None: 3301 self.Confidence_Assertion = [] 3302 else: 3303 self.Confidence_Assertion = Confidence_Assertion 3304 def factory(*args_, **kwargs_): 3305 if ConfidenceAssertionChainType.subclass: 3306 return ConfidenceAssertionChainType.subclass(*args_, **kwargs_) 3307 else: 3308 return ConfidenceAssertionChainType(*args_, **kwargs_) 3309 factory = staticmethod(factory) 3310 def get_Confidence_Assertion(self): return self.Confidence_Assertion 3311 def set_Confidence_Assertion(self, Confidence_Assertion): self.Confidence_Assertion = Confidence_Assertion 3312 def add_Confidence_Assertion(self, value): self.Confidence_Assertion.append(value) 3313 def insert_Confidence_Assertion(self, index, value): self.Confidence_Assertion[index] = value 3314 def hasContent_(self): 3315 if ( 3316 self.Confidence_Assertion 3317 ): 3318 return True 3319 else: 3320 return False 3321 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='ConfidenceAssertionChainType', namespacedef_='', pretty_print=True): 3322 if pretty_print: 3323 eol_ = '\n' 3324 else: 3325 eol_ = '' 3326 showIndent(lwrite, level, pretty_print) 3327 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 3328 already_processed = set() 3329 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='ConfidenceAssertionChainType') 3330 if self.hasContent_(): 3331 lwrite('>%s' % (eol_, )) 3332 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 3333 showIndent(lwrite, level, pretty_print) 3334 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 3335 else: 3336 lwrite('/>%s' % (eol_, )) 3337 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='ConfidenceAssertionChainType'): 3338 pass 3339 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='ConfidenceAssertionChainType', fromsubclass_=False, pretty_print=True): 3340 if pretty_print: 3341 eol_ = '\n' 3342 else: 3343 eol_ = '' 3344 for Confidence_Assertion_ in self.Confidence_Assertion: 3345 Confidence_Assertion_.export(lwrite, level, nsmap, namespace_, name_='Confidence_Assertion', pretty_print=pretty_print) 3346 def build(self, node): 3347 self.__sourcenode__ = node 3348 already_processed = set() 3349 self.buildAttributes(node, node.attrib, already_processed) 3350 for child in node: 3351 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 3352 self.buildChildren(child, node, nodeName_) 3353 def buildAttributes(self, node, attrs, already_processed): 3354 pass 3355 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 3356 if nodeName_ == 'Confidence_Assertion': 3357 obj_ = ConfidenceType.factory() 3358 obj_.build(child_) 3359 self.Confidence_Assertion.append(obj_) 3360# end class ConfidenceAssertionChainType 3361 3362class StatementType(GeneratedsSuper): 3363 """StatementType allows the expression of a statement with an 3364 associated value, description, source, confidence, and 3365 timestamp. Specifies the time this statement was asserted.In 3366 order to avoid ambiguity, it is strongly suggest that all 3367 timestamps include a specification of the timezone if it is 3368 known.Represents the precision of the associated timestamp 3369 value. If omitted, the default is "second", meaning the 3370 timestamp is precise to the full field value. Digits in the 3371 timestamp that are required by the xs:dateTime datatype but are 3372 beyond the specified precision should be zeroed out.""" 3373 subclass = None 3374 superclass = None 3375 def __init__(self, timestamp=None, timestamp_precision='second', Value=None, Description=None, Source=None, Confidence=None): 3376 self.timestamp = _cast(None, timestamp) 3377 self.timestamp_precision = _cast(None, timestamp_precision) 3378 self.Value = Value 3379 if Description is None: 3380 self.Description = [] 3381 else: 3382 self.Description = Description 3383 self.Source = Source 3384 self.Confidence = Confidence 3385 def factory(*args_, **kwargs_): 3386 if StatementType.subclass: 3387 return StatementType.subclass(*args_, **kwargs_) 3388 else: 3389 return StatementType(*args_, **kwargs_) 3390 factory = staticmethod(factory) 3391 def get_Value(self): return self.Value 3392 def set_Value(self, Value): self.Value = Value 3393 def add_Description(self, Description): self.Description.append(Description) 3394 def insert_Description(self, index, Description): self.Description[index] = Description 3395 def get_Description(self): return self.Description 3396 def set_Description(self, Description): self.Description = Description 3397 def get_Source(self): return self.Source 3398 def set_Source(self, Source): self.Source = Source 3399 def get_Confidence(self): return self.Confidence 3400 def set_Confidence(self, Confidence): self.Confidence = Confidence 3401 def get_timestamp(self): return self.timestamp 3402 def set_timestamp(self, timestamp): self.timestamp = timestamp 3403 def get_timestamp_precision(self): return self.timestamp_precision 3404 def set_timestamp_precision(self, timestamp_precision): self.timestamp_precision = timestamp_precision 3405 def hasContent_(self): 3406 if ( 3407 self.Value is not None or 3408 self.Description or 3409 self.Source is not None or 3410 self.Confidence is not None 3411 ): 3412 return True 3413 else: 3414 return False 3415 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='StatementType', namespacedef_='', pretty_print=True): 3416 if pretty_print: 3417 eol_ = '\n' 3418 else: 3419 eol_ = '' 3420 showIndent(lwrite, level, pretty_print) 3421 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 3422 already_processed = set() 3423 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='StatementType') 3424 if self.hasContent_(): 3425 lwrite('>%s' % (eol_, )) 3426 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 3427 showIndent(lwrite, level, pretty_print) 3428 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 3429 else: 3430 lwrite('/>%s' % (eol_, )) 3431 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='StatementType'): 3432 if self.timestamp is not None and 'timestamp' not in already_processed: 3433 already_processed.add('timestamp') 3434 lwrite(' timestamp="%s"' % self.gds_format_datetime(self.timestamp, input_name='timestamp')) 3435 if self.timestamp_precision not in (None, 'second') and 'timestamp_precision' not in already_processed: 3436 already_processed.add('timestamp_precision') 3437 lwrite(' timestamp_precision=%s' % (quote_attrib(self.timestamp_precision), )) 3438 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='StatementType', fromsubclass_=False, pretty_print=True): 3439 if pretty_print: 3440 eol_ = '\n' 3441 else: 3442 eol_ = '' 3443 if self.Value is not None: 3444 self.Value.export(lwrite, level, nsmap, namespace_, name_='Value', pretty_print=pretty_print) 3445 for Description in self.Description: 3446 Description.export(lwrite, level, nsmap, namespace_, name_='Description', pretty_print=pretty_print) 3447 if self.Source is not None: 3448 self.Source.export(lwrite, level, nsmap, namespace_, name_='Source', pretty_print=pretty_print) 3449 if self.Confidence is not None: 3450 self.Confidence.export(lwrite, level, nsmap, namespace_, name_='Confidence', pretty_print=pretty_print) 3451 def build(self, node): 3452 self.__sourcenode__ = node 3453 already_processed = set() 3454 self.buildAttributes(node, node.attrib, already_processed) 3455 for child in node: 3456 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 3457 self.buildChildren(child, node, nodeName_) 3458 def buildAttributes(self, node, attrs, already_processed): 3459 value = find_attr_value_('timestamp', node) 3460 if value is not None and 'timestamp' not in already_processed: 3461 already_processed.add('timestamp') 3462 try: 3463 self.timestamp = self.gds_parse_datetime(value, node, 'timestamp') 3464 except ValueError as exp: 3465 raise ValueError('Bad date-time attribute (timestamp): %s' % exp) 3466 value = find_attr_value_('timestamp_precision', node) 3467 if value is not None and 'timestamp_precision' not in already_processed: 3468 already_processed.add('timestamp_precision') 3469 self.timestamp_precision = value 3470 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 3471 if nodeName_ == 'Value': 3472 obj_ = ControlledVocabularyStringType.factory() 3473 obj_.build(child_) 3474 self.set_Value(obj_) 3475 elif nodeName_ == 'Description': 3476 obj_ = StructuredTextType.factory() 3477 obj_.build(child_) 3478 self.add_Description(obj_) 3479 elif nodeName_ == 'Source': 3480 obj_ = InformationSourceType.factory() 3481 obj_.build(child_) 3482 self.set_Source(obj_) 3483 elif nodeName_ == 'Confidence': 3484 obj_ = ConfidenceType.factory() 3485 obj_.build(child_) 3486 self.set_Confidence(obj_) 3487# end class StatementType 3488 3489class StructuredTextType(GeneratedsSuper): 3490 """The StructuredTextType is a type representing a generalized 3491 structure for capturing structured or unstructured textual 3492 information such as descriptions of things. It mirrors a similar 3493 type in CybOX 2.0 used to indicate a particular structuring 3494 format (e.g., HTML5) used within an instance of StructuredTextType. 3495 Note that if the markup tags used by this format would be interpreted 3496 as XML information (such as the bracket-based tags of HTML) the text 3497 area should be enclosed in a CDATA section to prevent the markup from 3498 interferring with XMLvalidation of the CybOX document. If this 3499 attribute is absent, the implication is that no markup is being used.""" 3500 subclass = None 3501 superclass = None 3502 def __init__(self, structuring_format=None, valueOf_=None, id=None, 3503 idref=None, ordinality=None): 3504 self.structuring_format = _cast(None, structuring_format) 3505 self.valueOf_ = valueOf_ 3506 self.id = id 3507 self.idref = idref 3508 self.ordinality = ordinality 3509 3510 def factory(*args_, **kwargs_): 3511 if StructuredTextType.subclass: 3512 return StructuredTextType.subclass(*args_, **kwargs_) 3513 else: 3514 return StructuredTextType(*args_, **kwargs_) 3515 factory = staticmethod(factory) 3516 def get_structuring_format(self): return self.structuring_format 3517 def set_structuring_format(self, structuring_format): self.structuring_format = structuring_format 3518 def get_valueOf_(self): return self.valueOf_ 3519 def set_valueOf_(self, valueOf_): self.valueOf_ = valueOf_ 3520 def get_id(self): return self.id 3521 def set_id(self, id): self.id = id 3522 def get_ordinality(self): return self.ordinality 3523 def set_ordinality(self, ordinality): self.ordinality = ordinality 3524 def hasContent_(self): 3525 if ( 3526 self.valueOf_ 3527 ): 3528 return True 3529 else: 3530 return False 3531 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='StructuredTextType', namespacedef_='', pretty_print=True): 3532 if pretty_print: 3533 eol_ = '\n' 3534 else: 3535 eol_ = '' 3536 showIndent(lwrite, level, pretty_print) 3537 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 3538 already_processed = set() 3539 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='StructuredTextType') 3540 if self.hasContent_(): 3541 lwrite('>') 3542 lwrite(quote_xml(self.valueOf_)) 3543 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 3544 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 3545 else: 3546 lwrite('/>%s' % (eol_, )) 3547 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='StructuredTextType'): 3548 if self.structuring_format is not None and 'structuring_format' not in already_processed: 3549 already_processed.add('structuring_format') 3550 lwrite(' structuring_format=%s' % quote_attrib(self.structuring_format)) 3551 if self.id is not None and 'id' not in already_processed: 3552 already_processed.add('id') 3553 lwrite(' id=%s' % quote_attrib(self.id)) 3554 if self.ordinality is not None and 'ordinality' not in already_processed: 3555 already_processed.add('ordinality') 3556 lwrite(' ordinality=%s' % quote_attrib(self.ordinality)) 3557 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='StructuredTextType', fromsubclass_=False, pretty_print=True): 3558 pass 3559 def build(self, node): 3560 self.__sourcenode__ = node 3561 already_processed = set() 3562 self.buildAttributes(node, node.attrib, already_processed) 3563 self.valueOf_ = get_all_text_(node) 3564 for child in node: 3565 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 3566 self.buildChildren(child, node, nodeName_) 3567 def buildAttributes(self, node, attrs, already_processed): 3568 value = find_attr_value_('structuring_format', node) 3569 if value is not None and 'structuring_format' not in already_processed: 3570 already_processed.add('structuring_format') 3571 self.structuring_format = value 3572 value = find_attr_value_('id', node) 3573 if value is not None and 'id' not in already_processed: 3574 already_processed.add('id') 3575 self.id = value 3576 value = find_attr_value_('ordinality', node) 3577 if value is not None and 'ordinality' not in already_processed: 3578 already_processed.add('ordinality') 3579 self.ordinality = value 3580 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 3581 pass 3582# end class StructuredTextType 3583 3584class EncodedCDATAType(GeneratedsSuper): 3585 """This type is used to represent data in an XML CDATA block. Data in a 3586 CDATA block may either be represented as-is or, in cases where 3587 it may contain characters that are not valid in CDATA, it may be 3588 encoded in Base64 per RFC4648. Data encoded in Base64 must be 3589 denoted as such using the encoded attribute. If true, specifies 3590 that the content encoded in the element is encoded using Base64 3591 per RFC4648.""" 3592 subclass = None 3593 superclass = None 3594 def __init__(self, encoded=False, valueOf_=None): 3595 self.encoded = _cast(bool, encoded) 3596 self.valueOf_ = valueOf_ 3597 def factory(*args_, **kwargs_): 3598 if EncodedCDATAType.subclass: 3599 return EncodedCDATAType.subclass(*args_, **kwargs_) 3600 else: 3601 return EncodedCDATAType(*args_, **kwargs_) 3602 factory = staticmethod(factory) 3603 def get_encoded(self): return self.encoded 3604 def set_encoded(self, encoded): self.encoded = encoded 3605 def get_valueOf_(self): return self.valueOf_ 3606 def set_valueOf_(self, valueOf_): self.valueOf_ = valueOf_ 3607 def hasContent_(self): 3608 if ( 3609 self.valueOf_ 3610 ): 3611 return True 3612 else: 3613 return False 3614 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='EncodedCDATAType', namespacedef_='', pretty_print=True): 3615 if pretty_print: 3616 eol_ = '\n' 3617 else: 3618 eol_ = '' 3619 showIndent(lwrite, level, pretty_print) 3620 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 3621 already_processed = set() 3622 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='EncodedCDATAType') 3623 if self.hasContent_(): 3624 lwrite('>') 3625 3626 if self.valueOf_ and not (self.valueOf_.strip().startswith("<![CDATA[")): 3627 value = CDATA_START + self.valueOf_ + CDATA_END 3628 else: 3629 value = self.valueOf_ 3630 3631 lwrite(quote_xml(value)) 3632 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 3633 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 3634 else: 3635 lwrite('/>%s' % (eol_, )) 3636 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='EncodedCDATAType'): 3637 if self.encoded is not None and 'encoded' not in already_processed: 3638 already_processed.add('encoded') 3639 lwrite(' encoded="%s"' % self.gds_format_boolean(self.encoded, input_name='encoded')) 3640 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='EncodedCDATAType', fromsubclass_=False, pretty_print=True): 3641 pass 3642 def build(self, node): 3643 self.__sourcenode__ = node 3644 already_processed = set() 3645 self.buildAttributes(node, node.attrib, already_processed) 3646 self.valueOf_ = get_all_text_(node) 3647 for child in node: 3648 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 3649 self.buildChildren(child, node, nodeName_) 3650 def buildAttributes(self, node, attrs, already_processed): 3651 value = find_attr_value_('encoded', node) 3652 if value is not None and 'encoded' not in already_processed: 3653 already_processed.add('encoded') 3654 if value in ('true', '1'): 3655 self.encoded = True 3656 elif value in ('false', '0'): 3657 self.encoded = False 3658 else: 3659 raise_parse_error(node, 'Bad boolean attribute') 3660 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 3661 pass 3662# end class EncodedCDATAType 3663 3664class ControlledVocabularyStringType(GeneratedsSuper): 3665 """The ControlledVocabularyStringType is used as the basis for defining 3666 controlled vocabularies.The vocab_name field specifies the name 3667 of the controlled vocabulary.The vocab_reference field specifies 3668 the URI to the location of where the controlled vocabulary is 3669 defined, e.g., in an externally located XML schema file.""" 3670 subclass = None 3671 superclass = None 3672 def __init__(self, vocab_reference=None, vocab_name=None, valueOf_=None, xsi_type=None): 3673 self.vocab_reference = _cast(None, vocab_reference) 3674 self.vocab_name = _cast(None, vocab_name) 3675 self.valueOf_ = valueOf_ 3676 self.xsi_type = xsi_type 3677 def factory(*args_, **kwargs_): 3678 if ControlledVocabularyStringType.subclass: 3679 return ControlledVocabularyStringType.subclass(*args_, **kwargs_) 3680 else: 3681 return ControlledVocabularyStringType(*args_, **kwargs_) 3682 factory = staticmethod(factory) 3683 def get_vocab_reference(self): return self.vocab_reference 3684 def set_vocab_reference(self, vocab_reference): self.vocab_reference = vocab_reference 3685 def get_vocab_name(self): return self.vocab_name 3686 def set_vocab_name(self, vocab_name): self.vocab_name = vocab_name 3687 def get_valueOf_(self): return self.valueOf_ 3688 def set_valueOf_(self, valueOf_): self.valueOf_ = valueOf_ 3689 def get_xsi_type(self): return self.xsi_type 3690 def set_xsi_type(self, xsi_type): self.xsi_type = xsi_type 3691 def hasContent_(self): 3692 if ( 3693 self.valueOf_ 3694 ): 3695 return True 3696 else: 3697 return False 3698 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='ControlledVocabularyStringType', namespacedef_='', pretty_print=True): 3699 if pretty_print: 3700 eol_ = '\n' 3701 else: 3702 eol_ = '' 3703 showIndent(lwrite, level, pretty_print) 3704 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 3705 already_processed = set() 3706 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='ControlledVocabularyStringType') 3707 if self.hasContent_(): 3708 lwrite('>') 3709 lwrite(quote_xml(self.valueOf_)) 3710 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 3711 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 3712 else: 3713 lwrite('/>%s' % (eol_, )) 3714 def exportAttributes(self, lwrite, level, already_processed, namespace_='stixCommon:', name_='ControlledVocabularyStringType'): 3715 if self.xsi_type is not None and 'xsi:type' not in already_processed: 3716 already_processed.add('xsi:type') 3717 lwrite(' xsi:type=%s' % quote_attrib(self.xsi_type)) 3718 if self.vocab_reference is not None and 'vocab_reference' not in already_processed: 3719 already_processed.add('vocab_reference') 3720 lwrite(' vocab_reference=%s' % (quote_attrib(self.vocab_reference), )) 3721 if self.vocab_name is not None and 'vocab_name' not in already_processed: 3722 already_processed.add('vocab_name') 3723 lwrite(' vocab_name=%s' % (quote_attrib(self.vocab_name), )) 3724 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='ControlledVocabularyStringType', fromsubclass_=False, pretty_print=True): 3725 pass 3726 def build(self, node): 3727 self.__sourcenode__ = node 3728 already_processed = set() 3729 self.buildAttributes(node, node.attrib, already_processed) 3730 self.valueOf_ = get_all_text_(node) 3731 for child in node: 3732 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 3733 self.buildChildren(child, node, nodeName_) 3734 def buildAttributes(self, node, attrs, already_processed): 3735 value = find_attr_value_('vocab_reference', node) 3736 if value is not None and 'vocab_reference' not in already_processed: 3737 already_processed.add('vocab_reference') 3738 self.vocab_reference = value 3739 value = find_attr_value_('vocab_name', node) 3740 if value is not None and 'vocab_name' not in already_processed: 3741 already_processed.add('vocab_name') 3742 self.vocab_name = value 3743 value = find_attr_value_('xsi:type', node) 3744 if value is not None and 'xsi:type' not in already_processed: 3745 already_processed.add('xsi:type') 3746 3747 from mixbox.namespaces import lookup_name 3748 typeinfo = get_type_info(node) 3749 3750 # Override the prefix if its mapped to a known STIX namespace. 3751 # This will help prevent class resolution failures in 3752 # stix.lookup_extension(). 3753 prefix = lookup_name(typeinfo.ns) 3754 if prefix: 3755 typename = typeinfo.typename 3756 xsi_type = "%s:%s" % (prefix, typename) 3757 else: 3758 xsi_type = value 3759 3760 self.xsi_type = xsi_type 3761 3762 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 3763 pass 3764# end class ControlledVocabularyStringType 3765 3766 3767class ReportBaseType(GeneratedsSuper): 3768 """This type represents the STIX Report component. It is extended using 3769 the XML Schema Extension feature by the STIX Report type itself. 3770 Users of this type who wish to express a full report using STIX 3771 must do so using the xsi:type extension feature. The STIX- 3772 defined Report type is ReportType in the 3773 http://stix.mitre.org/Report-1 namespace. This type is defined 3774 in the report.xsd file or at the URL http://stix.mitre.org/XMLSc 3775 hema/report/1.2/report.xsd.Alternatively, uses that require 3776 simply specifying an idref as a reference to a report defined 3777 elsewhere can do so without specifying an xsi:type.Specifies a 3778 globally unique identifier for this Report. Specifies a globally 3779 unique identifier of a Report specified elsewhere.When idref is 3780 specified, the id attribute must not be specified, and any 3781 instance of this Report should not hold content.Specifies a 3782 timestamp for the definition of a specific version of a Report. 3783 When used in conjunction with the id, this field is specifying 3784 the definition time for the specific version of the Report. When 3785 used in conjunction with the idref, this field is specifying a 3786 reference to a specific version of a Report defined elsewhere. 3787 This field has no defined semantic meaning if used in the 3788 absence of either the id or idref fields.""" 3789 subclass = None 3790 superclass = None 3791 def __init__(self, timestamp=None, idref=None, id=None, extensiontype_=None): 3792 self.timestamp = _cast(None, timestamp) 3793 self.idref = _cast(None, idref) 3794 self.id = _cast(None, id) 3795 self.extensiontype_ = extensiontype_ 3796 def factory(*args_, **kwargs_): 3797 if ReportBaseType.subclass: 3798 return ReportBaseType.subclass(*args_, **kwargs_) 3799 else: 3800 return ReportBaseType(*args_, **kwargs_) 3801 factory = staticmethod(factory) 3802 def get_timestamp(self): return self.timestamp 3803 def set_timestamp(self, timestamp): self.timestamp = timestamp 3804 def get_idref(self): return self.idref 3805 def set_idref(self, idref): self.idref = idref 3806 def get_id(self): return self.id 3807 def set_id(self, id): self.id = id 3808 def get_extensiontype_(self): return self.extensiontype_ 3809 def set_extensiontype_(self, extensiontype_): self.extensiontype_ = extensiontype_ 3810 def hasContent_(self): 3811 if ( 3812 3813 ): 3814 return True 3815 else: 3816 return False 3817 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='ReportBaseType', namespacedef_='', pretty_print=True): 3818 if pretty_print: 3819 eol_ = '\n' 3820 else: 3821 eol_ = '' 3822 showIndent(lwrite, level, pretty_print) 3823 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 3824 already_processed = set() 3825 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='ReportBaseType') 3826 if self.hasContent_(): 3827 lwrite('>%s' % (eol_, )) 3828 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 3829 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 3830 else: 3831 lwrite('/>%s' % (eol_, )) 3832 def exportAttributes(self, lwrite, level, already_processed, namespace_='report:', name_='ReportBaseType'): 3833 if self.timestamp is not None and 'timestamp' not in already_processed: 3834 already_processed.add('timestamp') 3835 lwrite(' timestamp="%s"' % self.gds_format_datetime(self.timestamp, input_name='timestamp')) 3836 if self.idref is not None and 'idref' not in already_processed: 3837 already_processed.add('idref') 3838 lwrite(' idref=%s' % (quote_attrib(self.idref), )) 3839 if self.id is not None and 'id' not in already_processed: 3840 already_processed.add('id') 3841 lwrite(' id=%s' % (quote_attrib(self.id), )) 3842 if self.extensiontype_ is not None and 'xsi:type' not in already_processed: 3843 already_processed.add('xsi:type') 3844 lwrite(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"') 3845 lwrite(' xsi:type="%s"' % self.extensiontype_) 3846 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='ReportBaseType', fromsubclass_=False, pretty_print=True): 3847 pass 3848 def build(self, node): 3849 self.__sourcenode__ = node 3850 already_processed = set() 3851 self.buildAttributes(node, node.attrib, already_processed) 3852 for child in node: 3853 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 3854 self.buildChildren(child, node, nodeName_) 3855 def buildAttributes(self, node, attrs, already_processed): 3856 value = find_attr_value_('timestamp', node) 3857 if value is not None and 'timestamp' not in already_processed: 3858 already_processed.add('timestamp') 3859 try: 3860 self.timestamp = self.gds_parse_datetime(value, node, 'timestamp') 3861 except ValueError as exp: 3862 raise ValueError('Bad date-time attribute (timestamp): %s' % exp) 3863 value = find_attr_value_('idref', node) 3864 if value is not None and 'idref' not in already_processed: 3865 already_processed.add('idref') 3866 self.idref = value 3867 value = find_attr_value_('id', node) 3868 if value is not None and 'id' not in already_processed: 3869 already_processed.add('id') 3870 self.id = value 3871 value = find_attr_value_('xsi:type', node) 3872 if value is not None and 'xsi:type' not in already_processed: 3873 already_processed.add('xsi:type') 3874 self.extensiontype_ = value 3875 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 3876 pass 3877# end class ReportBaseType 3878 3879class RelatedReportType(GenericRelationshipType): 3880 """Identifies or characterizes a relationship to a report.""" 3881 subclass = None 3882 superclass = GenericRelationshipType 3883 def __init__(self, Confidence=None, Information_Source=None, Relationship=None, Report=None): 3884 super(RelatedReportType, self).__init__(Confidence, Information_Source, Relationship, ) 3885 self.Report = Report 3886 def factory(*args_, **kwargs_): 3887 if RelatedReportType.subclass: 3888 return RelatedReportType.subclass(*args_, **kwargs_) 3889 else: 3890 return RelatedReportType(*args_, **kwargs_) 3891 factory = staticmethod(factory) 3892 def get_Report(self): return self.Report 3893 def set_Report(self, Report): self.Report = Report 3894 def hasContent_(self): 3895 if ( 3896 self.Report is not None or 3897 super(RelatedReportType, self).hasContent_() 3898 ): 3899 return True 3900 else: 3901 return False 3902 def export(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedReportType', namespacedef_='', pretty_print=True): 3903 if pretty_print: 3904 eol_ = '\n' 3905 else: 3906 eol_ = '' 3907 showIndent(lwrite, level, pretty_print) 3908 lwrite('<%s:%s%s' % (nsmap[namespace_], name_, namespacedef_ and ' ' + namespacedef_ or '', )) 3909 already_processed = set() 3910 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='RelatedReportType') 3911 if self.hasContent_(): 3912 lwrite('>%s' % (eol_, )) 3913 self.exportChildren(lwrite, level + 1, nsmap, XML_NS, name_, pretty_print=pretty_print) 3914 showIndent(lwrite, level, pretty_print) 3915 lwrite('</%s:%s>%s' % (nsmap[namespace_], name_, eol_)) 3916 else: 3917 lwrite('/>%s' % (eol_, )) 3918 def exportAttributes(self, lwrite, level, already_processed, namespace_='report:', name_='RelatedReportType'): 3919 super(RelatedReportType, self).exportAttributes(lwrite, level, already_processed, namespace_, name_='RelatedReportType') 3920 def exportChildren(self, lwrite, level, nsmap, namespace_=XML_NS, name_='RelatedReportType', fromsubclass_=False, pretty_print=True): 3921 super(RelatedReportType, self).exportChildren(lwrite, level, nsmap, namespace_, name_, True, pretty_print=pretty_print) 3922 if pretty_print: 3923 eol_ = '\n' 3924 else: 3925 eol_ = '' 3926 if self.Report is not None: 3927 self.Report.export(lwrite, level, nsmap, namespace_, name_='Report', pretty_print=pretty_print) 3928 def build(self, node): 3929 self.__sourcenode__ = node 3930 already_processed = set() 3931 self.buildAttributes(node, node.attrib, already_processed) 3932 for child in node: 3933 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 3934 self.buildChildren(child, node, nodeName_) 3935 def buildAttributes(self, node, attrs, already_processed): 3936 super(RelatedReportType, self).buildAttributes(node, attrs, already_processed) 3937 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 3938 if nodeName_ == 'Report': 3939 from . import report 3940 obj_ = lookup_extension(child_, ReportBaseType).factory() 3941 obj_.build(child_) 3942 self.set_Report(obj_) 3943 super(RelatedReportType, self).buildChildren(child_, node, nodeName_, True) 3944# end class RelatedReportType 3945 3946GDSClassesMapping = {} 3947 3948USAGE_TEXT = """ 3949Usage: python <Parser>.py [ -s ] <in_xml_file> 3950""" 3951 3952def usage(): 3953 print(USAGE_TEXT) 3954 sys.exit(1) 3955 3956def get_root_tag(node): 3957 tag = Tag_pattern_.match(node.tag).groups()[-1] 3958 rootClass = GDSClassesMapping.get(tag) 3959 if rootClass is None: 3960 rootClass = globals().get(tag) 3961 return tag, rootClass 3962 3963def parse(inFileName): 3964 doc = parsexml_(inFileName) 3965 rootNode = doc.getroot() 3966 rootTag, rootClass = get_root_tag(rootNode) 3967 if rootClass is None: 3968 rootTag = 'InformationSourceType' 3969 rootClass = InformationSourceType 3970 rootObj = rootClass.factory() 3971 rootObj.build(rootNode) 3972 # Enable Python to collect the space used by the DOM. 3973 doc = None 3974 # sys.stdout.write('<?xml version="1.0" ?>\n') 3975 # rootObj.export(sys.stdout, 0, name_=rootTag, 3976 # namespacedef_='', 3977 # pretty_print=True) 3978 return rootObj 3979 3980def parseEtree(inFileName): 3981 doc = parsexml_(inFileName) 3982 rootNode = doc.getroot() 3983 rootTag, rootClass = get_root_tag(rootNode) 3984 if rootClass is None: 3985 rootTag = 'InformationSourceType' 3986 rootClass = InformationSourceType 3987 rootObj = rootClass.factory() 3988 rootObj.build(rootNode) 3989 # Enable Python to collect the space used by the DOM. 3990 doc = None 3991 rootElement = rootObj.to_etree(None, name_=rootTag) 3992 content = etree_.tostring(rootElement, pretty_print=True, 3993 xml_declaration=True, encoding="utf-8") 3994 sys.stdout.write(content) 3995 sys.stdout.write('\n') 3996 return rootObj, rootElement 3997 3998def parseString(inString): 3999 from mixbox.vendor.six import StringIO 4000 doc = parsexml_(StringIO(inString)) 4001 rootNode = doc.getroot() 4002 rootTag, rootClass = get_root_tag(rootNode) 4003 if rootClass is None: 4004 rootTag = 'InformationSourceType' 4005 rootClass = InformationSourceType 4006 rootObj = rootClass.factory() 4007 rootObj.build(rootNode) 4008 # Enable Python to collect the space used by the DOM. 4009 doc = None 4010 # sys.stdout.write('<?xml version="1.0" ?>\n') 4011 # rootObj.export(sys.stdout, 0, name_="InformationSourceType", 4012 # namespacedef_='') 4013 return rootObj 4014 4015def main(): 4016 args = sys.argv[1:] 4017 if len(args) == 1: 4018 parse(args[0]) 4019 else: 4020 usage() 4021 4022if __name__ == '__main__': 4023 #import pdb; pdb.set_trace() 4024 main() 4025 4026__all__ = [ 4027 "GenericRelationshipType", 4028 "DateTimeWithPrecisionType", 4029 "ProfilesType", 4030 "RelatedPackageRefType", 4031 "RelatedPackageRefsType", 4032 "ToolInformationType", 4033 "InformationSourceType", 4034 "ConfidenceType", 4035 "ActivityType", 4036 "KillChainsType", 4037 "KillChainType", 4038 "KillChainPhaseType", 4039 "KillChainPhasesReferenceType", 4040 "KillChainPhaseReferenceType", 4041 "IdentityType", 4042 "GenericRelationshipListType", 4043 "RelatedCampaignType", 4044 "RelatedCourseOfActionType", 4045 "RelatedExploitTargetType", 4046 "RelatedIncidentType", 4047 "RelatedIndicatorType", 4048 "RelatedObservableType", 4049 "RelatedThreatActorType", 4050 "RelatedTTPType", 4051 "RelatedIdentityType", 4052 "IndicatorBaseType", 4053 "IncidentBaseType", 4054 "TTPBaseType", 4055 "ExploitTargetBaseType", 4056 "CourseOfActionBaseType", 4057 "RelatedCampaignReferenceType", 4058 "CampaignReferenceType", 4059 "NamesType", 4060 "CampaignBaseType", 4061 "ThreatActorBaseType", 4062 "ExploitTargetsType", 4063 "AddressAbstractType", 4064 "ContributingSourcesType", 4065 "ReferencesType", 4066 "RelatedIdentitiesType", 4067 "ConfidenceAssertionChainType", 4068 "StatementType", 4069 "StructuredTextType", 4070 "EncodedCDATAType", 4071 "ControlledVocabularyStringType", 4072 "ReportBaseType" 4073 ] 4074