This repository has been archived by the owner on Mar 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 95
Fix/taxii 2.1 pagination #400
Open
UFOSmuggler
wants to merge
23
commits into
PaloAltoNetworks:develop
Choose a base branch
from
UFOSmuggler:fix/taxii-2.1-pagination
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix/taxii 2.1 pagination #400
UFOSmuggler
wants to merge
23
commits into
PaloAltoNetworks:develop
from
UFOSmuggler:fix/taxii-2.1-pagination
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Luigi Mori <[email protected]>
…herwise use 'X-TAXII-Date-Added-Last' HTTP response header.
🎉 Thanks for opening this pull request! We really appreciate contributors like you! 🙌 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fix pagination in TAXII 2.1 requests
Motivation and Context
Minemeld attempts to paginate TAXII 2.1 requests by using the most recent value of the "modified" keys of STIX objects within the response, to form new "added_after" URI parameters for subsequent queries.
This is an invalid approach to pagination in TAXII 2.1. The TAXII 2.1 spec has this to say about the "added_after" URI parameter:
Using this method is inappropriate and may lead to pagination loops, resulting in Minemeld polling rapidly forever.
Here is an example found in the wild:
As can be seen, the most recent modified date is the same as the one we just requested.
The valid method for pagination by using "added_after" is to use the "X-TAXII-Date-Added-Last" HTTP response header which contains the datetime the most recent object in the response was added to the collection. This contains a timestamp of the same format as expected by "added_after" so it is a trivial change to alter this code to work with the value of this header.
However, it is likely more appropriate to use the "next" key in the TAXII response, as the server will take care of pagination for the client. Taking the value of the "next" key, and using it in a request with the "next" URI parameter will obtain the next page.
I have altered the taxii2.py "_poll_taxii21_server" function to first attempt to use the "next" key, and fall back to the "X-TAXII-Date-Added-Last" HTTP response header. If neither of these are available, we raise an error as the TAXII 2.1 server is not meeting the specification.
How Has This Been Tested?
I tested this fix against Medallion 3 and OpenTAXII 0.9.3 TAXII 2.1 collections which the original code could not successfully poll without looping. I was able to fully poll all collections.
Types of changes
Checklist