diff --git a/stix2/test/test_versioning.py b/stix2/test/test_versioning.py index dcbd3d3..233587e 100644 --- a/stix2/test/test_versioning.py +++ b/stix2/test/test_versioning.py @@ -223,8 +223,8 @@ def test_remove_custom_stix_property(): mal_nc = stix2.utils.remove_custom_stix(mal) assert "x_custom" not in mal_nc - assert stix2.utils.parse_into_datetime(mal["modified"], precision="microsecond") < stix2.utils.parse_into_datetime(mal_nc["modified"], - precision="microsecond") + assert stix2.utils.parse_into_datetime(mal["modified"], precision="millisecond") < stix2.utils.parse_into_datetime(mal_nc["modified"], + precision="millisecond") def test_remove_custom_stix_object(): diff --git a/stix2/utils.py b/stix2/utils.py index 3129a5c..701fe56 100644 --- a/stix2/utils.py +++ b/stix2/utils.py @@ -303,7 +303,14 @@ def remove_custom_stix(stix_obj): # add to set the custom properties we want to get rid of (with their value=None) props.extend(custom_props) - return new_version(stix_obj, **(dict(props))) + new_obj = new_version(stix_obj, **(dict(props))) + + while parse_into_datetime(new_obj["modified"]) == parse_into_datetime(stix_obj["modified"]): + # Prevents bug when fast computation allows multiple STIX object + # versions to be created in single unit of time + new_obj = new_version(stix_obj, **(dict(props))) + + return new_obj else: return stix_obj