1# Copyright (c) 2017, The MITRE Corporation. All rights reserved. 2# See LICENSE.txt for complete terms. 3 4import sys 5 6from mixbox.binding_utils import * 7from . import cybox_common 8from . import address_object 9from . import uri_object 10 11 12class WhoisRegistrarInfoType(GeneratedsSuper): 13 14 subclass = None 15 superclass = None 16 def __init__(self, Registrar_ID=None, Registrar_GUID=None, Name=None, Address=None, Email_Address=None, Phone_Number=None, Whois_Server=None, Referral_URL=None, Contacts=None): 17 self.Registrar_ID = Registrar_ID 18 self.Registrar_GUID = Registrar_GUID 19 self.Name = Name 20 self.Address = Address 21 self.Email_Address = Email_Address 22 self.Phone_Number = Phone_Number 23 self.Whois_Server = Whois_Server 24 self.Referral_URL = Referral_URL 25 self.Contacts = Contacts 26 def factory(*args_, **kwargs_): 27 if WhoisRegistrarInfoType.subclass: 28 return WhoisRegistrarInfoType.subclass(*args_, **kwargs_) 29 else: 30 return WhoisRegistrarInfoType(*args_, **kwargs_) 31 factory = staticmethod(factory) 32 def get_Registrar_ID(self): return self.Registrar_ID 33 def set_Registrar_ID(self, Registrar_ID): self.Registrar_ID = Registrar_ID 34 def validate_StringObjectPropertyType(self, value): 35 # Validate type cybox_common.StringObjectPropertyType, a restriction on None. 36 pass 37 def get_Registrar_GUID(self): return self.Registrar_GUID 38 def set_Registrar_GUID(self, Registrar_GUID): self.Registrar_GUID = Registrar_GUID 39 def get_Name(self): return self.Name 40 def set_Name(self, Name): self.Name = Name 41 def get_Address(self): return self.Address 42 def set_Address(self, Address): self.Address = Address 43 def get_Email_Address(self): return self.Email_Address 44 def set_Email_Address(self, Email_Address): self.Email_Address = Email_Address 45 def get_Phone_Number(self): return self.Phone_Number 46 def set_Phone_Number(self, Phone_Number): self.Phone_Number = Phone_Number 47 def get_Whois_Server(self): return self.Whois_Server 48 def set_Whois_Server(self, Whois_Server): self.Whois_Server = Whois_Server 49 def get_Referral_URL(self): return self.Referral_URL 50 def set_Referral_URL(self, Referral_URL): self.Referral_URL = Referral_URL 51 def get_Contacts(self): return self.Contacts 52 def set_Contacts(self, Contacts): self.Contacts = Contacts 53 def hasContent_(self): 54 if ( 55 self.Registrar_ID is not None or 56 self.Registrar_GUID is not None or 57 self.Name is not None or 58 self.Address is not None or 59 self.Email_Address is not None or 60 self.Phone_Number is not None or 61 self.Whois_Server is not None or 62 self.Referral_URL is not None or 63 self.Contacts is not None 64 ): 65 return True 66 else: 67 return False 68 def export(self, lwrite, level, namespace_='WhoisObj:', name_='WhoisRegistrarInfoType', namespacedef_='', pretty_print=True): 69 if pretty_print: 70 eol_ = '\n' 71 else: 72 eol_ = '' 73 showIndent(lwrite, level, pretty_print) 74 lwrite('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 75 already_processed = set() 76 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='WhoisRegistrarInfoType') 77 if self.hasContent_(): 78 lwrite('>%s' % (eol_, )) 79 self.exportChildren(lwrite, level + 1, namespace_, name_, pretty_print=pretty_print) 80 showIndent(lwrite, level, pretty_print) 81 lwrite('</%s%s>%s' % (namespace_, name_, eol_)) 82 else: 83 lwrite('/>%s' % (eol_, )) 84 def exportAttributes(self, lwrite, level, already_processed, namespace_='WhoisObj:', name_='WhoisRegistrarInfoType'): 85 pass 86 def exportChildren(self, lwrite, level, namespace_='WhoisObj:', name_='WhoisRegistrarInfoType', fromsubclass_=False, pretty_print=True): 87 if pretty_print: 88 eol_ = '\n' 89 else: 90 eol_ = '' 91 if self.Registrar_ID is not None: 92 self.Registrar_ID.export(lwrite, level, 'WhoisObj:', name_='Registrar_ID', pretty_print=pretty_print) 93 if self.Registrar_GUID is not None: 94 self.Registrar_GUID.export(lwrite, level, 'WhoisObj:', name_='Registrar_GUID', pretty_print=pretty_print) 95 if self.Name is not None: 96 self.Name.export(lwrite, level, 'WhoisObj:', name_='Name', pretty_print=pretty_print) 97 if self.Address is not None: 98 self.Address.export(lwrite, level, 'WhoisObj:', name_='Address', pretty_print=pretty_print) 99 if self.Email_Address is not None: 100 self.Email_Address.export(lwrite, level, 'WhoisObj:', name_='Email_Address', pretty_print=pretty_print) 101 if self.Phone_Number is not None: 102 self.Phone_Number.export(lwrite, level, 'WhoisObj:', name_='Phone_Number', pretty_print=pretty_print) 103 if self.Whois_Server is not None: 104 self.Whois_Server.export(lwrite, level, 'WhoisObj:', name_='Whois_Server', pretty_print=pretty_print) 105 if self.Referral_URL is not None: 106 self.Referral_URL.export(lwrite, level, 'WhoisObj:', name_='Referral_URL', pretty_print=pretty_print) 107 if self.Contacts is not None: 108 self.Contacts.export(lwrite, level, 'WhoisObj:', name_='Contacts', pretty_print=pretty_print) 109 def build(self, node): 110 self.__sourcenode__ = node 111 already_processed = set() 112 self.buildAttributes(node, node.attrib, already_processed) 113 for child in node: 114 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 115 self.buildChildren(child, node, nodeName_) 116 def buildAttributes(self, node, attrs, already_processed): 117 pass 118 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 119 if nodeName_ == 'Registrar_ID': 120 obj_ = cybox_common.StringObjectPropertyType.factory() 121 obj_.build(child_) 122 self.set_Registrar_ID(obj_) 123 elif nodeName_ == 'Registrar_GUID': 124 obj_ = cybox_common.StringObjectPropertyType.factory() 125 obj_.build(child_) 126 self.set_Registrar_GUID(obj_) 127 elif nodeName_ == 'Name': 128 obj_ = cybox_common.StringObjectPropertyType.factory() 129 obj_.build(child_) 130 self.set_Name(obj_) 131 elif nodeName_ == 'Address': 132 obj_ = cybox_common.StringObjectPropertyType.factory() 133 obj_.build(child_) 134 self.set_Address(obj_) 135 elif nodeName_ == 'Email_Address': 136 obj_ = address_object.AddressObjectType.factory() 137 obj_.build(child_) 138 self.set_Email_Address(obj_) 139 elif nodeName_ == 'Phone_Number': 140 obj_ = cybox_common.StringObjectPropertyType.factory() 141 obj_.build(child_) 142 self.set_Phone_Number(obj_) 143 elif nodeName_ == 'Whois_Server': 144 obj_ = uri_object.URIObjectType.factory() 145 obj_.build(child_) 146 self.set_Whois_Server(obj_) 147 elif nodeName_ == 'Referral_URL': 148 obj_ = uri_object.URIObjectType.factory() 149 obj_.build(child_) 150 self.set_Referral_URL(obj_) 151 elif nodeName_ == 'Contacts': 152 obj_ = WhoisContactsType.factory() 153 obj_.build(child_) 154 self.set_Contacts(obj_) 155# end class WhoisRegistrarInfoType 156 157class WhoisContactsType(GeneratedsSuper): 158 """The WhoisContactsType represents a list of contacts (usually 159 registrar or registrant) found in a Whois entry""" 160 161 subclass = None 162 superclass = None 163 def __init__(self, Contact=None): 164 if Contact is None: 165 self.Contact = [] 166 else: 167 self.Contact = Contact 168 def factory(*args_, **kwargs_): 169 if WhoisContactsType.subclass: 170 return WhoisContactsType.subclass(*args_, **kwargs_) 171 else: 172 return WhoisContactsType(*args_, **kwargs_) 173 factory = staticmethod(factory) 174 def get_Contact(self): return self.Contact 175 def set_Contact(self, Contact): self.Contact = Contact 176 def add_Contact(self, value): self.Contact.append(value) 177 def insert_Contact(self, index, value): self.Contact[index] = value 178 def hasContent_(self): 179 if ( 180 self.Contact 181 ): 182 return True 183 else: 184 return False 185 def export(self, lwrite, level, namespace_='WhoisObj:', name_='WhoisContactsType', namespacedef_='', pretty_print=True): 186 if pretty_print: 187 eol_ = '\n' 188 else: 189 eol_ = '' 190 showIndent(lwrite, level, pretty_print) 191 lwrite('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 192 already_processed = set() 193 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='WhoisContactsType') 194 if self.hasContent_(): 195 lwrite('>%s' % (eol_, )) 196 self.exportChildren(lwrite, level + 1, namespace_, name_, pretty_print=pretty_print) 197 showIndent(lwrite, level, pretty_print) 198 lwrite('</%s%s>%s' % (namespace_, name_, eol_)) 199 else: 200 lwrite('/>%s' % (eol_, )) 201 def exportAttributes(self, lwrite, level, already_processed, namespace_='WhoisObj:', name_='WhoisContactsType'): 202 pass 203 def exportChildren(self, lwrite, level, namespace_='WhoisObj:', name_='WhoisContactsType', fromsubclass_=False, pretty_print=True): 204 if pretty_print: 205 eol_ = '\n' 206 else: 207 eol_ = '' 208 for Contact_ in self.Contact: 209 Contact_.export(lwrite, level, 'WhoisObj:', name_='Contact', pretty_print=pretty_print) 210 def build(self, node): 211 self.__sourcenode__ = node 212 already_processed = set() 213 self.buildAttributes(node, node.attrib, already_processed) 214 for child in node: 215 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 216 self.buildChildren(child, node, nodeName_) 217 def buildAttributes(self, node, attrs, already_processed): 218 pass 219 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 220 if nodeName_ == 'Contact': 221 obj_ = WhoisContactType.factory() 222 obj_.build(child_) 223 self.add_Contact(obj_) 224# end class WhoisContactsType 225 226class WhoisContactType(GeneratedsSuper): 227 """The contact_type field specifies what type of contact this is. Only 228 values from WhoisObj:RegistrarContactTypeEnum can be used.""" 229 230 subclass = None 231 superclass = None 232 def __init__(self, contact_type=None, Contact_ID=None, Name=None, Email_Address=None, Phone_Number=None, Fax_Number=None, Address=None, Organization=None, extensiontype_=None): 233 self.contact_type = _cast(None, contact_type) 234 self.Contact_ID = Contact_ID 235 self.Name = Name 236 self.Email_Address = Email_Address 237 self.Fax_Number = Fax_Number 238 self.Phone_Number = Phone_Number 239 self.Address = Address 240 self.Organization = Organization 241 self.extensiontype_ = extensiontype_ 242 def factory(*args_, **kwargs_): 243 if WhoisContactType.subclass: 244 return WhoisContactType.subclass(*args_, **kwargs_) 245 else: 246 return WhoisContactType(*args_, **kwargs_) 247 factory = staticmethod(factory) 248 def get_Contact_ID(self): return self.Contact_ID 249 def set_Contact_ID(self, Contact_ID): self.Contact_ID = Contact_ID 250 def validate_StringObjectPropertyType(self, value): 251 # Validate type cybox_common.StringObjectPropertyType, a restriction on None. 252 pass 253 def get_Name(self): return self.Name 254 def set_Name(self, Name): self.Name = Name 255 def get_Email_Address(self): return self.Email_Address 256 def set_Email_Address(self, Email_Address): self.Email_Address = Email_Address 257 def get_Phone_Number(self): return self.Phone_Number 258 def set_Phone_Number(self, Phone_Number): self.Phone_Number = Phone_Number 259 def get_Fax_Number(self): return self.Fax_Number 260 def set_Fax_Number(self, Fax_Number): self.Fax_Number = Fax_Number 261 def get_Address(self): return self.Address 262 def set_Address(self, Address): self.Address = Address 263 def get_Organization(self): return self.Organization 264 def set_Organization(self, Organization): self.Organization = Organization 265 def get_contact_type(self): return self.contact_type 266 def set_contact_type(self, contact_type): self.contact_type = contact_type 267 def get_extensiontype_(self): return self.extensiontype_ 268 def set_extensiontype_(self, extensiontype_): self.extensiontype_ = extensiontype_ 269 def hasContent_(self): 270 if ( 271 self.Contact_ID is not None or 272 self.Name is not None or 273 self.Email_Address is not None or 274 self.Phone_Number is not None or 275 self.Fax_Number is not None or 276 self.Address is not None or 277 self.Organization is not None 278 ): 279 return True 280 else: 281 return False 282 def export(self, lwrite, level, namespace_='WhoisObj:', name_='WhoisContactType', namespacedef_='', pretty_print=True): 283 if pretty_print: 284 eol_ = '\n' 285 else: 286 eol_ = '' 287 showIndent(lwrite, level, pretty_print) 288 lwrite('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 289 already_processed = set() 290 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='WhoisContactType') 291 if self.hasContent_(): 292 lwrite('>%s' % (eol_, )) 293 self.exportChildren(lwrite, level + 1, namespace_, name_, pretty_print=pretty_print) 294 showIndent(lwrite, level, pretty_print) 295 lwrite('</%s%s>%s' % (namespace_, name_, eol_)) 296 else: 297 lwrite('/>%s' % (eol_, )) 298 def exportAttributes(self, lwrite, level, already_processed, namespace_='WhoisObj:', name_='WhoisContactType'): 299 if self.contact_type is not None: 300 301 lwrite(' contact_type=%s' % (quote_attrib(self.contact_type), )) 302 if self.extensiontype_ is not None: 303 304 lwrite(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"') 305 lwrite(' xsi:type="%s"' % self.extensiontype_) 306 def exportChildren(self, lwrite, level, namespace_='WhoisObj:', name_='WhoisContactType', fromsubclass_=False, pretty_print=True): 307 if pretty_print: 308 eol_ = '\n' 309 else: 310 eol_ = '' 311 if self.Contact_ID is not None: 312 self.Contact_ID.export(lwrite, level, 'WhoisObj:', name_='Contact_ID', pretty_print=pretty_print) 313 if self.Name is not None: 314 self.Name.export(lwrite, level, 'WhoisObj:', name_='Name', pretty_print=pretty_print) 315 if self.Email_Address is not None: 316 self.Email_Address.export(lwrite, level, 'WhoisObj:', name_='Email_Address', pretty_print=pretty_print) 317 if self.Phone_Number is not None: 318 self.Phone_Number.export(lwrite, level, 'WhoisObj:', name_='Phone_Number', pretty_print=pretty_print) 319 if self.Fax_Number is not None: 320 self.Fax_Number.export(lwrite, level, 'WhoisObj:', name_='Fax_Number', pretty_print=pretty_print) 321 if self.Address is not None: 322 self.Address.export(lwrite, level, 'WhoisObj:', name_='Address', pretty_print=pretty_print) 323 if self.Organization is not None: 324 self.Organization.export(lwrite, level, 'WhoisObj:', name_='Organization', pretty_print=pretty_print) 325 def build(self, node): 326 self.__sourcenode__ = node 327 already_processed = set() 328 self.buildAttributes(node, node.attrib, already_processed) 329 for child in node: 330 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 331 self.buildChildren(child, node, nodeName_) 332 def buildAttributes(self, node, attrs, already_processed): 333 value = find_attr_value_('contact_type', node) 334 if value is not None: 335 336 self.contact_type = value 337 value = find_attr_value_('xsi:type', node) 338 if value is not None: 339 340 self.extensiontype_ = value 341 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 342 if nodeName_ == 'Contact_ID': 343 obj_ = cybox_common.StringObjectPropertyType.factory() 344 obj_.build(child_) 345 self.set_Contact_ID(obj_) 346 elif nodeName_ == 'Name': 347 obj_ = cybox_common.StringObjectPropertyType.factory() 348 obj_.build(child_) 349 self.set_Name(obj_) 350 elif nodeName_ == 'Email_Address': 351 obj_ = address_object.AddressObjectType.factory() 352 obj_.build(child_) 353 self.set_Email_Address(obj_) 354 elif nodeName_ == 'Phone_Number': 355 obj_ = cybox_common.StringObjectPropertyType.factory() 356 obj_.build(child_) 357 self.set_Phone_Number(obj_) 358 elif nodeName_ == 'Fax_Number': 359 obj_ = cybox_common.StringObjectPropertyType.factory() 360 obj_.build(child_) 361 self.set_Fax_Number(obj_) 362 elif nodeName_ == 'Address': 363 obj_ = cybox_common.StringObjectPropertyType.factory() 364 obj_.build(child_) 365 self.set_Address(obj_) 366 elif nodeName_ == 'Organization': 367 obj_ = cybox_common.StringObjectPropertyType.factory() 368 obj_.build(child_) 369 self.set_Organization(obj_) 370# end class WhoisContactType 371 372class WhoisStatusesType(GeneratedsSuper): 373 """The WhoisStatusesType defines a list of WhoisStatusType objecst""" 374 375 subclass = None 376 superclass = None 377 def __init__(self, Status=None): 378 if Status is None: 379 self.Status = [] 380 else: 381 self.Status = Status 382 def factory(*args_, **kwargs_): 383 if WhoisStatusesType.subclass: 384 return WhoisStatusesType.subclass(*args_, **kwargs_) 385 else: 386 return WhoisStatusesType(*args_, **kwargs_) 387 factory = staticmethod(factory) 388 def get_Status(self): return self.Status 389 def set_Status(self, Status): self.Status = Status 390 def add_Status(self, value): self.Status.append(value) 391 def insert_Status(self, index, value): self.Status[index] = value 392 def validate_WhoisStatusType(self, value): 393 # Validate type WhoisStatusType, a restriction on None. 394 pass 395 def hasContent_(self): 396 if ( 397 self.Status 398 ): 399 return True 400 else: 401 return False 402 def export(self, lwrite, level, namespace_='WhoisObj:', name_='WhoisStatusesType', namespacedef_='', pretty_print=True): 403 if pretty_print: 404 eol_ = '\n' 405 else: 406 eol_ = '' 407 showIndent(lwrite, level, pretty_print) 408 lwrite('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 409 already_processed = set() 410 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='WhoisStatusesType') 411 if self.hasContent_(): 412 lwrite('>%s' % (eol_, )) 413 self.exportChildren(lwrite, level + 1, namespace_, name_, pretty_print=pretty_print) 414 showIndent(lwrite, level, pretty_print) 415 lwrite('</%s%s>%s' % (namespace_, name_, eol_)) 416 else: 417 lwrite('/>%s' % (eol_, )) 418 def exportAttributes(self, lwrite, level, already_processed, namespace_='WhoisObj:', name_='WhoisStatusesType'): 419 pass 420 def exportChildren(self, lwrite, level, namespace_='WhoisObj:', name_='WhoisStatusesType', fromsubclass_=False, pretty_print=True): 421 if pretty_print: 422 eol_ = '\n' 423 else: 424 eol_ = '' 425 for Status_ in self.Status: 426 Status_.export(lwrite, level, 'WhoisObj:', name_='Status', pretty_print=pretty_print) 427 def build(self, node): 428 self.__sourcenode__ = node 429 already_processed = set() 430 self.buildAttributes(node, node.attrib, already_processed) 431 for child in node: 432 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 433 self.buildChildren(child, node, nodeName_) 434 def buildAttributes(self, node, attrs, already_processed): 435 pass 436 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 437 if nodeName_ == 'Status': 438 obj_ = WhoisStatusType.factory() 439 obj_.build(child_) 440 self.Status.append(obj_) 441# end class WhoisStatusesType 442 443class WhoisNameserversType(GeneratedsSuper): 444 """The WhoisNameserversType defines a list of nameservers associated 445 with a Whois entry""" 446 447 subclass = None 448 superclass = None 449 def __init__(self, Nameserver=None): 450 if Nameserver is None: 451 self.Nameserver = [] 452 else: 453 self.Nameserver = Nameserver 454 def factory(*args_, **kwargs_): 455 if WhoisNameserversType.subclass: 456 return WhoisNameserversType.subclass(*args_, **kwargs_) 457 else: 458 return WhoisNameserversType(*args_, **kwargs_) 459 factory = staticmethod(factory) 460 def get_Nameserver(self): return self.Nameserver 461 def set_Nameserver(self, Nameserver): self.Nameserver = Nameserver 462 def add_Nameserver(self, value): self.Nameserver.append(value) 463 def insert_Nameserver(self, index, value): self.Nameserver[index] = value 464 def hasContent_(self): 465 if ( 466 self.Nameserver 467 ): 468 return True 469 else: 470 return False 471 def export(self, lwrite, level, namespace_='WhoisObj:', name_='WhoisNameserversType', namespacedef_='', pretty_print=True): 472 if pretty_print: 473 eol_ = '\n' 474 else: 475 eol_ = '' 476 showIndent(lwrite, level, pretty_print) 477 lwrite('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 478 already_processed = set() 479 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='WhoisNameserversType') 480 if self.hasContent_(): 481 lwrite('>%s' % (eol_, )) 482 self.exportChildren(lwrite, level + 1, namespace_, name_, pretty_print=pretty_print) 483 showIndent(lwrite, level, pretty_print) 484 lwrite('</%s%s>%s' % (namespace_, name_, eol_)) 485 else: 486 lwrite('/>%s' % (eol_, )) 487 def exportAttributes(self, lwrite, level, already_processed, namespace_='WhoisObj:', name_='WhoisNameserversType'): 488 pass 489 def exportChildren(self, lwrite, level, namespace_='WhoisObj:', name_='WhoisNameserversType', fromsubclass_=False, pretty_print=True): 490 if pretty_print: 491 eol_ = '\n' 492 else: 493 eol_ = '' 494 for Nameserver_ in self.Nameserver: 495 Nameserver_.export(lwrite, level, 'WhoisObj:', name_='Nameserver', pretty_print=pretty_print) 496 def build(self, node): 497 self.__sourcenode__ = node 498 already_processed = set() 499 self.buildAttributes(node, node.attrib, already_processed) 500 for child in node: 501 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 502 self.buildChildren(child, node, nodeName_) 503 def buildAttributes(self, node, attrs, already_processed): 504 pass 505 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 506 if nodeName_ == 'Nameserver': 507 obj_ = uri_object.URIObjectType.factory() 508 obj_.build(child_) 509 self.Nameserver.append(obj_) 510# end class WhoisNameserversType 511 512class WhoisRegistrantInfoType(WhoisContactType): 513 514 subclass = None 515 superclass = WhoisContactType 516 def __init__(self, contact_type=None, Contact_ID=None, Name=None, Email_Address=None, Phone_Number=None, Fax_Number=None, Address=None, Organization=None, Registrant_ID=None): 517 super(WhoisRegistrantInfoType, self).__init__(contact_type, Contact_ID, Name, Email_Address, Phone_Number, Fax_Number, Address, Organization, ) 518 self.Registrant_ID = Registrant_ID 519 def factory(*args_, **kwargs_): 520 if WhoisRegistrantInfoType.subclass: 521 return WhoisRegistrantInfoType.subclass(*args_, **kwargs_) 522 else: 523 return WhoisRegistrantInfoType(*args_, **kwargs_) 524 factory = staticmethod(factory) 525 def get_Registrant_ID(self): return self.Registrant_ID 526 def set_Registrant_ID(self, Registrant_ID): self.Registrant_ID = Registrant_ID 527 def validate_StringObjectPropertyType(self, value): 528 # Validate type cybox_common.StringObjectPropertyType, a restriction on None. 529 pass 530 def hasContent_(self): 531 if ( 532 self.Registrant_ID is not None or 533 super(WhoisRegistrantInfoType, self).hasContent_() 534 ): 535 return True 536 else: 537 return False 538 def export(self, lwrite, level, namespace_='WhoisObj:', name_='WhoisRegistrantInfoType', namespacedef_='', pretty_print=True): 539 if pretty_print: 540 eol_ = '\n' 541 else: 542 eol_ = '' 543 showIndent(lwrite, level, pretty_print) 544 lwrite('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 545 already_processed = set() 546 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='WhoisRegistrantInfoType') 547 if self.hasContent_(): 548 lwrite('>%s' % (eol_, )) 549 self.exportChildren(lwrite, level + 1, namespace_, name_, pretty_print=pretty_print) 550 showIndent(lwrite, level, pretty_print) 551 lwrite('</%s%s>%s' % (namespace_, name_, eol_)) 552 else: 553 lwrite('/>%s' % (eol_, )) 554 def exportAttributes(self, lwrite, level, already_processed, namespace_='WhoisObj:', name_='WhoisRegistrantInfoType'): 555 super(WhoisRegistrantInfoType, self).exportAttributes(lwrite, level, already_processed, namespace_, name_='WhoisRegistrantInfoType') 556 def exportChildren(self, lwrite, level, namespace_='WhoisObj:', name_='WhoisRegistrantInfoType', fromsubclass_=False, pretty_print=True): 557 super(WhoisRegistrantInfoType, self).exportChildren(lwrite, level, 'WhoisObj:', name_, True, pretty_print=pretty_print) 558 if pretty_print: 559 eol_ = '\n' 560 else: 561 eol_ = '' 562 if self.Registrant_ID is not None: 563 self.Registrant_ID.export(lwrite, level, 'WhoisObj:', name_='Registrant_ID', pretty_print=pretty_print) 564 def build(self, node): 565 self.__sourcenode__ = node 566 already_processed = set() 567 self.buildAttributes(node, node.attrib, already_processed) 568 for child in node: 569 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 570 self.buildChildren(child, node, nodeName_) 571 def buildAttributes(self, node, attrs, already_processed): 572 super(WhoisRegistrantInfoType, self).buildAttributes(node, attrs, already_processed) 573 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 574 if nodeName_ == 'Registrant_ID': 575 obj_ = cybox_common.StringObjectPropertyType.factory() 576 obj_.build(child_) 577 self.set_Registrant_ID(obj_) 578 super(WhoisRegistrantInfoType, self).buildChildren(child_, node, nodeName_, True) 579# end class WhoisRegistrantInfoType 580 581class WhoisRegistrantsType(GeneratedsSuper): 582 """The WhoisRegistrantsType represents a list of registrant information 583 for a given Whois entry""" 584 585 subclass = None 586 superclass = None 587 def __init__(self, Registrant=None): 588 if Registrant is None: 589 self.Registrant = [] 590 else: 591 self.Registrant = Registrant 592 def factory(*args_, **kwargs_): 593 if WhoisRegistrantsType.subclass: 594 return WhoisRegistrantsType.subclass(*args_, **kwargs_) 595 else: 596 return WhoisRegistrantsType(*args_, **kwargs_) 597 factory = staticmethod(factory) 598 def get_Registrant(self): return self.Registrant 599 def set_Registrant(self, Registrant): self.Registrant = Registrant 600 def add_Registrant(self, value): self.Registrant.append(value) 601 def insert_Registrant(self, index, value): self.Registrant[index] = value 602 def hasContent_(self): 603 if ( 604 self.Registrant 605 ): 606 return True 607 else: 608 return False 609 def export(self, lwrite, level, namespace_='WhoisObj:', name_='WhoisRegistrantsType', namespacedef_='', pretty_print=True): 610 if pretty_print: 611 eol_ = '\n' 612 else: 613 eol_ = '' 614 showIndent(lwrite, level, pretty_print) 615 lwrite('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 616 already_processed = set() 617 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='WhoisRegistrantsType') 618 if self.hasContent_(): 619 lwrite('>%s' % (eol_, )) 620 self.exportChildren(lwrite, level + 1, namespace_, name_, pretty_print=pretty_print) 621 showIndent(lwrite, level, pretty_print) 622 lwrite('</%s%s>%s' % (namespace_, name_, eol_)) 623 else: 624 lwrite('/>%s' % (eol_, )) 625 def exportAttributes(self, lwrite, level, already_processed, namespace_='WhoisObj:', name_='WhoisRegistrantsType'): 626 pass 627 def exportChildren(self, lwrite, level, namespace_='WhoisObj:', name_='WhoisRegistrantsType', fromsubclass_=False, pretty_print=True): 628 if pretty_print: 629 eol_ = '\n' 630 else: 631 eol_ = '' 632 for Registrant_ in self.Registrant: 633 Registrant_.export(lwrite, level, 'WhoisObj:', name_='Registrant', pretty_print=pretty_print) 634 def build(self, node): 635 self.__sourcenode__ = node 636 already_processed = set() 637 self.buildAttributes(node, node.attrib, already_processed) 638 for child in node: 639 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 640 self.buildChildren(child, node, nodeName_) 641 def buildAttributes(self, node, attrs, already_processed): 642 pass 643 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 644 if nodeName_ == 'Registrant': 645 obj_ = WhoisRegistrantInfoType.factory() 646 obj_.build(child_) 647 self.Registrant.append(obj_) 648# end class WhoisRegistrantsType 649 650class RegionalRegistryType(cybox_common.BaseObjectPropertyType): 651 """The RegionalRegistryType specifies a Regional Internet Registry 652 (RIR) for a given WHOIS entry. RIRs defined by the 653 RegionalRegistryTypeEnum may be used, as well as those specified 654 by a free form text string.""" 655 656 subclass = None 657 superclass = cybox_common.BaseObjectPropertyType 658 def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None): 659 # PROP: This is a BaseObjectPropertyType subclass 660 super(RegionalRegistryType, self).__init__(obfuscation_algorithm_ref, refanging_transform_type, has_changed, delimiter, pattern_type, datatype, refanging_transform, is_case_sensitive, bit_mask, appears_random, observed_encoding, defanging_algorithm_ref, is_obfuscated, regex_syntax, apply_condition, trend, idref, is_defanged, id, condition, valueOf_) 661 self.valueOf_ = valueOf_ 662 def factory(*args_, **kwargs_): 663 if RegionalRegistryType.subclass: 664 return RegionalRegistryType.subclass(*args_, **kwargs_) 665 else: 666 return RegionalRegistryType(*args_, **kwargs_) 667 factory = staticmethod(factory) 668 def get_valueOf_(self): return self.valueOf_ 669 def set_valueOf_(self, valueOf_): self.valueOf_ = valueOf_ 670 def hasContent_(self): 671 if ( 672 self.valueOf_ or 673 super(RegionalRegistryType, self).hasContent_() 674 ): 675 return True 676 else: 677 return False 678 def export(self, lwrite, level, namespace_='WhoisObj:', name_='RegionalRegistryType', namespacedef_='', pretty_print=True): 679 if pretty_print: 680 eol_ = '\n' 681 else: 682 eol_ = '' 683 showIndent(lwrite, level, pretty_print) 684 lwrite('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 685 already_processed = set() 686 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='RegionalRegistryType') 687 if self.hasContent_(): 688 lwrite('>') 689 lwrite(quote_xml(self.valueOf_)) 690 self.exportChildren(lwrite, level + 1, namespace_, name_, pretty_print=pretty_print) 691 lwrite('</%s%s>%s' % (namespace_, name_, eol_)) 692 else: 693 lwrite('/>%s' % (eol_, )) 694 def exportAttributes(self, lwrite, level, already_processed, namespace_='WhoisObj:', name_='RegionalRegistryType'): 695 super(RegionalRegistryType, self).exportAttributes(lwrite, level, already_processed, namespace_, name_='RegionalRegistryType') 696 def exportChildren(self, lwrite, level, namespace_='WhoisObj:', name_='RegionalRegistryType', fromsubclass_=False, pretty_print=True): 697 super(RegionalRegistryType, self).exportChildren(lwrite, level, 'WhoisObj:', name_, True, pretty_print=pretty_print) 698 pass 699 def build(self, node): 700 self.__sourcenode__ = node 701 already_processed = set() 702 self.buildAttributes(node, node.attrib, already_processed) 703 self.valueOf_ = get_all_text_(node) 704 for child in node: 705 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 706 self.buildChildren(child, node, nodeName_) 707 def buildAttributes(self, node, attrs, already_processed): 708 super(RegionalRegistryType, self).buildAttributes(node, attrs, already_processed) 709 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 710 pass 711# end class RegionalRegistryType 712 713class WhoisStatusType(cybox_common.BaseObjectPropertyType): 714 """The WhoisStatusType specifies a status for a domain as listed in its 715 Whois entry. Only statuses defined by WhoisStatusTypeEnum can be 716 used.""" 717 718 subclass = None 719 superclass = cybox_common.BaseObjectPropertyType 720 def __init__(self, obfuscation_algorithm_ref=None, refanging_transform_type=None, has_changed=None, delimiter='##comma##', pattern_type=None, datatype='string', refanging_transform=None, is_case_sensitive=True, bit_mask=None, appears_random=None, observed_encoding=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, apply_condition='ANY', trend=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None, extensiontype_=None): 721 # PROP: This is a BaseObjectPropertyType subclass 722 super(WhoisStatusType, self).__init__(obfuscation_algorithm_ref, refanging_transform_type, has_changed, delimiter, pattern_type, datatype, refanging_transform, is_case_sensitive, bit_mask, appears_random, observed_encoding, defanging_algorithm_ref, is_obfuscated, regex_syntax, apply_condition, trend, idref, is_defanged, id, condition, valueOf_, extensiontype_) 723 def factory(*args_, **kwargs_): 724 if WhoisStatusType.subclass: 725 return WhoisStatusType.subclass(*args_, **kwargs_) 726 else: 727 return WhoisStatusType(*args_, **kwargs_) 728 factory = staticmethod(factory) 729 def get_valueOf_(self): return self.valueOf_ 730 def set_valueOf_(self, valueOf_): self.valueOf_ = valueOf_ 731 def hasContent_(self): 732 if ( 733 self.valueOf_ or 734 super(WhoisStatusType, self).hasContent_() 735 ): 736 return True 737 else: 738 return False 739 def export(self, lwrite, level, namespace_='WhoisObj:', name_='WhoisStatusType', namespacedef_='', pretty_print=True): 740 if pretty_print: 741 eol_ = '\n' 742 else: 743 eol_ = '' 744 showIndent(lwrite, level, pretty_print) 745 lwrite('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 746 already_processed = set() 747 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='WhoisStatusType') 748 if self.hasContent_(): 749 lwrite('>') 750 lwrite(quote_xml(self.valueOf_)) 751 self.exportChildren(lwrite, level + 1, namespace_, name_, pretty_print=pretty_print) 752 lwrite('</%s%s>%s' % (namespace_, name_, eol_)) 753 else: 754 lwrite('/>%s' % (eol_, )) 755 def exportAttributes(self, lwrite, level, already_processed, namespace_='WhoisObj:', name_='WhoisStatusType'): 756 super(WhoisStatusType, self).exportAttributes(lwrite, level, already_processed, namespace_, name_='WhoisStatusType') 757 def exportChildren(self, lwrite, level, namespace_='WhoisObj:', name_='WhoisStatusType', fromsubclass_=False, pretty_print=True): 758 super(WhoisStatusType, self).exportChildren(lwrite, level, 'WhoisObj:', name_, True, pretty_print=pretty_print) 759 pass 760 def build(self, node): 761 self.__sourcenode__ = node 762 already_processed = set() 763 self.buildAttributes(node, node.attrib, already_processed) 764 self.valueOf_ = get_all_text_(node) 765 for child in node: 766 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 767 self.buildChildren(child, node, nodeName_) 768 def buildAttributes(self, node, attrs, already_processed): 769 super(WhoisStatusType, self).buildAttributes(node, attrs, already_processed) 770 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 771 pass 772# end class WhoisStatusType 773 774class WhoisObjectType(cybox_common.ObjectPropertiesType): 775 """The WhoisObjectType type is intended to characterize Whois 776 information for a domain.""" 777 778 subclass = None 779 superclass = cybox_common.ObjectPropertiesType 780 def __init__(self, object_reference=None, Custom_Properties=None, xsi_type=None, Lookup_Date=None, Domain_Name=None, Domain_ID=None, Server_Name=None, IP_Address=None, DNSSEC=None, Nameservers=None, Status=None, Updated_Date=None, Creation_Date=None, Expiration_Date=None, Regional_Internet_Registry=None, Sponsoring_Registrar=None, Registrar_Info=None, Registrants=None, Contact_Info=None, Remarks=None): 781 super(WhoisObjectType, self).__init__(object_reference, Custom_Properties, xsi_type ) 782 self.Lookup_Date = Lookup_Date 783 self.Domain_Name = Domain_Name 784 self.Domain_ID = Domain_ID 785 self.Server_Name = Server_Name 786 self.IP_Address = IP_Address 787 self.DNSSEC = DNSSEC 788 self.Nameservers = Nameservers 789 self.Status = Status 790 self.Updated_Date = Updated_Date 791 self.Creation_Date = Creation_Date 792 self.Expiration_Date = Expiration_Date 793 self.Regional_Internet_Registry = Regional_Internet_Registry 794 self.Sponsoring_Registrar = Sponsoring_Registrar 795 self.Registrar_Info = Registrar_Info 796 self.Registrants = Registrants 797 self.Contact_Info = Contact_Info 798 self.Remarks = Remarks 799 def factory(*args_, **kwargs_): 800 if WhoisObjectType.subclass: 801 return WhoisObjectType.subclass(*args_, **kwargs_) 802 else: 803 return WhoisObjectType(*args_, **kwargs_) 804 factory = staticmethod(factory) 805 def get_Lookup_Date(self): return self.Lookup_Date 806 def set_Lookup_Date(self, Lookup_Date): self.Lookup_Date = Lookup_Date 807 def get_Domain_Name(self): return self.Domain_Name 808 def set_Domain_Name(self, Domain_Name): self.Domain_Name = Domain_Name 809 def get_Domain_ID(self): return self.Domain_ID 810 def set_Domain_ID(self, Domain_ID): self.Domain_ID = Domain_ID 811 def validate_StringObjectPropertyType(self, value): 812 # Validate type cybox_common.StringObjectPropertyType, a restriction on None. 813 pass 814 def get_Server_Name(self): return self.Server_Name 815 def set_Server_Name(self, Server_Name): self.Server_Name = Server_Name 816 def get_IP_Address(self): return self.IP_Address 817 def set_IP_Address(self, IP_Address): self.IP_Address = IP_Address 818 def get_DNSSEC(self): return self.DNSSEC 819 def set_DNSSEC(self, DNSSEC): self.DNSSEC = DNSSEC 820 def validate_WhoisDNSSECTypeEnum(self, value): 821 # Validate type WhoisDNSSECTypeEnum, a restriction on xs:string. 822 pass 823 def get_Nameservers(self): return self.Nameservers 824 def set_Nameservers(self, Nameservers): self.Nameservers = Nameservers 825 def get_Status(self): return self.Status 826 def set_Status(self, Status): self.Status = Status 827 def get_Updated_Date(self): return self.Updated_Date 828 def set_Updated_Date(self, Updated_Date): self.Updated_Date = Updated_Date 829 def validate_DateObjectPropertyType(self, value): 830 # Validate type cybox_common.DateObjectPropertyType, a restriction on None. 831 pass 832 def get_Creation_Date(self): return self.Creation_Date 833 def set_Creation_Date(self, Creation_Date): self.Creation_Date = Creation_Date 834 def get_Expiration_Date(self): return self.Expiration_Date 835 def set_Expiration_Date(self, Expiration_Date): self.Expiration_Date = Expiration_Date 836 def get_Regional_Internet_Registry(self): return self.Regional_Internet_Registry 837 def set_Regional_Internet_Registry(self, Regional_Internet_Registry): self.Regional_Internet_Registry = Regional_Internet_Registry 838 def validate_RegionalRegistryType(self, value): 839 # Validate type RegionalRegistryType, a restriction on None. 840 pass 841 def get_Sponsoring_Registrar(self): return self.Sponsoring_Registrar 842 def set_Sponsoring_Registrar(self, Sponsoring_Registrar): self.Sponsoring_Registrar = Sponsoring_Registrar 843 def get_Registrar_Info(self): return self.Registrar_Info 844 def set_Registrar_Info(self, Registrar_Info): self.Registrar_Info = Registrar_Info 845 def get_Registrants(self): return self.Registrants 846 def set_Registrants(self, Registrants): self.Registrants = Registrants 847 def get_Contact_Info(self): return self.Contact_Info 848 def set_Contact_Info(self, Contact_Info): self.Contact_Info = Contact_Info 849 def get_Remarks(self): return self.Remarks 850 def set_Remarks(self, Remarks): self.Remarks = Remarks 851 def hasContent_(self): 852 if ( 853 self.Lookup_Date is not None or 854 self.Domain_Name is not None or 855 self.Domain_ID is not None or 856 self.Server_Name is not None or 857 self.IP_Address is not None or 858 self.DNSSEC is not None or 859 self.Nameservers is not None or 860 self.Status is not None or 861 self.Updated_Date is not None or 862 self.Creation_Date is not None or 863 self.Expiration_Date is not None or 864 self.Regional_Internet_Registry is not None or 865 self.Sponsoring_Registrar is not None or 866 self.Registrar_Info is not None or 867 self.Registrants is not None or 868 self.Contact_Info is not None or 869 self.Remarks is not None or 870 super(WhoisObjectType, self).hasContent_() 871 ): 872 return True 873 else: 874 return False 875 def export(self, lwrite, level, namespace_='WhoisObj:', name_='WhoisObjectType', namespacedef_='', pretty_print=True): 876 if pretty_print: 877 eol_ = '\n' 878 else: 879 eol_ = '' 880 showIndent(lwrite, level, pretty_print) 881 lwrite('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 882 already_processed = set() 883 self.exportAttributes(lwrite, level, already_processed, namespace_, name_='WhoisObjectType') 884 if self.hasContent_(): 885 lwrite('>%s' % (eol_, )) 886 self.exportChildren(lwrite, level + 1, namespace_, name_, pretty_print=pretty_print) 887 showIndent(lwrite, level, pretty_print) 888 lwrite('</%s%s>%s' % (namespace_, name_, eol_)) 889 else: 890 lwrite('/>%s' % (eol_, )) 891 def exportAttributes(self, lwrite, level, already_processed, namespace_='WhoisObj:', name_='WhoisObjectType'): 892 super(WhoisObjectType, self).exportAttributes(lwrite, level, already_processed, namespace_, name_='WhoisObjectType') 893 def exportChildren(self, lwrite, level, namespace_='WhoisObj:', name_='WhoisObjectType', fromsubclass_=False, pretty_print=True): 894 super(WhoisObjectType, self).exportChildren(lwrite, level, 'WhoisObj:', name_, True, pretty_print=pretty_print) 895 if pretty_print: 896 eol_ = '\n' 897 else: 898 eol_ = '' 899 if self.Lookup_Date is not None: 900 self.Lookup_Date.export(lwrite, level, 'WhoisObj:', name_='Lookup_Date', pretty_print=pretty_print) 901 if self.Domain_Name is not None: 902 self.Domain_Name.export(lwrite, level, 'WhoisObj:', name_='Domain_Name', pretty_print=pretty_print) 903 if self.Domain_ID is not None: 904 self.Domain_ID.export(lwrite, level, 'WhoisObj:', name_='Domain_ID', pretty_print=pretty_print) 905 if self.Server_Name is not None: 906 self.Server_Name.export(lwrite, level, 'WhoisObj:', name_='Server_Name', pretty_print=pretty_print) 907 if self.IP_Address is not None: 908 self.IP_Address.export(lwrite, level, 'WhoisObj:', name_='IP_Address', pretty_print=pretty_print) 909 if self.DNSSEC is not None: 910 showIndent(lwrite, level, pretty_print) 911 lwrite('<%sDNSSEC>%s</%sDNSSEC>%s' % ('WhoisObj:', self.gds_format_string(quote_xml(self.DNSSEC), input_name='DNSSEC'), 'WhoisObj:', eol_)) 912 if self.Nameservers is not None: 913 self.Nameservers.export(lwrite, level, 'WhoisObj:', name_='Nameservers', pretty_print=pretty_print) 914 if self.Status is not None: 915 self.Status.export(lwrite, level, 'WhoisObj:', name_='Status', pretty_print=pretty_print) 916 if self.Updated_Date is not None: 917 self.Updated_Date.export(lwrite, level, 'WhoisObj:', name_='Updated_Date', pretty_print=pretty_print) 918 if self.Creation_Date is not None: 919 self.Creation_Date.export(lwrite, level, 'WhoisObj:', name_='Creation_Date', pretty_print=pretty_print) 920 if self.Expiration_Date is not None: 921 self.Expiration_Date.export(lwrite, level, 'WhoisObj:', name_='Expiration_Date', pretty_print=pretty_print) 922 if self.Regional_Internet_Registry is not None: 923 self.Regional_Internet_Registry.export(lwrite, level, 'WhoisObj:', name_='Regional_Internet_Registry', pretty_print=pretty_print) 924 if self.Sponsoring_Registrar is not None: 925 self.Sponsoring_Registrar.export(lwrite, level, 'WhoisObj:', name_='Sponsoring_Registrar', pretty_print=pretty_print) 926 if self.Registrar_Info is not None: 927 self.Registrar_Info.export(lwrite, level, 'WhoisObj:', name_='Registrar_Info', pretty_print=pretty_print) 928 if self.Registrants is not None: 929 self.Registrants.export(lwrite, level, 'WhoisObj:', name_='Registrants', pretty_print=pretty_print) 930 if self.Contact_Info is not None: 931 self.Contact_Info.export(lwrite, level, 'WhoisObj:', name_='Contact_Info', pretty_print=pretty_print) 932 if self.Remarks is not None: 933 self.Remarks.export(lwrite, level, 'WhoisObj:', name_='Remarks', pretty_print=pretty_print) 934 def build(self, node): 935 self.__sourcenode__ = node 936 already_processed = set() 937 self.buildAttributes(node, node.attrib, already_processed) 938 for child in node: 939 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 940 self.buildChildren(child, node, nodeName_) 941 def buildAttributes(self, node, attrs, already_processed): 942 super(WhoisObjectType, self).buildAttributes(node, attrs, already_processed) 943 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 944 if nodeName_ == 'Lookup_Date': 945 obj_ = cybox_common.DateTimeObjectPropertyType.factory() 946 obj_.build(child_) 947 self.set_Lookup_Date(obj_) 948 elif nodeName_ == 'Domain_Name': 949 obj_ = uri_object.URIObjectType.factory() 950 obj_.build(child_) 951 self.set_Domain_Name(obj_) 952 elif nodeName_ == 'Domain_ID': 953 obj_ = cybox_common.StringObjectPropertyType.factory() 954 obj_.build(child_) 955 self.set_Domain_ID(obj_) 956 elif nodeName_ == 'Server_Name': 957 obj_ = uri_object.URIObjectType.factory() 958 obj_.build(child_) 959 self.set_Server_Name(obj_) 960 elif nodeName_ == 'IP_Address': 961 obj_ = address_object.AddressObjectType.factory() 962 obj_.build(child_) 963 self.set_IP_Address(obj_) 964 elif nodeName_ == 'DNSSEC': 965 DNSSEC = child_.text 966 DNSSEC = self.gds_validate_string(DNSSEC, node, 'DNSSEC') 967 self.DNSSEC = DNSSEC 968 elif nodeName_ == 'Nameservers': 969 obj_ = WhoisNameserversType.factory() 970 obj_.build(child_) 971 self.set_Nameservers(obj_) 972 elif nodeName_ == 'Status': 973 obj_ = WhoisStatusesType.factory() 974 obj_.build(child_) 975 self.set_Status(obj_) 976 elif nodeName_ == 'Updated_Date': 977 obj_ = cybox_common.DateObjectPropertyType.factory() 978 obj_.build(child_) 979 self.set_Updated_Date(obj_) 980 elif nodeName_ == 'Creation_Date': 981 obj_ = cybox_common.DateObjectPropertyType.factory() 982 obj_.build(child_) 983 self.set_Creation_Date(obj_) 984 elif nodeName_ == 'Expiration_Date': 985 obj_ = cybox_common.DateObjectPropertyType.factory() 986 obj_.build(child_) 987 self.set_Expiration_Date(obj_) 988 elif nodeName_ == 'Regional_Internet_Registry': 989 obj_ = RegionalRegistryType.factory() 990 obj_.build(child_) 991 self.set_Regional_Internet_Registry(obj_) 992 elif nodeName_ == 'Sponsoring_Registrar': 993 obj_ = cybox_common.StringObjectPropertyType.factory() 994 obj_.build(child_) 995 self.set_Sponsoring_Registrar(obj_) 996 elif nodeName_ == 'Registrar_Info': 997 obj_ = WhoisRegistrarInfoType.factory() 998 obj_.build(child_) 999 self.set_Registrar_Info(obj_) 1000 elif nodeName_ == 'Registrants': 1001 obj_ = WhoisRegistrantsType.factory() 1002 obj_.build(child_) 1003 self.set_Registrants(obj_) 1004 elif nodeName_ == 'Contact_Info': 1005 obj_ = WhoisContactType.factory() 1006 obj_.build(child_) 1007 self.set_Contact_Info(obj_) 1008 elif nodeName_ == 'Remarks': 1009 obj_ = cybox_common.StringObjectPropertyType.factory() 1010 obj_.build(child_) 1011 self.set_Remarks(obj_) 1012 super(WhoisObjectType, self).buildChildren(child_, node, nodeName_, True) 1013# end class WhoisObjectType 1014 1015GDSClassesMapping = { 1016 'Build_Utility': cybox_common.BuildUtilityType, 1017 'Errors': cybox_common.ErrorsType, 1018 'Time': cybox_common.TimeType, 1019 'Certificate_Issuer': cybox_common.StringObjectPropertyType, 1020 'Email_Address': address_object.AddressObjectType, 1021 'Metadata': cybox_common.MetadataType, 1022 'Hash': cybox_common.HashType, 1023 'Information_Source_Type': cybox_common.ControlledVocabularyStringType, 1024 'Domain_ID': cybox_common.StringObjectPropertyType, 1025 'Phone_Number': cybox_common.StringObjectPropertyType, 1026 'Fuzzy_Hash_Structure': cybox_common.FuzzyHashStructureType, 1027 'SubDatum': cybox_common.MetadataType, 1028 'Segment_Hash': cybox_common.HashValueType, 1029 'Digital_Signature': cybox_common.DigitalSignatureInfoType, 1030 'Code_Snippets': cybox_common.CodeSnippetsType, 1031 'URI': uri_object.URIObjectType, 1032 'Value': cybox_common.AnyURIObjectPropertyType, 1033 'Length': cybox_common.IntegerObjectPropertyType, 1034 'Certificate_Subject': cybox_common.StringObjectPropertyType, 1035 'Encoding': cybox_common.ControlledVocabularyStringType, 1036 'Block_Hash_Value': cybox_common.HashValueType, 1037 'Internationalization_Settings': cybox_common.InternationalizationSettingsType, 1038 'Image_Offset': cybox_common.IntegerObjectPropertyType, 1039 'Referral_URL': uri_object.URIObjectType, 1040 'Registrar_GUID': cybox_common.StringObjectPropertyType, 1041 'English_Translation': cybox_common.StringObjectPropertyType, 1042 'Registrant_ID': cybox_common.StringObjectPropertyType, 1043 'Functions': cybox_common.FunctionsType, 1044 'String_Value': cybox_common.StringObjectPropertyType, 1045 'Build_Utility_Platform_Specification': cybox_common.PlatformSpecificationType, 1046 'Compiler_Informal_Description': cybox_common.CompilerInformalDescriptionType, 1047 'System': cybox_common.ObjectPropertiesType, 1048 'Platform': cybox_common.PlatformSpecificationType, 1049 'Usage_Context_Assumptions': cybox_common.UsageContextAssumptionsType, 1050 'Type': cybox_common.ControlledVocabularyStringType, 1051 'Compilers': cybox_common.CompilersType, 1052 'Tool_Type': cybox_common.ControlledVocabularyStringType, 1053 'String': cybox_common.ExtractedStringType, 1054 'Tool': cybox_common.ToolInformationType, 1055 'Build_Information': cybox_common.BuildInformationType, 1056 'Tool_Hashes': cybox_common.HashListType, 1057 'IP_Address': address_object.AddressObjectType, 1058 'Error_Instances': cybox_common.ErrorInstancesType, 1059 'Data_Segment': cybox_common.StringObjectPropertyType, 1060 'Simple_Hash_Value': cybox_common.SimpleHashValueType, 1061 'Property': cybox_common.PropertyType, 1062 'Strings': cybox_common.ExtractedStringsType, 1063 'Tool_Specific_Data': cybox_common.ToolSpecificDataType, 1064 'Contributors': cybox_common.PersonnelType, 1065 'Expiration_Date': cybox_common.DateObjectPropertyType, 1066 'Reference_Description': cybox_common.StructuredTextType, 1067 'Usage_Context_Assumption': cybox_common.StructuredTextType, 1068 'User_Account_Info': cybox_common.ObjectPropertiesType, 1069 'Configuration_Settings': cybox_common.ConfigurationSettingsType, 1070 'Compiler_Platform_Specification': cybox_common.PlatformSpecificationType, 1071 'Byte_String_Value': cybox_common.HexBinaryObjectPropertyType, 1072 'Instance': cybox_common.ObjectPropertiesType, 1073 'Import': cybox_common.StringObjectPropertyType, 1074 'Identifier': cybox_common.PlatformIdentifierType, 1075 'Server_Name': uri_object.URIObjectType, 1076 'Execution_Environment': cybox_common.ExecutionEnvironmentType, 1077 'Domain_Name': uri_object.URIObjectType, 1078 'Search_Distance': cybox_common.IntegerObjectPropertyType, 1079 'Dependencies': cybox_common.DependenciesType, 1080 'Segment_Count': cybox_common.IntegerObjectPropertyType, 1081 'Offset': cybox_common.IntegerObjectPropertyType, 1082 'Date': cybox_common.DateRangeType, 1083 'Hashes': cybox_common.HashListType, 1084 'Segments': cybox_common.HashSegmentsType, 1085 'Language': cybox_common.StringObjectPropertyType, 1086 'Creation_Date': cybox_common.DateObjectPropertyType, 1087 'Block_Hash': cybox_common.FuzzyHashBlockType, 1088 'Dependency': cybox_common.DependencyType, 1089 'Contact_ID': cybox_common.StringObjectPropertyType, 1090 'Error': cybox_common.ErrorType, 1091 'Nameserver': uri_object.URIObjectType, 1092 'Trigger_Point': cybox_common.HexBinaryObjectPropertyType, 1093 'Environment_Variable': cybox_common.EnvironmentVariableType, 1094 'Byte_Run': cybox_common.ByteRunType, 1095 'File_System_Offset': cybox_common.IntegerObjectPropertyType, 1096 'Tool_Configuration': cybox_common.ToolConfigurationType, 1097 'Imports': cybox_common.ImportsType, 1098 'Library': cybox_common.LibraryType, 1099 'References': cybox_common.ToolReferencesType, 1100 'Sponsoring_Registrar': cybox_common.StringObjectPropertyType, 1101 'Internal_Strings': cybox_common.InternalStringsType, 1102 'Configuration_Setting': cybox_common.ConfigurationSettingType, 1103 'Data_Size': cybox_common.DataSizeType, 1104 'Libraries': cybox_common.LibrariesType, 1105 'Whois_Server': uri_object.URIObjectType, 1106 'Function': cybox_common.StringObjectPropertyType, 1107 'Description': cybox_common.StructuredTextType, 1108 'Code_Snippet': cybox_common.ObjectPropertiesType, 1109 'Build_Configuration': cybox_common.BuildConfigurationType, 1110 'VLAN_Name': cybox_common.StringObjectPropertyType, 1111 'Address': address_object.AddressObjectType, 1112 'Search_Within': cybox_common.IntegerObjectPropertyType, 1113 'Segment': cybox_common.HashSegmentType, 1114 'Compiler': cybox_common.CompilerType, 1115 'Updated_Date': cybox_common.DateObjectPropertyType, 1116 'Name': cybox_common.StringObjectPropertyType, 1117 'Address_Value': cybox_common.StringObjectPropertyType, 1118 'VLAN_Num': cybox_common.IntegerObjectPropertyType, 1119 'Signature_Description': cybox_common.StringObjectPropertyType, 1120 'Block_Size': cybox_common.IntegerObjectPropertyType, 1121 'Fuzzy_Hash_Value': cybox_common.FuzzyHashValueType, 1122 'Dependency_Description': cybox_common.StructuredTextType, 1123 'Contributor': cybox_common.ContributorType, 1124 'Registrar_ID': cybox_common.StringObjectPropertyType, 1125 'Tools': cybox_common.ToolsInformationType, 1126 'Custom_Properties': cybox_common.CustomPropertiesType, 1127} 1128 1129USAGE_TEXT = """ 1130Usage: python <Parser>.py [ -s ] <in_xml_file> 1131""" 1132 1133def usage(): 1134 print(USAGE_TEXT) 1135 sys.exit(1) 1136 1137def get_root_tag(node): 1138 tag = Tag_pattern_.match(node.tag).groups()[-1] 1139 rootClass = GDSClassesMapping.get(tag) 1140 if rootClass is None: 1141 rootClass = globals().get(tag) 1142 return tag, rootClass 1143 1144def parse(inFileName): 1145 doc = parsexml_(inFileName) 1146 rootNode = doc.getroot() 1147 rootTag, rootClass = get_root_tag(rootNode) 1148 if rootClass is None: 1149 rootTag = 'Whois_Entry' 1150 rootClass = WhoisObjectType 1151 rootObj = rootClass.factory() 1152 rootObj.build(rootNode) 1153 # Enable Python to collect the space used by the DOM. 1154 doc = None 1155# sys.stdout.write('<?xml version="1.0" ?>\n') 1156# rootObj.export(sys.stdout.write, 0, name_=rootTag, 1157# namespacedef_='', 1158# pretty_print=True) 1159 return rootObj 1160 1161def parseEtree(inFileName): 1162 doc = parsexml_(inFileName) 1163 rootNode = doc.getroot() 1164 rootTag, rootClass = get_root_tag(rootNode) 1165 if rootClass is None: 1166 rootTag = 'Whois_Entry' 1167 rootClass = WhoisObjectType 1168 rootObj = rootClass.factory() 1169 rootObj.build(rootNode) 1170 # Enable Python to collect the space used by the DOM. 1171 doc = None 1172 rootElement = rootObj.to_etree(None, name_=rootTag) 1173 content = etree_.tostring(rootElement, pretty_print=True, 1174 xml_declaration=True, encoding="utf-8") 1175 sys.stdout.write(content) 1176 sys.stdout.write('\n') 1177 return rootObj, rootElement 1178 1179def parseString(inString): 1180 from mixbox.vendor.six import StringIO 1181 doc = parsexml_(StringIO(inString)) 1182 rootNode = doc.getroot() 1183 rootTag, rootClass = get_root_tag(rootNode) 1184 if rootClass is None: 1185 rootTag = 'Whois_Entry' 1186 rootClass = WhoisObjectType 1187 rootObj = rootClass.factory() 1188 rootObj.build(rootNode) 1189 # Enable Python to collect the space used by the DOM. 1190 doc = None 1191# sys.stdout.write('<?xml version="1.0" ?>\n') 1192# rootObj.export(sys.stdout.write, 0, name_="Whois_Entry", 1193# namespacedef_='') 1194 return rootObj 1195 1196def main(): 1197 args = sys.argv[1:] 1198 if len(args) == 1: 1199 parse(args[0]) 1200 else: 1201 usage() 1202 1203if __name__ == '__main__': 1204 #import pdb; pdb.set_trace() 1205 main() 1206 1207__all__ = [ 1208 "WhoisObjectType", 1209 "WhoisRegistrarInfoType", 1210 "WhoisContactsType", 1211 "WhoisContactType", 1212 "WhoisStatusType", 1213 "WhoisStatusesType", 1214 "WhoisNameserversType", 1215 "WhoisRegistrantInfoType", 1216 "WhoisRegistrantsType", 1217 "RegionalRegistryType" 1218 ] 1219