Skip to content

Commit 31e132b

Browse files
authored
[Kibana Management] Add a limit when strings are too long (#186312)
## Summary This PR adds a validation on the string length on routes that create new objects in ES. Affected routes are: - Create an ingest pipeline - Create an index template and a component template - Create an ILM policy - Create a snapshot repo and policy - Create a remote cluster - Create an auto-follow pattern and a follower index - Create a rollup job ### Checklist Delete any items that are not applicable to this PR. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [ ] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [ ] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) ### Risk Matrix Delete this section if it is not applicable to this PR. Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release. When forming the risk matrix, consider some of the following examples and how they may potentially impact the change: | Risk | Probability | Severity | Mitigation/Notes | |---------------------------|-------------|----------|-------------------------| | Multiple Spaces—unexpected behavior in non-default Kibana Space. | Low | High | Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces. | | Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. | High | Low | Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure. | | Code should gracefully handle cases when feature X or plugin Y are disabled. | Medium | High | Unit tests will verify that any feature flag or plugin combination still results in our service operational. | | [See more potential risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) | ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
1 parent 72284db commit 31e132b

11 files changed

Lines changed: 29 additions & 18 deletions

File tree

x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_create_route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const registerCreateRoute = ({
2020
lib: { handleEsError },
2121
}: RouteDependencies) => {
2222
const bodySchema = schema.object({
23-
id: schema.string(),
23+
id: schema.string({ maxLength: 1000 }),
2424
remoteCluster: schema.string(),
2525
leaderIndexPatterns: schema.arrayOf(schema.string()),
2626
followIndexPattern: schema.string(),

x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index/register_create_route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const registerCreateRoute = ({
2121
lib: { handleEsError },
2222
}: RouteDependencies) => {
2323
const bodySchema = schema.object({
24-
name: schema.string(),
24+
name: schema.string({ maxLength: 1000 }),
2525
remoteCluster: schema.string(),
2626
leaderIndex: schema.string(),
2727
maxReadRequestOperationCount: schema.maybe(schema.number()),

x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_create_route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async function createPolicy(
3232
* We only specify a rough structure based on https://www.elastic.co/guide/en/elasticsearch/reference/current/_actions.html.
3333
*/
3434
const bodySchema = schema.object({
35-
name: schema.string(),
35+
name: schema.string({ maxLength: 1000 }),
3636
deprecated: schema.maybe(schema.boolean()),
3737
phases: schema.object({
3838
hot: schema.any(),

x-pack/plugins/index_management/server/routes/api/component_templates/schema_validation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import { schema } from '@kbn/config-schema';
99

1010
export const componentTemplateSchema = schema.object({
11-
name: schema.string(),
11+
name: schema.string({ maxLength: 1000 }),
1212
template: schema.object({
1313
settings: schema.maybe(schema.object({}, { unknowns: 'allow' })),
1414
aliases: schema.maybe(schema.object({}, { unknowns: 'allow' })),

x-pack/plugins/index_management/server/routes/api/enrich_policies/register_create_route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { normalizeFieldsList, getIndices, FieldCapsList, getCommonFields } from
1717

1818
const validationSchema = schema.object({
1919
policy: schema.object({
20-
name: schema.string(),
20+
name: schema.string({ maxLength: 1000 }),
2121
type: schema.oneOf([
2222
schema.literal('match'),
2323
schema.literal('range'),

x-pack/plugins/index_management/server/routes/api/templates/validate_schemas.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import { schema } from '@kbn/config-schema';
99

1010
export const templateSchema = schema.object({
11-
name: schema.string(),
11+
name: schema.string({ maxLength: 1000 }),
1212
indexPatterns: schema.arrayOf(schema.string()),
1313
version: schema.maybe(schema.number()),
1414
order: schema.maybe(schema.number()),

x-pack/plugins/ingest_pipelines/server/routes/api/create.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { RouteDependencies } from '../../types';
1414
import { pipelineSchema } from './shared';
1515

1616
const bodySchema = schema.object({
17-
name: schema.string(),
17+
name: schema.string({ maxLength: 1000 }),
1818
...pipelineSchema,
1919
});
2020

x-pack/plugins/remote_clusters/server/routes/api/add_route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { licensePreRoutingFactory } from '../../lib/license_pre_routing_factory'
1717
import { RouteDependencies } from '../../types';
1818

1919
const bodyValidation = schema.object({
20-
name: schema.string(),
20+
name: schema.string({ maxLength: 1000 }),
2121
skipUnavailable: schema.boolean(),
2222
mode: schema.oneOf([schema.literal(PROXY_MODE), schema.literal(SNIFF_MODE)]),
2323
seeds: schema.nullable(schema.arrayOf(schema.string())),

x-pack/plugins/rollup/server/routes/api/jobs/register_create_route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const registerCreateRoute = ({
2121
body: schema.object({
2222
job: schema.object(
2323
{
24-
id: schema.string(),
24+
id: schema.string({ maxLength: 1000 }),
2525
},
2626
{ unknowns: 'allow' }
2727
),

x-pack/plugins/snapshot_restore/server/routes/api/validate_schemas.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ export const snapshotListSchema = schema.object({
5353
});
5454

5555
export const policySchema = schema.object({
56-
name: schema.string(),
57-
snapshotName: schema.string(),
56+
name: schema.string({ maxLength: 1000 }),
57+
snapshotName: schema.string({ maxLength: 1000 }),
5858
schedule: schema.string(),
5959
repository: schema.string(),
6060
config: schema.maybe(snapshotConfigSchema),
@@ -66,7 +66,7 @@ export const policySchema = schema.object({
6666
const fsRepositorySettings = schema.object({ location: schema.string() }, { unknowns: 'allow' });
6767

6868
const fsRepositorySchema = schema.object({
69-
name: schema.string(),
69+
name: schema.string({ maxLength: 1000 }),
7070
type: schema.string(),
7171
settings: fsRepositorySettings,
7272
});
@@ -76,7 +76,7 @@ const readOnlyRepositorySettings = schema.object({
7676
});
7777

7878
const readOnlyRepository = schema.object({
79-
name: schema.string(),
79+
name: schema.string({ maxLength: 1000 }),
8080
type: schema.string(),
8181
settings: readOnlyRepositorySettings,
8282
});
@@ -85,7 +85,7 @@ const readOnlyRepository = schema.object({
8585
const s3RepositorySettings = schema.object({ bucket: schema.string() }, { unknowns: 'allow' });
8686

8787
const s3Repository = schema.object({
88-
name: schema.string(),
88+
name: schema.string({ maxLength: 1000 }),
8989
type: schema.string(),
9090
settings: s3RepositorySettings,
9191
});
@@ -100,15 +100,15 @@ const hdsRepositorySettings = schema.object(
100100
);
101101

102102
const hdsfRepository = schema.object({
103-
name: schema.string(),
103+
name: schema.string({ maxLength: 1000 }),
104104
type: schema.string(),
105105
settings: hdsRepositorySettings,
106106
});
107107

108108
const azureRepositorySettings = schema.object({}, { unknowns: 'allow' });
109109

110110
const azureRepository = schema.object({
111-
name: schema.string(),
111+
name: schema.string({ maxLength: 1000 }),
112112
type: schema.string(),
113113
settings: azureRepositorySettings,
114114
});
@@ -117,13 +117,13 @@ const azureRepository = schema.object({
117117
const gcsRepositorySettings = schema.object({ bucket: schema.string() }, { unknowns: 'allow' });
118118

119119
const gcsRepository = schema.object({
120-
name: schema.string(),
120+
name: schema.string({ maxLength: 1000 }),
121121
type: schema.string(),
122122
settings: gcsRepositorySettings,
123123
});
124124

125125
const sourceRepository = schema.object({
126-
name: schema.string(),
126+
name: schema.string({ maxLength: 1000 }),
127127
type: schema.string(),
128128
settings: schema.oneOf([
129129
fsRepositorySettings,

0 commit comments

Comments
 (0)