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
356 stars 113 forks source link

TAXIICollectionSource should support 2.1 filters #510

Open clenk opened 3 years ago

clenk commented 3 years ago

_parse_taxii_filters() doesn't support the TAXII 2.1-specific filters of limit, next, or spec_version.

See also: https://github.com/oasis-open/cti-taxii-client/issues/100.

rpiazza commented 2 years ago

@zrush-mitre - is this something we need before we release python-stix2 3.0? (for 2.1)

zrush-mitre commented 2 years ago

No rush to get this out with major release. I'll plan on working on this next week and hopefully submitting a PR.

zrush-mitre commented 2 years ago

So a little update for this issue:

The 'limit' filter is not difficult to implement on TAXIICollectionSource, since there's only one or two functions that will actually go to call the TAXII server and they already have a paging functionality included, so replacing that with an argument for the 'limit' filter is pretty easy and immediately works well.

The problem comes from the 'next' filter: since 'next' only ever gets used after subsequent 'limit' responses, it doesn't really make sense for a user to explicitly give this value in the request, since paged requests will just return all of the objects collected with multiple requests to the server. However, a user may not actually want to receive all the returned objects with the 'limit' filter in the first place, and instead, the TAXIICollectionSource would need to either hold onto paged objects and only give them to the user when requested, or the functions would need to be refactored to not make all paged requests immediately.

I'm not sure what is the best way forward here, so this requires further investigation.