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

[Entity Analytics] Asset criticality bulk upload JSON API #186310

Merged
merged 9 commits into from
Jun 19, 2024

Conversation

hop-dev
Copy link
Contributor

@hop-dev hop-dev commented Jun 17, 2024

Summary

Add the asset criticality bulk upload API at POST /api/asset_criticality/bulk. Records supplied will either be created or updated.

This API has the same functionality as the csv upload API but takes a JSON body.

A couple slight differences:

  • only 1000 records can be supplied, I think this is a good number, I have capped this so we dont have to parse a huge body, I think if users want more than this in a single request they can use CSV which is better suited (parses request as data is received instead of parsing in one go)
  • Validation is done up front not line by line, if an invalid record is received the whole request is aborted with a 400, no records are changed or added.

Example curl (note asset criticality advanced setting must be enabled otherwise you will get a 403):

> curl -X POST $KIBANA_URL/api/asset_criticality/bulk \
--header "kbn-xsrf: true" \
--header "Content-Type: application/json" \
--header "elastic-api-version: 2023-10-31" \
--data '{ "records": [ { "id_field": "host.name", "id_value": "host-1", "criticality_level": "low_impact" }, { "id_field": "host.name", "id_value": "host-2", "criticality_level": "high_impact" } ] }'

I have added API tests for the new route

@hop-dev hop-dev added release_note:skip Skip the PR/issue when compiling release notes Team:Entity Analytics Security Entity Analytics Team labels Jun 17, 2024
@hop-dev hop-dev self-assigned this Jun 17, 2024
@hop-dev
Copy link
Contributor Author

hop-dev commented Jun 17, 2024

/ci

@hop-dev hop-dev force-pushed the asset-criticality-multi-api branch from 35f51d5 to 194b01b Compare June 18, 2024 12:54
@hop-dev hop-dev marked this pull request as ready for review June 18, 2024 12:57
@hop-dev hop-dev requested review from a team as code owners June 18, 2024 12:57
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-entity-analytics (Team:Entity Analytics)

Copy link
Contributor

@tiansivive tiansivive left a comment

Choose a reason for hiding this comment

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

Just a small question

Copy link
Contributor

@szaffarano szaffarano left a comment

Choose a reason for hiding this comment

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

LGTM!

@hop-dev hop-dev enabled auto-merge (squash) June 19, 2024 12:56
@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 13.6MB 13.6MB +226.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @hop-dev

@hop-dev hop-dev merged commit 0856155 into elastic:main Jun 19, 2024
39 checks passed
@kibanamachine kibanamachine added v8.15.0 backport:skip This commit does not require backporting labels Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Entity Analytics Security Entity Analytics Team v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants