CompositeDataSource guide - still incomplete as need to test execution
parent
3b9e52ce19
commit
a0c0e957ff
|
@ -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": {
|
||||
|
|
Loading…
Reference in New Issue