Version: 1.2.0

ramrod.stix.stix_1_1_1 Module

class ramrod.stix.stix_1_1_1.STIX_1_1_1_Updater

Updates STIX v1.1.1 content to STIX v1.2.

The following update operations are performed:

  • Instances of DiscoveryMethodTypeVocab-1.0 are upgraded to DiscoveryMethodTypeVocab-2.0.
  • Component versions are updated.
  • Schemalocations are updated.
check_update(root, options=None)

Determines if the input document can be upgraded.

Parameters:
  • root – The XML document. This can be a filename, a file-like object, an instance of etree._Element or an instance of etree._ElementTree.
  • options (optional) – A ramrod.UpdateOptions instance. If None, ramrod.DEFAULT_UPDATE_OPTIONS will be used.
Raises:
get_version(package)

Returns the version of the package STIX_Package element by inspecting its version attribute.

update(root, options=None, force=False)

Attempts to update root to the next version of its language specification.

If force is set to True, items may be removed during the translation process and IDs may be reassigned if they are not unique within the document.

Note

This does not remap idref attributes to new ID values because it is impossible to determine which entity the idref was pointing to.

Removed items can be retrieved via the removed attribute on the return value:

>>> results = updater.update(root, force=True)
>>> print(results.removed)
(<Element at 0xffdcf234>, <Element at 0xffdcf284>)

Items which have been reassigned IDs can be retrieved via the remappped_ids attribute on the return value:

>>> results = updater.update(root, force=True)
>>> print(results.remapped_ids)
{'example:Observable-duplicate-id-1': [<Element {http://cybox.mitre...
Parameters:
  • root – The XML document. This can be a filename, a file-like object, an instance of etree._Element or an instance of etree._ElementTree.
  • options – A ramrod.UpdateOptions instance. If None, ramrod.DEFAULT_UPDATE_OPTIONS will be used.
  • force – Forces the update process to complete by potentially removing untranslatable xml nodes and/or remapping non-unique IDs. This may result in non-schema=conformant XML. USE AT YOUR OWN RISK!
Returns:

An instance of ramrod.UpdateResults.

Raises:
  • UpdateError – If untranslatable fields or non-unique IDs are discovered in root and force is False.
  • UnknownVersionError – If the root node contains no version information.
  • InvalidVersionError – If the root node contains invalid version information (e.g., the class expects v1.0 content and the root node contains v1.1 content).