Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TAXII2 pagination incorrectly sets more to false if MAX_TAXII_PAGINATION > ES_DEFAULT_PAGINATION #7793

Closed
samczsun opened this issue Jul 23, 2024 · 2 comments
Assignees
Labels
bug use for describing something not working as expected solved use to identify issue that has been solved (must be linked to the solving PR)

Comments

@samczsun
Copy link

Description

We have app:data_sharing:taxii:max_pagination_result set to 10000. When requesting /objects with no limit parameter, it returns 5000 entries and more=false. However, there are more entries and requesting with the next parameter properly returns additional entries.

The value of more is determined by pageInfo.hasNextPage

export const restCollectionStix = async (context, user, collection, args) => {
const { edges, pageInfo } = await collectionQuery(context, user, collection, args);
const edgeIds = edges.map((e) => e.node.internal_id);
const instances = await stixLoadByIds(context, user, edgeIds);
return {
more: pageInfo.hasNextPage,
next: R.last(edges)?.cursor || '',
objects: instances,
};
};

This value is true if instances.length === limit

export const buildPagination = (limit, searchAfter, instances, globalCount) => {
const edges = R.pipe(
R.mapObjIndexed((record) => {
const { node, sort, types } = record;
const cursor = sort ? offsetToCursor(sort) : '';
return { node, cursor, types };
}),
R.values
)(instances);
// Because of stateless approach its difficult to know if its finish
// this test could lead to an extra round trip sometimes
const hasNextPage = instances.length === limit;

This conditional will evaluate to false if limit is not set as a query parameter and MAX_TAXII_PAGINATION > ES_DEFAULT_PAGINATION, because instances.length == ES_DEFAULT_PAGINATION but limit == MAX_TAXII_PAGINATION.

Environment

  1. OS (where OpenCTI server runs): Ubuntu
  2. OpenCTI version: 6.2.6
  3. OpenCTI client: frontend
  4. Other environment details:

Reproducible Steps

Steps to create the smallest reproducible scenario:

  1. Create a TAXII2 collection which has more than ES_DEFAULT_PAGINATION elements
  2. Set MAX_TAXII_PAGINATION to a value greater than ES_DEFAULT_PAGINATION
  3. Request the /objects endpoint with no explicit limit parameter

Expected Output

more should be true, because there are more elements

Actual Output

more is false, because of the reasons outlined above

Additional information

Screenshots (optional)

@samczsun samczsun added bug use for describing something not working as expected needs triage use to identify issue needing triage from Filigran Product team labels Jul 23, 2024
@romain-filigran
Copy link
Member

@richard-julien @SouadHadjiat @aHenryJard : Can we plan to look at this together ?

@romain-filigran romain-filigran removed the needs triage use to identify issue needing triage from Filigran Product team label Aug 21, 2024
@romain-filigran romain-filigran added this to the Bugs backlog milestone Aug 21, 2024
@richard-julien richard-julien self-assigned this Aug 25, 2024
@richard-julien
Copy link
Member

richard-julien commented Aug 25, 2024

Thanks for the report @samczsun. There is a collision in term of option between the data_sharing:taxii:max_pagination_result and the elasticsearch:max_pagination_result that create this issue.
We be fixed in the next release.
However you need to be really careful about changing this kind of option. Too many results will impact the processing and the elasticsearch.
For now please use 5000 as the max configuration.

@richard-julien richard-julien added the solved use to identify issue that has been solved (must be linked to the solving PR) label Aug 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug use for describing something not working as expected solved use to identify issue that has been solved (must be linked to the solving PR)
Projects
None yet
Development

No branches or pull requests

4 participants