Closed sean-macfarlane closed 6 years ago
Hi, @sean-macfarlane . Try this:
objects = collection.get_objects(added_after=lastUpdate)
I tried what you suggested and it gives me this error:
Traceback (most recent call last):
File "/home/sean/CLAW_TAXII_Service/venv/lib/python3.5/site-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/home/sean/CLAW_TAXII_Service/venv/lib/python3.5/site-packages/urllib3/connectionpool.py", line 387, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "/home/sean/CLAW_TAXII_Service/venv/lib/python3.5/site-packages/urllib3/connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.5/http/client.py", line 1197, in getresponse
response.begin()
File "/usr/lib/python3.5/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.5/http/client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/sean/CLAW_TAXII_Service/venv/lib/python3.5/site-packages/requests/adapters.py", line 440, in send
timeout=timeout
File "/home/sean/CLAW_TAXII_Service/venv/lib/python3.5/site-packages/urllib3/connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "/home/sean/CLAW_TAXII_Service/venv/lib/python3.5/site-packages/urllib3/util/retry.py", line 357, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/home/sean/CLAW_TAXII_Service/venv/lib/python3.5/site-packages/urllib3/packages/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/home/sean/CLAW_TAXII_Service/venv/lib/python3.5/site-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/home/sean/CLAW_TAXII_Service/venv/lib/python3.5/site-packages/urllib3/connectionpool.py", line 387, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "/home/sean/CLAW_TAXII_Service/venv/lib/python3.5/site-packages/urllib3/connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.5/http/client.py", line 1197, in getresponse
response.begin()
File "/usr/lib/python3.5/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.5/http/client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "server.py", line 57, in <module>
job()
File "server.py", line 37, in job
objects = collection.get_objects(added_after=lastUpdate)
File "/home/sean/CLAW_TAXII_Service/venv/lib/python3.5/site-packages/taxii2client/__init__.py", line 295, in get_objects
params=query_params)
File "/home/sean/CLAW_TAXII_Service/venv/lib/python3.5/site-packages/taxii2client/__init__.py", line 571, in get
resp = self.session.get(url, headers=headers, params=params)
File "/home/sean/CLAW_TAXII_Service/venv/lib/python3.5/site-packages/requests/sessions.py", line 521, in get
return self.request('GET', url, **kwargs)
File "/home/sean/CLAW_TAXII_Service/venv/lib/python3.5/site-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/home/sean/CLAW_TAXII_Service/venv/lib/python3.5/site-packages/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/home/sean/CLAW_TAXII_Service/venv/lib/python3.5/site-packages/requests/adapters.py", line 490, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
the value I am passing for added_after is an iso format datetime string i.e "2018-01-23T05:13:19.080825+00:00"
What server are you testing against? Seems like the server isn't returning a response, which may be because of an error in the client, or maybe not.
Also, ideally it shouldn't matter, but the spec calls for timestamps to be expressed with a Z suffix rather than +00:00:
The timestamp MUST be represented in the UTC timezone and MUST use the āZā designation to indicate this.
http://docs.oasis-open.org/cti/taxii/v2.0/cs01/taxii-v2.0-cs01.html#_Toc496542710
I'm using https://test.freetaxii.com:8000/osint/
And I tried using the string "2018-01-23T05:13:19.080825Z" and using a datetime object cause I saw in the code it would convert it to the correct string format. But both still produce the same error
I can reproduce this. @jordan2175, do you know if this a known issue with the freetaxii-server, or something in the Python client library?
@gtback I am not aware of any issue with my code. I do this filter a lot for my unit tests. Do you have an exact URL string you are using that I can test with?
@jordan2175: This url works (assuming the correct Accept
header is used):
https://test.freetaxii.com:8000/osint/collections/34f8c42d-213a-480d-9046-0bd8a8f25680/objects/
This URL does not work:
Note that I also tried encoding the colons in the timestamp as %3A
, to match what the Python library will do.
I used the httpie command line utility, so I don't think it's an issue in cti-taxii-client.
http https://test.freetaxii.com:8000/osint/collections/34f8c42d-213a-480d-9046-0bd8a8f25680/objects/?added_after=2018-01-23T05%3A13%3A19.080825Z Accept:"application/vnd.oasis.stix+json; version=2.0"
any update on why this isn't working? thanks
@jordan2175, let me know if I'm using an invalid URL to test this; it seems like freetaxii is aborting the connection rather than returning a response (even an empty HTTP response)
FYI
I've used my scala code to ask https://test.freetaxii.com:8000 for the above collection of objects.
I tried: 2018-01-23T05:13:19.080825Z get an error with "Remotely closed" message, get no bundle at all but should return an empty bundle. and 2017-12-03T08:00:38.231Z get a bundle with 7 stix indicator
Note: The 10 indicators returned for collection "34f8c42d-213a-480d-9046-0bd8a8f25680" have dates created in the year 2017. So 2018-01-23T05:13:19.080825Z will not return any objects, but should return a bundle with nothing in it, however we get a "Remotely closed" error instead.
This is to say this is a known issue with https://test.freetaxii.com:8000. Quote: "The way I have the code right now, if there is no data in the collection that matches your filter, I am returning an error."
Is there another play/test taxii server around?
I have a new version based on TAXII 2.1 CSD 01 that I am going to upload to the test server, once we figure out how we are going advertise a CSD version.
Bret
Sent from my Commodore 64
PGP Fingerprint: 63B4 FC53 680A 6B7D 1447 F2C0 74F8 ACAE 7415 0050
On Feb 22, 2018, at 8:18 PM, workingDog notifications@github.com wrote:
FYI
I've used my scala code to ask https://test.freetaxii.com:8000 for the above collection of objects.
I tried: 2018-01-23T05:13:19.080825Z get an error with "Remotely closed" message, get no bundle at all but should return an empty bundle. and 2017-12-03T08:00:38.231Z get a bundle with 7 stix indicator
Note: The 10 indicators returned for collection "34f8c42d-213a-480d-9046-0bd8a8f25680" have dates created in the year 2017. So 2018-01-23T05:13:19.080825Z will not return any objects, but should return a bundle with nothing in it, however we get a "Remotely closed" error instead.
ā You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
It sounds like this isn't an issue in the cti-taxii-client, so I'm going to close this; but if there's anything that needs to be done here, feel free to re-open.
I'm trying to pass the "added_after" to
collection.get_objects
but I keep getting this error:TypeError: get_objects() takes 1 positional argument but 2 were given
code:
objects = collection.get_objects({"added_after": lastUpdate})