From a0c0e957ff714ffe693eb12de71a9227d8e2f49d Mon Sep 17 00:00:00 2001 From: = Date: Mon, 2 Oct 2017 17:33:03 -0400 Subject: [PATCH] CompositeDataSource guide - still incomplete as need to test execution --- ...aStore, CompositeDataSource, Filters.ipynb | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/docs/guide/DataStore, CompositeDataSource, Filters.ipynb b/docs/guide/DataStore, CompositeDataSource, Filters.ipynb index 5ea04e3..6f1e2e4 100644 --- a/docs/guide/DataStore, CompositeDataSource, Filters.ipynb +++ b/docs/guide/DataStore, CompositeDataSource, Filters.ipynb @@ -55,21 +55,31 @@ }, { "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": true - }, + "execution_count": null, + "metadata": {}, "outputs": [], "source": [ - "import sys\n", - "sys.path.append(\"/home/michael/oasis-python-stix2/cti-python-stix2/\")\n", - "sys.path\n", + "from taxii2client import Collection\n", + "from stix2 import CompositeDataSource, FileSystemSource, TAXIICollectionSource\n", "\n", - "from stix2 import CompositeDataSource, FileSystemStore\n", + "# create FileSystemStore\n", + "fs = FileSystemSource(\"/tmp/stix2_data\")\n", "\n", + "# create TAXIICollectionSource\n", + "colxn = Collection('https://test.freetaxii.com:8000/api1/collections/9cfa669c-ee94-4ece-afd2-f8edac37d8fd/')\n", + "ts = TAXIICollectionSource(colxn)\n", "\n", - "# TO BE COMPLETED, WAITING ON TAXIICollection,\n", - "# want to put a TAXIICollection in here" + "# add them both to the CompositeDataSource\n", + "cs = CompositeDataSource()\n", + "cs.add_data_sources([fs, ts])\n", + "\n", + "# get an object that is only in the filesystem\n", + "ta = cs.get('threat-actor--d10825d4-7b74-4cca-a0fc-7c097e08ccd2')\n", + "print(ta)\n", + "\n", + "# get an object that is only in the TAXII collection\n", + "ind = cs.get('indicator--37a6a5de-a5b9-425a-903a-4ae9cbf1ff3f')\n", + "print(ind)\n" ] }, { @@ -133,7 +143,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": { "collapsed": true }, @@ -167,7 +177,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -196,15 +206,6 @@ "# attach multiple filters to a MemoryStore\n", "mem.source.filters.update([f1,f2])" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] } ], "metadata": {