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

Function main

examples/creation_tool_metadata.py:20–55  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18
19
20def 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
58if __name__ == '__main__':

Callers 1

Calls 6

STIXPackageClass · 0.90
STIXHeaderClass · 0.90
InformationSourceClass · 0.90
ToolInformationClass · 0.90
to_xmlMethod · 0.45
to_dictMethod · 0.45

Tested by

no test coverage detected