CompositeDataSource guide - still incomplete as need to test execution

stix2.1
= 2017-10-02 17:33:03 -04:00
parent 3b9e52ce19
commit a0c0e957ff
1 changed files with 22 additions and 21 deletions

View File

@ -55,21 +55,31 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": true
},
"outputs": [], "outputs": [],
"source": [ "source": [
"import sys\n", "from taxii2client import Collection\n",
"sys.path.append(\"/home/michael/oasis-python-stix2/cti-python-stix2/\")\n", "from stix2 import CompositeDataSource, FileSystemSource, TAXIICollectionSource\n",
"sys.path\n",
"\n", "\n",
"from stix2 import CompositeDataSource, FileSystemStore\n", "# create FileSystemStore\n",
"fs = FileSystemSource(\"/tmp/stix2_data\")\n",
"\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", "\n",
"# TO BE COMPLETED, WAITING ON TAXIICollection,\n", "# add them both to the CompositeDataSource\n",
"# want to put a TAXIICollection in here" "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", "cell_type": "code",
"execution_count": 1, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true "collapsed": true
}, },
@ -167,7 +177,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -196,15 +206,6 @@
"# attach multiple filters to a MemoryStore\n", "# attach multiple filters to a MemoryStore\n",
"mem.source.filters.update([f1,f2])" "mem.source.filters.update([f1,f2])"
] ]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
} }
], ],
"metadata": { "metadata": {