diff --git a/docs/guide/custom.ipynb b/docs/guide/custom.ipynb index 6031e5f..042f11e 100644 --- a/docs/guide/custom.ipynb +++ b/docs/guide/custom.ipynb @@ -175,9 +175,9 @@ ".highlight .vm { color: #19177C } /* Name.Variable.Magic */\n", ".highlight .il { color: #666666 } /* Literal.Number.Integer.Long */
{\n",
" "type": "identity",\n",
- " "id": "identity--87aac643-341b-413a-b702-ea5820416155",\n",
- " "created": "2018-04-05T18:38:10.269Z",\n",
- " "modified": "2018-04-05T18:38:10.269Z",\n",
+ " "id": "identity--e7fd0fe0-25ff-4fcb-abe5-b6254a9d1a22",\n",
+ " "created": "2019-07-25T18:18:18.241Z",\n",
+ " "modified": "2019-07-25T18:18:18.241Z",\n",
" "name": "John Smith",\n",
" "identity_class": "individual",\n",
" "x_foo": "bar"\n",
@@ -194,8 +194,6 @@
}
],
"source": [
- "from stix2 import Identity\n",
- "\n",
"identity = Identity(name=\"John Smith\",\n",
" identity_class=\"individual\",\n",
" custom_properties={\n",
@@ -289,9 +287,9 @@
".highlight .vm { color: #19177C } /* Name.Variable.Magic */\n",
".highlight .il { color: #666666 } /* Literal.Number.Integer.Long */{\n",
" "type": "identity",\n",
- " "id": "identity--a1ad0a6f-39ab-4642-9a72-aaa198b1eee2",\n",
- " "created": "2018-04-05T18:38:12.270Z",\n",
- " "modified": "2018-04-05T18:38:12.270Z",\n",
+ " "id": "identity--033b5f42-c94f-488f-8efa-2b6a167f0d6f",\n",
+ " "created": "2019-07-25T18:18:21.352Z",\n",
+ " "modified": "2019-07-25T18:18:21.352Z",\n",
" "name": "John Smith",\n",
" "identity_class": "individual",\n",
" "x_foo": "bar"\n",
@@ -426,6 +424,113 @@
"print(identity3.x_foo)"
]
},
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "To remove a custom properties, use `new_version()` and set it to `None`."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "{\n",
+ " "type": "identity",\n",
+ " "id": "identity--311b2d2d-f010-4473-83ec-1edf84858f4c",\n",
+ " "created": "2015-12-21T19:59:11.000Z",\n",
+ " "modified": "2019-07-25T18:18:25.927Z",\n",
+ " "name": "John Smith",\n",
+ " "identity_class": "individual"\n",
+ "}\n",
+ "
\n"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 7,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "identity4 = identity3.new_version(x_foo=None)\n",
+ "print(identity4)"
+ ]
+ },
{
"cell_type": "markdown",
"metadata": {},
diff --git a/docs/guide/versioning.ipynb b/docs/guide/versioning.ipynb
index 6074d00..eb0708a 100644
--- a/docs/guide/versioning.ipynb
+++ b/docs/guide/versioning.ipynb
@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 1,
"metadata": {
"nbsphinx": "hidden"
},
@@ -22,7 +22,7 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 2,
"metadata": {
"nbsphinx": "hidden"
},
@@ -63,12 +63,12 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "To create a new version of an existing object, specify the property(ies) you want to change and their new values:"
+ "To create a new version of an existing object, specify the property(ies) you want to change and their new values. For example, here we change the label from \"anomalous-activity\" to \"malicious-activity\":"
]
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": 3,
"metadata": {},
"outputs": [
{
@@ -144,12 +144,13 @@
".highlight .vm { color: #19177C } /* Name.Variable.Magic */\n",
".highlight .il { color: #666666 } /* Literal.Number.Integer.Long */{\n",
" "type": "indicator",\n",
- " "id": "indicator--dd052ff6-e404-444b-beb9-eae96d1e79ea",\n",
+ " "id": "indicator--8ad18fc7-457c-475d-b292-1ec44febe0fd",\n",
" "created": "2016-01-01T08:00:00.000Z",\n",
- " "modified": "2018-04-05T20:02:51.161Z",\n",
+ " "modified": "2019-07-25T17:59:34.815Z",\n",
" "name": "File hash for Foobar malware",\n",
+ " "description": "A file indicator",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
- " "valid_from": "2018-04-05T20:02:51.138312Z",\n",
+ " "valid_from": "2019-07-25T17:59:34.779826Z",\n",
" "labels": [\n",
" "malicious-activity"\n",
" ]\n",
@@ -160,7 +161,7 @@
""
]
},
- "execution_count": 4,
+ "execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
@@ -170,6 +171,7 @@
"\n",
"indicator = Indicator(created=\"2016-01-01T08:00:00.000Z\",\n",
" name=\"File hash for suspicious file\",\n",
+ " description=\"A file indicator\",\n",
" labels=[\"anomalous-activity\"],\n",
" pattern=\"[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']\")\n",
"\n",
@@ -187,7 +189,7 @@
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": 4,
"metadata": {
"scrolled": true
},
@@ -205,6 +207,117 @@
"indicator.new_version(id=\"indicator--cc42e358-8b9b-493c-9646-6ecd73b41c21\")"
]
},
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "You can remove optional or custom properties by setting them to `None` when you call `new_version()`."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "{\n",
+ " "type": "indicator",\n",
+ " "id": "indicator--8ad18fc7-457c-475d-b292-1ec44febe0fd",\n",
+ " "created": "2016-01-01T08:00:00.000Z",\n",
+ " "modified": "2019-07-25T17:59:42.648Z",\n",
+ " "name": "File hash for suspicious file",\n",
+ " "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
+ " "valid_from": "2019-07-25T17:59:34.779826Z",\n",
+ " "labels": [\n",
+ " "anomalous-activity"\n",
+ " ]\n",
+ "}\n",
+ "
\n"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 5,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "indicator3 = indicator.new_version(description=None)\n",
+ "print(indicator3)"
+ ]
+ },
{
"cell_type": "markdown",
"metadata": {
@@ -292,15 +405,15 @@
".highlight .vm { color: #19177C } /* Name.Variable.Magic */\n",
".highlight .il { color: #666666 } /* Literal.Number.Integer.Long */{\n",
" "type": "indicator",\n",
- " "id": "indicator--dd052ff6-e404-444b-beb9-eae96d1e79ea",\n",
+ " "id": "indicator--8ad18fc7-457c-475d-b292-1ec44febe0fd",\n",
" "created": "2016-01-01T08:00:00.000Z",\n",
- " "modified": "2018-04-05T20:02:54.704Z",\n",
- " "name": "File hash for Foobar malware",\n",
+ " "modified": "2019-07-25T17:59:52.198Z",\n",
+ " "name": "File hash for suspicious file",\n",
" "pattern": "[file:hashes.md5 = 'd41d8cd98f00b204e9800998ecf8427e']",\n",
- " "valid_from": "2018-04-05T20:02:51.138312Z",\n",
+ " "valid_from": "2019-07-25T17:59:34.779826Z",\n",
" "revoked": true,\n",
" "labels": [\n",
- " "malicious-activity"\n",
+ " "anomalous-activity"\n",
" ]\n",
"}\n",
"
\n"
@@ -315,8 +428,8 @@
}
],
"source": [
- "indicator2 = indicator2.revoke()\n",
- "print(indicator2)"
+ "indicator4 = indicator3.revoke()\n",
+ "print(indicator4)"
]
}
],