You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#!/usr/bin/env python# Copyright (c) 2014, The MITRE Corporation. All rights reserved.# See LICENSE.txt for complete terms.'''Description: Round-trip example. This script takes a STIX instance document from XML toa binding object, then to a api object and then to a dictionary. That dictionary is thenconverted back into an api object, which is then used to generate an XML document.'''importiofrompprintimportpprintfromstix.coreimportSTIXPackagefromstix.indicatorimportIndicatorimportstix.bindings.stix_coreasstix_core_bindingdefmain():
fn='input.xml'stix_package=STIXPackage.from_xml(fn)
stix_dict=stix_package.to_dict() # parse to dictionarypprint(stix_dict)
stix_package_two=STIXPackage.from_dict(stix_dict) # create python-stix object from dictionaryxml=stix_package_two.to_xml() # generate xml from python-stix objectprint(xml)
if__name__=='__main__':
main()
Under what cases do you anticipate needing to use non-integer values for Port_Value?
The default datatype value is integer. I forget whether we actually implemented logic that checks for non-default data types and parses the value differently.
I think it makes sense to try to do the int conversion, but if it fails, store the value as a string rather than raising a cryptic ValueError to the user.
In this example the API tries to cast portObj/port_value as a number rather than leave it as a string.
input.xml
script.py
error
The text was updated successfully, but these errors were encountered: