()
| 18 | |
| 19 | |
| 20 | def main(): |
| 21 | # Create a new STIXPackage |
| 22 | stix_package = STIXPackage() |
| 23 | |
| 24 | # Create a new STIXHeader |
| 25 | stix_header = STIXHeader() |
| 26 | |
| 27 | # Add Information Source. This is where we will add the tool information. |
| 28 | stix_header.information_source = InformationSource() |
| 29 | |
| 30 | # Create a ToolInformation object. Use the initialization parameters |
| 31 | # to set the tool and vendor names. |
| 32 | # |
| 33 | # Note: This is an instance of cybox.common.ToolInformation and NOT |
| 34 | # stix.common.ToolInformation. |
| 35 | tool = ToolInformation( |
| 36 | tool_name="python-stix", |
| 37 | tool_vendor="The MITRE Corporation" |
| 38 | ) |
| 39 | |
| 40 | # Set the Information Source "tools" section to a |
| 41 | # cybox.common.ToolInformationList which contains our tool that we |
| 42 | # created above. |
| 43 | stix_header.information_source.tools = ToolInformationList(tool) |
| 44 | |
| 45 | # Set the header description |
| 46 | stix_header.description = "Example" |
| 47 | |
| 48 | # Set the STIXPackage header |
| 49 | stix_package.stix_header = stix_header |
| 50 | |
| 51 | # Print the XML! |
| 52 | print(stix_package.to_xml()) |
| 53 | |
| 54 | # Print the dictionary! |
| 55 | pprint(stix_package.to_dict()) |
| 56 | |
| 57 | |
| 58 | if __name__ == '__main__': |
no test coverage detected