Skip to content

Commit

Permalink
[Backend] Align built in TAXII ingester pagination to be aligned with…
Browse files Browse the repository at this point in the history
… specification (#5691)
  • Loading branch information
yassine-ouaamou authored and Goumies committed Jan 26, 2024
1 parent 96f0127 commit a49a993
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,12 @@ const taxiiHttpGet = async (ingestion: BasicStoreEntityIngestionTaxii): Promise<
const httpClient = getHttpClient(httpClientOptions);
const preparedUri = ingestion.uri.endsWith('/') ? ingestion.uri : `${ingestion.uri}/`;
const url = `${preparedUri}collections/${ingestion.collection}/objects/`;
const next = ingestion.added_after_start ? ingestion.current_state_cursor : null;
// https://docs.oasis-open.org/cti/taxii/v2.1/os/taxii-v2.1-os.html#_Toc31107519
// If the more property is set to true and the next property is populated then the client can paginate through the remaining records using the next URL parameter along with the
// same original query options.
// If the more property is set to true and the next property is empty then the client may paginate through the remaining records by using the added_after URL parameter with the
// date/time value from the X-TAXII-Date-Added-Last header along with the same original query options.
const next = ingestion.current_state_cursor;
const params = { next, added_after: ingestion.added_after_start };
const { data, headers: resultHeaders } = await httpClient.get(url, { params });
return { data, addedLast: resultHeaders['x-taxii-date-added-last'] };
Expand All @@ -244,7 +249,7 @@ const taxiiV21DataHandler: TaxiiHandlerFn = async (context: AuthContext, ingesti
// Update the state
await patchTaxiiIngestion(context, SYSTEM_USER, ingestion.internal_id, {
current_state_cursor: data.next ? String(data.next) : undefined,
added_after_start: utcDate(addedLast)
added_after_start: data.next ? ingestion.added_after_start : utcDate(addedLast)
});
} else if (data.objects === undefined) {
const error = UnknownError('Undefined taxii objects', data);
Expand Down

0 comments on commit a49a993

Please sign in to comment.