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

[filebeat][threatintel] MISP pagination fixes #37898

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Expand Up @@ -89,6 +89,7 @@ fields added to events containing the Beats version. {pull}37553[37553]
- Fix m365_defender cursor value and query building. {pull}37116[37116]
- Fix TCP/UDP metric queue length parsing base. {pull}37714[37714]
- Update github.com/lestrrat-go/jwx dependency. {pull}37799[37799]
- [threatintel] MISP pagination fixes {pull}37898[37898]

*Heartbeat*

Expand Down
25 changes: 22 additions & 3 deletions x-pack/filebeat/module/threatintel/misp/config/config.yml
Expand Up @@ -32,8 +32,20 @@ request.transforms:
value: json
- set:
target: body.timestamp
value: '[[.cursor.timestamp]]'
default: '[[ formatDate (now (parseDuration "-{{ .first_interval }}")) "UnixDate" ]]'
value: >-
[[- if index .cursor "timestamp" -]]
[[- .cursor.timestamp -]]
[[- else -]]
[[- .last_response.url.params.Get "timestamp" -]]
[[- end -]]
default: '[[ (now (parseDuration "-{{ .first_interval }}")).Unix ]]'
- set:
target: body.order
value: timestamp
- set:
# Ignored by MISP, set as a workaround to make it available in response.pagination.
target: url.params.timestamp
value: '[[.body.timestamp]]'

response.split:
target: body.response
Expand All @@ -51,8 +63,15 @@ response.request_body_on_pagination: true
response.pagination:
- set:
target: body.page
value: '[[if (ne (len .last_response.body.response) 0)]][[add .last_response.page 1]][[end]]'
# Add 2 because the httpjson page counter is zero-based while the MISP page parameter starts at 1.
value: '[[if (ne (len .last_response.body.response) 0)]][[add .last_response.page 2]][[end]]'
fail_on_template_error: true
- set:
target: body.timestamp
value: '[[.last_response.url.params.Get "timestamp"]]'
- set:
target: url.params.timestamp
value: '[[.last_response.url.params.Get "timestamp"]]'
cursor:
timestamp:
value: '[[.last_event.Event.timestamp]]'
Expand Down