Skip to content

forgerock: fix handling of query time ranges - #11240

Merged
efd6 merged 3 commits into
elastic:mainfrom
efd6:11220-forgerock
Sep 26, 2024
Merged

efd6 merged 3 commits into
elastic:mainfrom
efd6:11220-forgerock

Conversation

@efd6

@efd6 efd6 commented Sep 25, 2024

Copy link
Copy Markdown
Contributor

Proposed commit message

The Forgerock API requires that the time range query satisfy three rules[1]. We
were not satisfying the last rule, that the end of the range must not be more
than 24 hours after the start of the range.

The API does not require that the end of the range must not be in the future, so
change the end time template to always render as the start of the range plus 24
hours.

The current tests do not correctly set the pagination token in some cases, and
in all cases the stream mock does not restrict queries that do not contain a
token from re-initiating a pagination cycle. Fix both of these and apply event
count assertions.

[1]https://backstage.forgerock.com/docs/idcloud/latest/tenants/audit-debug-logs.html#get-log-results-for-a-time-period

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Screenshots

@efd6 efd6 added bugfix Pull request that fixes a bug issue Integration:forgerock ForgeRock Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations] labels Sep 25, 2024
@efd6 efd6 self-assigned this Sep 25, 2024
The Forgerock API requires that the time range query satisfy three rules[1]. We
were not satisfying the last rule, that the end of the range must not be more
than 24 hours after the start of the range.

The API does not require that the end of the range must not be in the future, so
change the end time template to always render as the start of the range plus 24
hours.

[1]https://backstage.forgerock.com/docs/idcloud/latest/tenants/audit-debug-logs.html#get-log-results-for-a-time-period
The current tests do not correctly set the pagination token in some cases, and
in all cases the stream mock does not restrict queries that do not contain a
token from re-initiating a pagination cycle. Fix both of these and apply event
count assertions.
@elastic-vault-github-plugin-prod

Copy link
Copy Markdown
Contributor

🚀 Benchmarks report

Package forgerock 👍(7) 💚(1) 💔(3)

Expand to view
Data stream Previous EPS New EPS Diff (%) Result
idm_core 50000 29411.76 -20588.24 (-41.18%) 💔
am_authentication 20000 15625 -4375 (-21.88%) 💔
idm_config 25641.03 18181.82 -7459.21 (-29.09%) 💔

To see the full report comment with /test benchmark fullreport

@elastic-sonarqube

Copy link
Copy Markdown

@elasticmachine

Copy link
Copy Markdown

💚 Build Succeeded

History

  • 💔 Build #16385 failed e1ea1bfd07c801a6c252906eb6c7a20a8a282503

cc @efd6

@efd6
efd6 marked this pull request as ready for review September 25, 2024 21:18
@efd6
efd6 requested a review from a team as a code owner September 25, 2024 21:18
@elasticmachine

Copy link
Copy Markdown

Pinging @elastic/security-service-integrations (Team:Security-Service Integrations)

@andrewkroh andrewkroh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

It might be worthwhile to take what we know about the API, and codify that into a mock / emulator.

@elastic-vault-github-plugin-prod

Copy link
Copy Markdown
Contributor

Package forgerock - 1.18.1 containing this change is available at https://epr.elastic.co/search?package=forgerock

efd6 added a commit to efd6/integrations that referenced this pull request Oct 15, 2024
In elastic#11240 we attempted to fix preparation of endTime where it could be more than
24 hours after the startTime parameter, a case that is invalid for the API. To
do this, we just always added 24 hours to the startTime on the basis that the
API would crop at the present moment, and — notably — under the assumption that
the returned document would be used to construct the next startTime. Clearly
this is not the case, since we use the actual endTime parameter to construct the
next startTime; the API does not provide an HTTPJSON-easy way to get the last
timestamp. So set the endTime query parameter to the earliest of now and 24
hours after startTime.
efd6 added a commit that referenced this pull request Oct 17, 2024
In #11240 we attempted to fix preparation of endTime where it could be more than
24 hours after the startTime parameter, a case that is invalid for the API. To
do this, we just always added 24 hours to the startTime on the basis that the
API would crop at the present moment, and — notably — under the assumption that
the returned document would be used to construct the next startTime. Clearly
this is not the case, since we use the actual endTime parameter to construct the
next startTime; the API does not provide an HTTPJSON-easy way to get the last
timestamp. So set the endTime query parameter to the earliest of now and 24
hours after startTime.

Queries with an end time of now may not get all documents up to now. Since we
are using the query parameter to define the end of the range of documents that
have definitively been retrieved, this means that we will never try to get these
missed documents. We could us the maximum timestamp of the collected documents
to define this range, but that less easy to do here, so just set the end of the
time range to be some short period before now. Ten seconds is chosen as a
conservative value (the report claimed milliseconds of documents were lost).
harnish-crest-data pushed a commit to chavdaharnish/integrations that referenced this pull request Feb 4, 2025
The Forgerock API requires that the time range query satisfy three rules[1]. We
were not satisfying the last rule, that the end of the range must not be more
than 24 hours after the start of the range.

The API does not require that the end of the range must not be in the future, so
change the end time template to always render as the start of the range plus 24
hours.

The current tests do not correctly set the pagination token in some cases, and
in all cases the stream mock does not restrict queries that do not contain a
token from re-initiating a pagination cycle. Fix both of these and apply event
count assertions.

[1]https://backstage.forgerock.com/docs/idcloud/latest/tenants/audit-debug-logs.html#get-log-results-for-a-time-period
harnish-crest-data pushed a commit to chavdaharnish/integrations that referenced this pull request Feb 4, 2025
In elastic#11240 we attempted to fix preparation of endTime where it could be more than
24 hours after the startTime parameter, a case that is invalid for the API. To
do this, we just always added 24 hours to the startTime on the basis that the
API would crop at the present moment, and — notably — under the assumption that
the returned document would be used to construct the next startTime. Clearly
this is not the case, since we use the actual endTime parameter to construct the
next startTime; the API does not provide an HTTPJSON-easy way to get the last
timestamp. So set the endTime query parameter to the earliest of now and 24
hours after startTime.

Queries with an end time of now may not get all documents up to now. Since we
are using the query parameter to define the end of the range of documents that
have definitively been retrieved, this means that we will never try to get these
missed documents. We could us the maximum timestamp of the collected documents
to define this range, but that less easy to do here, so just set the end of the
time range to be some short period before now. Ten seconds is chosen as a
conservative value (the report claimed milliseconds of documents were lost).
harnish-crest-data pushed a commit to chavdaharnish/integrations that referenced this pull request Feb 5, 2025
The Forgerock API requires that the time range query satisfy three rules[1]. We
were not satisfying the last rule, that the end of the range must not be more
than 24 hours after the start of the range.

The API does not require that the end of the range must not be in the future, so
change the end time template to always render as the start of the range plus 24
hours.

The current tests do not correctly set the pagination token in some cases, and
in all cases the stream mock does not restrict queries that do not contain a
token from re-initiating a pagination cycle. Fix both of these and apply event
count assertions.

[1]https://backstage.forgerock.com/docs/idcloud/latest/tenants/audit-debug-logs.html#get-log-results-for-a-time-period
harnish-crest-data pushed a commit to chavdaharnish/integrations that referenced this pull request Feb 5, 2025
In elastic#11240 we attempted to fix preparation of endTime where it could be more than
24 hours after the startTime parameter, a case that is invalid for the API. To
do this, we just always added 24 hours to the startTime on the basis that the
API would crop at the present moment, and — notably — under the assumption that
the returned document would be used to construct the next startTime. Clearly
this is not the case, since we use the actual endTime parameter to construct the
next startTime; the API does not provide an HTTPJSON-easy way to get the last
timestamp. So set the endTime query parameter to the earliest of now and 24
hours after startTime.

Queries with an end time of now may not get all documents up to now. Since we
are using the query parameter to define the end of the range of documents that
have definitively been retrieved, this means that we will never try to get these
missed documents. We could us the maximum timestamp of the collected documents
to define this range, but that less easy to do here, so just set the end of the
time range to be some short period before now. Ten seconds is chosen as a
conservative value (the report claimed milliseconds of documents were lost).
@efd6
efd6 deleted the 11220-forgerock branch February 5, 2025 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Pull request that fixes a bug issue Integration:forgerock ForgeRock Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[forgerock]: agent does not keep time stamp ranges within API requirements

3 participants