From a002c1736d2fdf54064823ab3fccf261157e4ac0 Mon Sep 17 00:00:00 2001 From: Chris Lenk Date: Wed, 14 Apr 2021 16:39:56 -0400 Subject: [PATCH] Update guide docs, remove outdated comments --- docs/guide/extensions.ipynb | 6 +- docs/guide/markings.ipynb | 571 ++++++++++++++++++++--------------- docs/guide/patterns.ipynb | 4 +- docs/guide/serializing.ipynb | 2 +- stix2/base.py | 4 +- stix2/parsing.py | 9 +- stix2/registry.py | 4 - 7 files changed, 340 insertions(+), 260 deletions(-) diff --git a/docs/guide/extensions.ipynb b/docs/guide/extensions.ipynb index 817b08a..9dcbdb2 100644 --- a/docs/guide/extensions.ipynb +++ b/docs/guide/extensions.ipynb @@ -59,7 +59,7 @@ "source": [ "## STIX Extensions\n", "\n", - "This page is specific for the STIX Extensions mechanism defined in STIX 2.1 CS 02, for the deprecated STIX Customization mechanisms see the [Custom](custom.ipynb) section.\n", + "This page is specific for the STIX Extensions mechanism defined in STIX 2.1 CS 02. For the deprecated STIX Customization mechanisms see the [Custom](custom.ipynb) section.\n", "\n", "### Top Level Property Extensions\n", "\n", @@ -336,7 +336,7 @@ "source": [ "### Using CustomExtension decorator\n", "\n", - "However, in order to prevent repetitive instantiation of the same extension, the `@CustomExtension` when used in a class for registering the `extension-definition` with stix2, it allows passing the id. Use the `extension_type` class variable to define what kind of extension it is." + "However, in order to prevent repetitive instantiation of the same extension, the `@CustomExtension` decorator can be used to register the `extension-definition` with stix2. Use the `extension_type` class variable to define what kind of extension it is. Then its id can be passed into objects that use this extension." ] }, { @@ -922,7 +922,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.7" + "version": "3.9.2" } }, "nbformat": 4, diff --git a/docs/guide/markings.ipynb b/docs/guide/markings.ipynb index 942f629..5bc1215 100644 --- a/docs/guide/markings.ipynb +++ b/docs/guide/markings.ipynb @@ -77,8 +77,13 @@ { "data": { "text/html": [ - "
{\n",
        "    "type": "indicator",\n",
        "    "spec_version": "2.1",\n",
-       "    "id": "indicator--46498844-7689-4e7b-be25-b119d8401159",\n",
-       "    "created": "2020-06-24T20:55:56.088861Z",\n",
-       "    "modified": "2020-06-24T20:55:56.088861Z",\n",
+       "    "id": "indicator--a315ce0b-1211-478e-812a-cd6d3eecc3c1",\n",
+       "    "created": "2021-04-09T13:59:48.911595Z",\n",
+       "    "modified": "2021-04-09T13:59:48.911595Z",\n",
        "    "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
        "    "pattern_type": "stix",\n",
        "    "pattern_version": "2.1",\n",
-       "    "valid_from": "2020-06-24T20:55:56.088861Z",\n",
+       "    "valid_from": "2021-04-09T13:59:48.911595Z",\n",
        "    "object_marking_refs": [\n",
        "        "marking-definition--f88d31f6-486f-44da-b317-01333bde0b82"\n",
        "    ]\n",
@@ -194,8 +199,13 @@
     {
      "data": {
       "text/html": [
-       "
{\n",
        "    "type": "marking-definition",\n",
        "    "spec_version": "2.1",\n",
-       "    "id": "marking-definition--9a4efc30-a7ac-42d0-8776-16f390a0fd44",\n",
-       "    "created": "2020-06-24T20:56:06.779241Z",\n",
+       "    "id": "marking-definition--4b8e86b5-d505-46a4-91b4-a8db17f4ff4d",\n",
+       "    "created": "2021-04-09T13:59:50.587649Z",\n",
        "    "definition_type": "statement",\n",
        "    "definition": {\n",
        "        "statement": "Copyright 2017, Example Corp"\n",
@@ -308,8 +318,13 @@
     {
      "data": {
       "text/html": [
-       "
{\n",
        "    "type": "indicator",\n",
        "    "spec_version": "2.1",\n",
-       "    "id": "indicator--75d66696-9960-4229-ba89-2caac50891b3",\n",
-       "    "created": "2020-06-24T20:56:29.80259Z",\n",
-       "    "modified": "2020-06-24T20:56:29.80259Z",\n",
+       "    "id": "indicator--91ed23a6-c5f0-4b16-8369-64cf39f974bf",\n",
+       "    "created": "2021-04-09T13:59:52.602254Z",\n",
+       "    "modified": "2021-04-09T13:59:52.602254Z",\n",
        "    "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
        "    "pattern_type": "stix",\n",
        "    "pattern_version": "2.1",\n",
-       "    "valid_from": "2020-06-24T20:56:29.80259Z",\n",
+       "    "valid_from": "2021-04-09T13:59:52.602254Z",\n",
        "    "object_marking_refs": [\n",
-       "        "marking-definition--9a4efc30-a7ac-42d0-8776-16f390a0fd44"\n",
+       "        "marking-definition--4b8e86b5-d505-46a4-91b4-a8db17f4ff4d"\n",
        "    ]\n",
        "}\n",
        "
\n" @@ -416,8 +431,13 @@ { "data": { "text/html": [ - "
{\n",
        "    "type": "indicator",\n",
        "    "spec_version": "2.1",\n",
-       "    "id": "indicator--757ea853-138c-44e2-bb00-e78eebfaa378",\n",
-       "    "created": "2020-06-24T20:56:43.703563Z",\n",
-       "    "modified": "2020-06-24T20:56:43.703563Z",\n",
+       "    "id": "indicator--42ae262e-4839-4c1a-a50a-3a6690623a9d",\n",
+       "    "created": "2021-04-09T13:59:54.207797Z",\n",
+       "    "modified": "2021-04-09T13:59:54.207797Z",\n",
        "    "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
        "    "pattern_type": "stix",\n",
        "    "pattern_version": "2.1",\n",
-       "    "valid_from": "2020-06-24T20:56:43.703563Z",\n",
+       "    "valid_from": "2021-04-09T13:59:54.207797Z",\n",
        "    "object_marking_refs": [\n",
        "        "marking-definition--f88d31f6-486f-44da-b317-01333bde0b82"\n",
        "    ]\n",
@@ -525,14 +545,19 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 8,
+   "execution_count": 7,
    "metadata": {},
    "outputs": [
     {
      "data": {
       "text/html": [
-       "
{\n",
        "    "type": "malware",\n",
        "    "spec_version": "2.1",\n",
-       "    "id": "malware--1752bbec-765a-4711-a304-f0e92ca902ae",\n",
-       "    "created": "2020-06-24T21:21:07.148194Z",\n",
-       "    "modified": "2020-06-24T21:21:07.148194Z",\n",
+       "    "id": "malware--2658ac6a-44e9-44ea-8c8a-d67abae4d0d5",\n",
+       "    "created": "2021-04-09T13:59:56.556801Z",\n",
+       "    "modified": "2021-04-09T13:59:56.556801Z",\n",
        "    "name": "Poison Ivy",\n",
        "    "description": "A ransomware related to ...",\n",
        "    "is_family": false,\n",
        "    "granular_markings": [\n",
        "        {\n",
-       "            "marking_ref": "marking-definition--9a4efc30-a7ac-42d0-8776-16f390a0fd44",\n",
+       "            "marking_ref": "marking-definition--4b8e86b5-d505-46a4-91b4-a8db17f4ff4d",\n",
        "            "selectors": [\n",
        "                "description"\n",
        "            ]\n",
@@ -629,7 +654,7 @@
        ""
       ]
      },
-     "execution_count": 8,
+     "execution_count": 7,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -662,7 +687,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 9,
+   "execution_count": 8,
    "metadata": {},
    "outputs": [
     {
@@ -706,14 +731,19 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 10,
+   "execution_count": 9,
    "metadata": {},
    "outputs": [
     {
      "data": {
       "text/html": [
-       "
{\n",
        "    "type": "indicator",\n",
        "    "spec_version": "2.1",\n",
-       "    "id": "indicator--46498844-7689-4e7b-be25-b119d8401159",\n",
-       "    "created": "2020-06-24T20:55:56.088861Z",\n",
-       "    "modified": "2020-06-24T21:21:39.898475Z",\n",
+       "    "id": "indicator--a315ce0b-1211-478e-812a-cd6d3eecc3c1",\n",
+       "    "created": "2021-04-09T13:59:48.911595Z",\n",
+       "    "modified": "2021-04-09T14:00:01.165749Z",\n",
        "    "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
        "    "pattern_type": "stix",\n",
        "    "pattern_version": "2.1",\n",
-       "    "valid_from": "2020-06-24T20:55:56.088861Z",\n",
+       "    "valid_from": "2021-04-09T13:59:48.911595Z",\n",
        "    "object_marking_refs": [\n",
-       "        "marking-definition--f88d31f6-486f-44da-b317-01333bde0b82",\n",
-       "        "marking-definition--9a4efc30-a7ac-42d0-8776-16f390a0fd44"\n",
+       "        "marking-definition--4b8e86b5-d505-46a4-91b4-a8db17f4ff4d",\n",
+       "        "marking-definition--f88d31f6-486f-44da-b317-01333bde0b82"\n",
        "    ]\n",
        "}\n",
        "
\n" @@ -801,7 +831,7 @@ "" ] }, - "execution_count": 10, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -820,14 +850,19 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
{\n",
        "    "type": "indicator",\n",
        "    "spec_version": "2.1",\n",
-       "    "id": "indicator--46498844-7689-4e7b-be25-b119d8401159",\n",
-       "    "created": "2020-06-24T20:55:56.088861Z",\n",
-       "    "modified": "2020-06-24T21:21:43.529702Z",\n",
+       "    "id": "indicator--a315ce0b-1211-478e-812a-cd6d3eecc3c1",\n",
+       "    "created": "2021-04-09T13:59:48.911595Z",\n",
+       "    "modified": "2021-04-09T14:00:03.00911Z",\n",
        "    "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
        "    "pattern_type": "stix",\n",
        "    "pattern_version": "2.1",\n",
-       "    "valid_from": "2020-06-24T20:55:56.088861Z",\n",
+       "    "valid_from": "2021-04-09T13:59:48.911595Z",\n",
        "    "object_marking_refs": [\n",
        "        "marking-definition--f88d31f6-486f-44da-b317-01333bde0b82"\n",
        "    ]\n",
@@ -914,21 +949,142 @@
        ""
       ]
      },
+     "execution_count": 10,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "indicator5 = indicator4.remove_markings(marking_definition)\n",
+    "print(indicator5.serialize(pretty=True))"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "The markings on an object can be replaced with a different set of markings:"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 11,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/html": [
+       "
{\n",
+       "    "type": "indicator",\n",
+       "    "spec_version": "2.1",\n",
+       "    "id": "indicator--a315ce0b-1211-478e-812a-cd6d3eecc3c1",\n",
+       "    "created": "2021-04-09T13:59:48.911595Z",\n",
+       "    "modified": "2021-04-09T14:00:04.531083Z",\n",
+       "    "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
+       "    "pattern_type": "stix",\n",
+       "    "pattern_version": "2.1",\n",
+       "    "valid_from": "2021-04-09T13:59:48.911595Z",\n",
+       "    "object_marking_refs": [\n",
+       "        "marking-definition--34098fce-860f-48ae-8e50-ebd3cc5e41da",\n",
+       "        "marking-definition--4b8e86b5-d505-46a4-91b4-a8db17f4ff4d"\n",
+       "    ]\n",
+       "}\n",
+       "
\n" + ], + "text/plain": [ + "" + ] + }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "indicator5 = indicator4.remove_markings(marking_definition)\n", - "print(indicator5)" + "from stix2 import TLP_GREEN\n", + "\n", + "indicator6 = indicator5.set_markings([TLP_GREEN, marking_definition])\n", + "print(indicator6.serialize(pretty=True))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "The markings on an object can be replaced with a different set of markings:" + "STIX objects can also be cleared of all markings with [clear_markings()](../api/stix2.markings.rst#stix2.markings.clear_markings):" ] }, { @@ -939,8 +1095,13 @@ { "data": { "text/html": [ - "
{\n",
        "    "type": "indicator",\n",
        "    "spec_version": "2.1",\n",
-       "    "id": "indicator--46498844-7689-4e7b-be25-b119d8401159",\n",
-       "    "created": "2020-06-24T20:55:56.088861Z",\n",
-       "    "modified": "2020-06-24T21:21:47.703212Z",\n",
+       "    "id": "indicator--a315ce0b-1211-478e-812a-cd6d3eecc3c1",\n",
+       "    "created": "2021-04-09T13:59:48.911595Z",\n",
+       "    "modified": "2021-04-09T14:00:06.512465Z",\n",
        "    "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
        "    "pattern_type": "stix",\n",
        "    "pattern_version": "2.1",\n",
-       "    "valid_from": "2020-06-24T20:55:56.088861Z",\n",
-       "    "object_marking_refs": [\n",
-       "        "marking-definition--9a4efc30-a7ac-42d0-8776-16f390a0fd44",\n",
-       "        "marking-definition--34098fce-860f-48ae-8e50-ebd3cc5e41da"\n",
-       "    ]\n",
+       "    "valid_from": "2021-04-09T13:59:48.911595Z"\n",
        "}\n",
        "
\n" ], @@ -1033,121 +1190,9 @@ "output_type": "execute_result" } ], - "source": [ - "from stix2 import TLP_GREEN\n", - "\n", - "indicator6 = indicator5.set_markings([TLP_GREEN, marking_definition])\n", - "print(indicator6)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "STIX objects can also be cleared of all markings with [clear_markings()](../api/stix2.markings.rst#stix2.markings.clear_markings):" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
{\n",
-       "    "type": "indicator",\n",
-       "    "spec_version": "2.1",\n",
-       "    "id": "indicator--46498844-7689-4e7b-be25-b119d8401159",\n",
-       "    "created": "2020-06-24T20:55:56.088861Z",\n",
-       "    "modified": "2020-06-24T21:21:53.287178Z",\n",
-       "    "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
-       "    "pattern_type": "stix",\n",
-       "    "pattern_version": "2.1",\n",
-       "    "valid_from": "2020-06-24T20:55:56.088861Z"\n",
-       "}\n",
-       "
\n" - ], - "text/plain": [ - "" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" - } - ], "source": [ "indicator7 = indicator5.clear_markings()\n", - "print(indicator7)" + "print(indicator7.serialize(pretty=True))" ] }, { @@ -1168,17 +1213,17 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "['marking-definition--9a4efc30-a7ac-42d0-8776-16f390a0fd44',\n", - " 'marking-definition--34098fce-860f-48ae-8e50-ebd3cc5e41da']" + "['marking-definition--34098fce-860f-48ae-8e50-ebd3cc5e41da',\n", + " 'marking-definition--4b8e86b5-d505-46a4-91b4-a8db17f4ff4d']" ] }, - "execution_count": 14, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -1196,7 +1241,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 14, "metadata": {}, "outputs": [ { @@ -1205,7 +1250,7 @@ "['marking-definition--613f2e26-407d-48c7-9eca-b8e91df99dc9']" ] }, - "execution_count": 15, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -1225,7 +1270,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 15, "metadata": {}, "outputs": [ { @@ -1234,7 +1279,7 @@ "['marking-definition--613f2e26-407d-48c7-9eca-b8e91df99dc9']" ] }, - "execution_count": 16, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -1250,6 +1295,26 @@ "Finally, you may also check if an object is marked by a specific markings. Again, for granular markings, pass in the selector or list of selectors." ] }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "indicator.is_marked(TLP_AMBER.id)" + ] + }, { "cell_type": "code", "execution_count": 17, @@ -1266,33 +1331,13 @@ "output_type": "execute_result" } ], - "source": [ - "indicator.is_marked(TLP_AMBER.id)" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": 18, - "metadata": {}, - "output_type": "execute_result" - } - ], "source": [ "malware.is_marked(TLP_WHITE.id, 'name')" ] }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 18, "metadata": { "scrolled": true }, @@ -1303,7 +1348,7 @@ "False" ] }, - "execution_count": 19, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -1323,14 +1368,19 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
{\n",
        "    "type": "indicator",\n",
        "    "spec_version": "2.1",\n",
-       "    "id": "indicator--f4004de9-a6d9-4c7b-823e-3d8199173c09",\n",
-       "    "created": "2020-06-24T21:35:08.630228Z",\n",
-       "    "modified": "2020-06-24T21:35:08.630228Z",\n",
+       "    "id": "indicator--a2fd263a-ec46-4fff-84af-27419f0b9f15",\n",
+       "    "created": "2021-04-09T14:02:31.991141Z",\n",
+       "    "modified": "2021-04-09T14:02:31.991141Z",\n",
        "    "description": "Una descripcion sobre este indicador",\n",
        "    "indicator_types": [\n",
        "        "malware"\n",
@@ -1410,7 +1460,7 @@
        "    "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
        "    "pattern_type": "stix",\n",
        "    "pattern_version": "2.1",\n",
-       "    "valid_from": "2020-06-24T21:35:08.630228Z",\n",
+       "    "valid_from": "2021-04-09T14:02:31.991141Z",\n",
        "    "object_marking_refs": [\n",
        "        "marking-definition--f88d31f6-486f-44da-b317-01333bde0b82"\n",
        "    ],\n",
@@ -1435,15 +1485,20 @@
        ""
       ]
      },
-     "execution_count": 20,
+     "execution_count": 19,
      "metadata": {},
      "output_type": "execute_result"
     },
     {
      "data": {
       "text/html": [
-       "
{\n",
        "    "type": "indicator",\n",
        "    "spec_version": "2.1",\n",
-       "    "id": "indicator--f4004de9-a6d9-4c7b-823e-3d8199173c09",\n",
-       "    "created": "2020-06-24T21:35:08.630228Z",\n",
-       "    "modified": "2020-06-24T21:35:14.54482Z",\n",
+       "    "id": "indicator--a2fd263a-ec46-4fff-84af-27419f0b9f15",\n",
+       "    "created": "2021-04-09T14:02:31.991141Z",\n",
+       "    "modified": "2021-04-09T14:03:11.817032Z",\n",
        "    "description": "Una descripcion sobre este indicador",\n",
        "    "indicator_types": [\n",
        "        "malware"\n",
@@ -1814,7 +1884,7 @@
        "    "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
        "    "pattern_type": "stix",\n",
        "    "pattern_version": "2.1",\n",
-       "    "valid_from": "2020-06-24T21:35:08.630228Z",\n",
+       "    "valid_from": "2021-04-09T14:02:31.991141Z",\n",
        "    "object_marking_refs": [\n",
        "        "marking-definition--f88d31f6-486f-44da-b317-01333bde0b82"\n",
        "    ]\n",
@@ -1831,7 +1901,8 @@
     }
    ],
    "source": [
-    "print(v21_indicator.clear_markings(\"description\"))  # By default, both types of markings will be removed"
+    "# By default, both types of markings will be removed\n",
+    "print(v21_indicator.clear_markings(\"description\").serialize(pretty=True))"
    ]
   },
   {
@@ -1842,8 +1913,13 @@
     {
      "data": {
       "text/html": [
-       "
{\n",
        "    "type": "indicator",\n",
        "    "spec_version": "2.1",\n",
-       "    "id": "indicator--f4004de9-a6d9-4c7b-823e-3d8199173c09",\n",
-       "    "created": "2020-06-24T21:35:08.630228Z",\n",
-       "    "modified": "2020-06-24T21:35:39.298138Z",\n",
+       "    "id": "indicator--a2fd263a-ec46-4fff-84af-27419f0b9f15",\n",
+       "    "created": "2021-04-09T14:02:31.991141Z",\n",
+       "    "modified": "2021-04-09T14:03:24.701927Z",\n",
        "    "description": "Una descripcion sobre este indicador",\n",
        "    "indicator_types": [\n",
        "        "malware"\n",
@@ -1923,7 +1999,7 @@
        "    "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
        "    "pattern_type": "stix",\n",
        "    "pattern_version": "2.1",\n",
-       "    "valid_from": "2020-06-24T21:35:08.630228Z",\n",
+       "    "valid_from": "2021-04-09T14:02:31.991141Z",\n",
        "    "object_marking_refs": [\n",
        "        "marking-definition--f88d31f6-486f-44da-b317-01333bde0b82"\n",
        "    ],\n",
@@ -1949,7 +2025,7 @@
    ],
    "source": [
     "# If lang is False, no lang markings will be removed\n",
-    "print(v21_indicator.clear_markings(\"description\", lang=False))"
+    "print(v21_indicator.clear_markings(\"description\", lang=False).serialize(pretty=True))"
    ]
   },
   {
@@ -1960,8 +2036,13 @@
     {
      "data": {
       "text/html": [
-       "
{\n",
        "    "type": "indicator",\n",
        "    "spec_version": "2.1",\n",
-       "    "id": "indicator--f4004de9-a6d9-4c7b-823e-3d8199173c09",\n",
-       "    "created": "2020-06-24T21:35:08.630228Z",\n",
-       "    "modified": "2020-06-24T21:35:42.684794Z",\n",
+       "    "id": "indicator--a2fd263a-ec46-4fff-84af-27419f0b9f15",\n",
+       "    "created": "2021-04-09T14:02:31.991141Z",\n",
+       "    "modified": "2021-04-09T14:03:29.751985Z",\n",
        "    "description": "Una descripcion sobre este indicador",\n",
        "    "indicator_types": [\n",
        "        "malware"\n",
@@ -2041,7 +2122,7 @@
        "    "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
        "    "pattern_type": "stix",\n",
        "    "pattern_version": "2.1",\n",
-       "    "valid_from": "2020-06-24T21:35:08.630228Z",\n",
+       "    "valid_from": "2021-04-09T14:02:31.991141Z",\n",
        "    "object_marking_refs": [\n",
        "        "marking-definition--f88d31f6-486f-44da-b317-01333bde0b82"\n",
        "    ],\n",
@@ -2067,7 +2148,7 @@
    ],
    "source": [
     "# If marking_ref is False, no marking-definition markings will be removed\n",
-    "print(v21_indicator.clear_markings(\"description\", marking_ref=False))"
+    "print(v21_indicator.clear_markings(\"description\", marking_ref=False).serialize(pretty=True))"
    ]
   }
  ],
@@ -2087,7 +2168,7 @@
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
-   "version": "3.9.0a6"
+   "version": "3.9.2"
   }
  },
  "nbformat": 4,
diff --git a/docs/guide/patterns.ipynb b/docs/guide/patterns.ipynb
index 4dc0175..dfd49f7 100644
--- a/docs/guide/patterns.ipynb
+++ b/docs/guide/patterns.ipynb
@@ -1502,7 +1502,7 @@
     "\n",
     "ece14 = ObservationExpression(EqualityComparisonExpression(ObjectPath(\"file\", [\"name\"]), \"$$t00rzch$$.elf\"))\n",
     "ind = Indicator(name=\"Cryptotorch\", pattern_type=\"stix\", pattern=ece14)\n",
-    "print(ind)"
+    "print(ind.serialize(pretty=True))"
    ]
   }
  ],
@@ -1522,7 +1522,7 @@
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
-   "version": "3.9.0a6"
+   "version": "3.9.2"
   }
  },
  "nbformat": 4,
diff --git a/docs/guide/serializing.ipynb b/docs/guide/serializing.ipynb
index fd91c60..cbbc6f3 100644
--- a/docs/guide/serializing.ipynb
+++ b/docs/guide/serializing.ipynb
@@ -183,7 +183,7 @@
     "---\n",
     "**New in 3.0.0:** \n",
     "\n",
-    "Calling `str()` on a STIX object will call `serialize()` without any formatting options. The change was made to address the performance penalty induced by unknowingly calling with the pretty formatted option. As shown above, to get effect `str()` would in the past versions of the library use the method directly and pass the pretty argument directly `serialize(pretty=True)`.\n",
+    "Calling `str()` on a STIX object will call `serialize()` without any formatting options. The change was made to address the performance penalty induced by unknowingly calling with the pretty formatted option. As shown above, to get the same effect as `str()` had in past versions of the library, use the method directly and pass in the pretty argument `serialize(pretty=True)`.\n",
     "\n",
     "---\n",
     "\n",
diff --git a/stix2/base.py b/stix2/base.py
index c581be8..ac726bd 100644
--- a/stix2/base.py
+++ b/stix2/base.py
@@ -126,7 +126,6 @@ class _STIXBase(collections.abc.Mapping):
             if ext_found is False:
                 raise ExtraPropertiesError(cls, extra_kwargs)
 
-        # because allow_custom is true, any extra kwargs are custom
         if custom_props or extra_kwargs:
             self._allow_custom = True
             if isinstance(self, stix2.v21._STIXBase21):
@@ -153,7 +152,8 @@ class _STIXBase(collections.abc.Mapping):
         if missing_kwargs:
             new_ext_check = (
                 bool(getattr(self, "extension_type", None))
-            ) and issubclass(cls, stix2.v21._Extension)
+                and issubclass(cls, stix2.v21._Extension)
+            )
             if new_ext_check is False:
                 raise MissingPropertiesError(cls, missing_kwargs)
 
diff --git a/stix2/parsing.py b/stix2/parsing.py
index 001f523..8b39f91 100644
--- a/stix2/parsing.py
+++ b/stix2/parsing.py
@@ -87,11 +87,14 @@ def dict_to_stix2(stix_dict, allow_custom=False, version=None):
             # be parsed into STIX object, returned as is
             return stix_dict
         for key_id, ext_def in stix_dict.get('extensions', {}).items():
-            if key_id.startswith('extension-definition--') and ext_def.get('extension_type', None):
+            if (
+                key_id.startswith('extension-definition--') and
+                'property-extension' not in ext_def.get('extension_type', '')
+            ):
                 # prevents ParseError for unregistered objects when
-                # 'is_new_object' or 'is_extension_so' are set to True and allow_custom=False
+                # allow_custom=False and the extension defines a new object
                 return stix_dict
-        raise ParseError("Can't parse unknown object type '%s'! For custom types, use the CustomObject decorator." % stix_dict['type'])
+        raise ParseError("Can't parse unknown object type '%s'! For custom types, use the CustomObject decorator." % obj_type)
 
     return obj_class(allow_custom=allow_custom, **stix_dict)
 
diff --git a/stix2/registry.py b/stix2/registry.py
index 7cfc9ef..5ce7e24 100644
--- a/stix2/registry.py
+++ b/stix2/registry.py
@@ -76,8 +76,4 @@ def class_for_type(stix_type, stix_version, category=None):
                 cat_map["extensions"].get(stix_type)
             )
 
-    # Left "observable-extensions" out; it has a different
-    # substructure.  A version->category->type lookup would result
-    # in another map, not a class.  So it doesn't fit the pattern.
-
     return cls