oasis-open / cti-python-stix2

OASIS TC Open Repository: Python APIs for STIX 2
https://stix2.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
364 stars 119 forks source link

Cannot run example #548

Open IgorGanapolsky opened 2 years ago

IgorGanapolsky commented 2 years ago

Hello, when I run your example in the examples folder, I get an error:

/Users/igorganapolsky/workspace/git/Andreww6/gists/venv/bin/python /Users/igorganapolsky/workspace/git/Andreww6/gists/main.py Traceback (most recent call last): File "/Users/igorganapolsky/workspace/git/Andreww6/gists/venv/lib/python3.11/site-packages/stix2/datastore/taxii.py", line 163, in init if collection.can_read: ^^^^^^^^^^^^^^^^^^^ File "/Users/igorganapolsky/workspace/git/Andreww6/gists/venv/lib/python3.11/site-packages/taxii2client/v21/init.py", line 285, in can_read self._ensure_loaded() ^^^^^^^^^^^^^^^^^^^^^ File "/Users/igorganapolsky/workspace/git/Andreww6/gists/venv/lib/python3.11/site-packages/taxii2client/v21/init.py", line 354, in _ensure_loaded self.refresh() ^^^^^^^^^^^^^^ File "/Users/igorganapolsky/workspace/git/Andreww6/gists/venv/lib/python3.11/site-packages/taxii2client/v21/init.py", line 368, in refresh response = self.__raw = self._conn.get(self.url, headers={"Accept": accept}) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/igorganapolsky/workspace/git/Andreww6/gists/venv/lib/python3.11/site-packages/taxii2client/common.py", line 310, in get raise e ^^^^^^^ File "/Users/igorganapolsky/workspace/git/Andreww6/gists/venv/lib/python3.11/site-packages/taxii2client/common.py", line 300, in get resp.raise_for_status() ^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/igorganapolsky/workspace/git/Andreww6/gists/venv/lib/python3.11/site-packages/requests/models.py", line 1022, in raise_for_status raise HTTPError(http_error_msg, response=self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: http://127.0.0.1:5000/trustgroup1/collections/91a7b528-80eb-42ed-a74d-c6fbd5a26116/

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/igorganapolsky/workspace/git/Andreww6/gists/main.py", line 39, in main() ^^^^^^ File "/Users/igorganapolsky/workspace/git/Andreww6/gists/main.py", line 13, in main taxii = stix2.TAXIICollectionSource(collection) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/igorganapolsky/workspace/git/Andreww6/gists/venv/lib/python3.11/site-packages/stix2/datastore/taxii.py", line 172, in init raise DataSourceError( ^^^^^^^^^^^^^^^^^^^^^^ stix2.datastore.DataSourceError: The underlying TAXII Collection resource defined in the supplied TAXII Collection object provided could not be reached. Recieved error: "403 Client Error: Forbidden for url: http://127.0.0.1:5000/trustgroup1/collections/91a7b528-80eb-42ed-a74d-c6fbd5a26116/"

Process finished with exit code 1

chisholm commented 2 years ago

Looks like a permission error. Did you run it with medallion as the TAXII server? Did you use the configuration and data included with that project?

IgorGanapolsky commented 2 years ago

I just used the default config. I did not set up a separate TAXII server. Do I need to?

rpiazza commented 2 years ago

@IgorGanapolsky - yes you need to run a TAXII server if you want to use the TAXII data store. See https://github.com/oasis-open/cti-taxii-server. You probably want to use the MemoryBackend