-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Ingest Manager] Add namespace validation #75381
Conversation
Pinging @elastic/ingest-management (Team:Ingest Management) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
@elasticmachine merge upstream |
💚 Build SucceededBuild metrics@kbn/optimizer bundle module count
async chunks size
page load bundle size
History
To update your PR or re-run it, just comment with: |
* Add namespace validation on APIs and UI * Add test coverage * Fix imports * Fix schema * Rename to policy * Fix typo
* Add namespace validation on APIs and UI * Add test coverage * Fix imports * Fix schema * Rename to policy * Fix typo # Conflicts: # x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_policy/components/agent_policy_form.tsx # x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_policy/create_package_policy_page/services/validate_package_policy.ts # x-pack/plugins/ingest_manager/public/applications/ingest_manager/services/index.ts # x-pack/plugins/ingest_manager/server/types/models/agent_policy.ts # x-pack/plugins/ingest_manager/server/types/models/package_policy.ts # x-pack/test/ingest_manager_api_integration/apis/agent_policy/agent_policy.ts # x-pack/test/ingest_manager_api_integration/apis/package_policy/create.ts
* Add namespace validation on APIs and UI * Add test coverage * Fix imports * Fix schema * Rename to policy * Fix typo # Conflicts: # x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_policy/components/agent_policy_form.tsx # x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_policy/create_package_policy_page/services/validate_package_policy.ts # x-pack/plugins/ingest_manager/public/applications/ingest_manager/services/index.ts # x-pack/plugins/ingest_manager/server/types/models/agent_policy.ts # x-pack/plugins/ingest_manager/server/types/models/package_policy.ts # x-pack/test/ingest_manager_api_integration/apis/agent_policy/agent_policy.ts # x-pack/test/ingest_manager_api_integration/apis/package_policy/create.ts
* Add namespace validation on APIs and UI * Add test coverage * Fix imports * Fix schema * Rename to policy * Fix typo
return ( | ||
typeof namespace === 'string' && | ||
// Lowercase only | ||
namespace === namespace.toLowerCase() && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a few cases missing which agent validates
- namespace is allowed to contain
.
but is not allowed to be equal to.
or..
- namespace cannot be longer than 255 chars
- namespace cannot start with
-
,_
or+
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michalpristas I think the validation is incorrect,
Cannot be longer than 255 bytes (note it is bytes, so multi-byte characters will count towards the 255 limit faster)
This mean, type + dataset + namespace <= 255 bytes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what we do in agent is that we put 255 constraint on dataset, namespace and a product of concatenation, so eventaully we will fail when index > 255.
putting some not communicated constraint felt weird (such as 255/3 or some other math) so i used 255 on each part and result as well.
as namespace is created before configuration and can lead to different indexes based on dataset and type it would make sense to agree on some constraint which can be applied at the time of specifying namespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @jen-huang
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed up in #75846 (comment).
We have validated this ticket on latest 7.9.1-SNAPSHOT Kibana cloud environment and found it fixed. Provide namespace value starting with capital letter in agent configuration or integration while adding and editing them. Observations:
Screenshot: We have created and executed 04 testcases under Add namespace validation TestRun. Testcases created: Hence, we are closing the ticket. |
Thanks Rahul |
Summary
Resolves #74667. This PR adds additional validation for
namespace
field on agent and package policies. As we use the namespace field in the last part of our indexing strategy, the validation method partially implements ES index name rules, omitting the irrelevant ones.The validation is applied on our API routes using a custom validation schema, as well as UI:
Checklist
Delete any items that are not applicable to this PR.