Skip to content

Commit

Permalink
[8.x] [Automatic Import] Fix UI validation for Integration and Datast…
Browse files Browse the repository at this point in the history
…ream name (#204943) (#205020)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Automatic Import] Fix UI validation for Integration and Datastream
name (#204943)](#204943)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Bharat
Pasupula","email":"123897612+bhapas@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-12-19T22:22:20Z","message":"[Automatic
Import] Fix UI validation for Integration and Datastream name
(#204943)\n\n## Release Note\r\n\r\nFixes Integration and Datastream
name validation\r\n\r\n##
Summary\r\n\r\nhttps://github.com//pull/204409 implemented
backend\r\nvalidation for integration and datastream names and this PR
fixes\r\nallowing numbers on backend\r\n\r\n<img width=\"858\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/8d61305a-eeb8-41d7-8fa0-f0b466fa7528\"\r\n/>\r\n\r\n\r\nCloses
https://github.com/elastic/kibana/issues/204935\r\n\r\n###
Checklist\r\n\r\nCheck the PR satisfies following conditions.
\r\n\r\nReviewers should verify this PR satisfies this list as
well.\r\n\r\n- [x] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] The PR description includes the appropriate Release Notes
section,\r\nand the correct `release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"b746c39ca04446301747c17cd845b1582db05396","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","v9.0.0","backport:prev-major","Team:Security-Scalability","Feature:AutomaticImport"],"title":"[Automatic
Import] Fix UI validation for Integration and Datastream
name","number":204943,"url":"https://github.com/elastic/kibana/pull/204943","mergeCommit":{"message":"[Automatic
Import] Fix UI validation for Integration and Datastream name
(#204943)\n\n## Release Note\r\n\r\nFixes Integration and Datastream
name validation\r\n\r\n##
Summary\r\n\r\nhttps://github.com//pull/204409 implemented
backend\r\nvalidation for integration and datastream names and this PR
fixes\r\nallowing numbers on backend\r\n\r\n<img width=\"858\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/8d61305a-eeb8-41d7-8fa0-f0b466fa7528\"\r\n/>\r\n\r\n\r\nCloses
https://github.com/elastic/kibana/issues/204935\r\n\r\n###
Checklist\r\n\r\nCheck the PR satisfies following conditions.
\r\n\r\nReviewers should verify this PR satisfies this list as
well.\r\n\r\n- [x] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] The PR description includes the appropriate Release Notes
section,\r\nand the correct `release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"b746c39ca04446301747c17cd845b1582db05396"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/204943","number":204943,"mergeCommit":{"message":"[Automatic
Import] Fix UI validation for Integration and Datastream name
(#204943)\n\n## Release Note\r\n\r\nFixes Integration and Datastream
name validation\r\n\r\n##
Summary\r\n\r\nhttps://github.com//pull/204409 implemented
backend\r\nvalidation for integration and datastream names and this PR
fixes\r\nallowing numbers on backend\r\n\r\n<img width=\"858\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/8d61305a-eeb8-41d7-8fa0-f0b466fa7528\"\r\n/>\r\n\r\n\r\nCloses
https://github.com/elastic/kibana/issues/204935\r\n\r\n###
Checklist\r\n\r\nCheck the PR satisfies following conditions.
\r\n\r\nReviewers should verify this PR satisfies this list as
well.\r\n\r\n- [x] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x] The PR description includes the appropriate Release Notes
section,\r\nand the correct `release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"b746c39ca04446301747c17cd845b1582db05396"}}]}]
BACKPORT-->

Co-authored-by: Bharat Pasupula <123897612+bhapas@users.noreply.github.com>
  • Loading branch information
kibanamachine and bhapas authored Dec 20, 2024
1 parent 4f85910 commit 6a0e65f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,6 @@ describe('isValidName', () => {
expect(isValidName('anotherValidName')).toBe(true);
});

it('should return false for names with numbers', () => {
expect(isValidName('invalid123')).toBe(false);
expect(isValidName('123invalid')).toBe(false);
expect(isValidName('invalid_123')).toBe(false);
});

it('should return false for empty string', () => {
expect(isValidName('')).toBe(false);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export async function buildPackage(integration: Integration): Promise<Buffer> {

if (!isValidName(integration.name)) {
throw new Error(
`Invalid integration name: ${integration.name}, Should only contain letters and underscores`
`Invalid integration name: ${integration.name}, Should only contain letters, numbers and underscores`
);
}

Expand All @@ -49,7 +49,7 @@ export async function buildPackage(integration: Integration): Promise<Buffer> {
const dataStreamName = dataStream.name;
if (!isValidName(dataStreamName)) {
throw new Error(
`Invalid datastream name: ${dataStreamName}, Should only contain letters and underscores`
`Invalid datastream name: ${dataStreamName}, Should only contain letters, numbers and underscores`
);
}
const specificDataStreamDir = joinPath(dataStreamsDir, dataStreamName);
Expand Down Expand Up @@ -77,7 +77,7 @@ export async function buildPackage(integration: Integration): Promise<Buffer> {
return zipBuffer;
}
export function isValidName(input: string): boolean {
const regex = /^[a-zA-Z_]+$/;
const regex = /^[a-zA-Z0-9_]+$/;
return input.length > 0 && regex.test(input);
}
function createDirectories(
Expand Down

0 comments on commit 6a0e65f

Please sign in to comment.