Skip to content

Commit d978538

Browse files
authored
[One Workflow] Fix hardcoded dynamic connectors schema (#241276)
## Summary Closes: elastic/security-team#14387 ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] 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/src/platform/packages/shared/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 - [ ] 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 was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [ ] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ...
1 parent 89eb430 commit d978538

File tree

4 files changed

+37
-52
lines changed

4 files changed

+37
-52
lines changed

src/platform/plugins/shared/workflows_management/common/stack_connectors_schema/bedrock.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@ import { z } from '@kbn/zod';
1616

1717
// Bedrock connector parameter schema
1818
export const BedrockParamsSchema = z.object({
19-
subAction: z.enum(['run', 'test']),
20-
subActionParams: z.object({
21-
body: z.string(),
22-
model: z.string().optional(),
23-
}),
19+
body: z.string(),
20+
model: z.string().optional(),
2421
});
2522

2623
// Bedrock connector response schema

src/platform/plugins/shared/workflows_management/common/stack_connectors_schema/gemini.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@ import { z } from '@kbn/zod';
1616

1717
// Gemini connector parameter schema
1818
export const GeminiParamsSchema = z.object({
19-
subAction: z.enum(['run', 'test', 'dashboard']),
20-
subActionParams: z.object({
21-
body: z.string(),
22-
model: z.string().optional(),
23-
}),
19+
body: z.string(),
20+
model: z.string().optional(),
2421
});
2522

2623
// Gemini connector response schema

src/platform/plugins/shared/workflows_management/common/stack_connectors_schema/openai.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,12 @@ import { z } from '@kbn/zod';
1616

1717
// OpenAI connector parameter schema
1818
export const OpenAIParamsSchema = z.object({
19-
subAction: z.enum(['run', 'test', 'dashboard']),
20-
subActionParams: z.object({
21-
body: z.string(),
22-
model: z.string().optional(),
23-
n: z.number().optional(),
24-
stop: z.array(z.string()).optional(),
25-
temperature: z.number().optional(),
26-
max_tokens: z.number().optional(),
27-
}),
19+
body: z.string(),
20+
model: z.string().optional(),
21+
n: z.number().optional(),
22+
stop: z.array(z.string()).optional(),
23+
temperature: z.number().optional(),
24+
max_tokens: z.number().optional(),
2825
});
2926

3027
// OpenAI connector response schema

src/platform/plugins/shared/workflows_management/common/stack_connectors_schema/swimlane.ts

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,44 +16,38 @@ import { z } from '@kbn/zod';
1616

1717
// Swimlane connector parameter schemas for different sub-actions
1818
export const SwimlaneCreateRecordParamsSchema = z.object({
19-
subAction: z.literal('pushToService'),
20-
subActionParams: z.object({
21-
incident: z.object({
22-
ruleName: z.string(),
23-
alertId: z.string(),
24-
severity: z.string().optional(),
25-
description: z.string().optional(),
26-
}),
27-
comments: z
28-
.array(
29-
z.object({
30-
comment: z.string(),
31-
commentId: z.string(),
32-
})
33-
)
34-
.optional(),
19+
incident: z.object({
20+
ruleName: z.string(),
21+
alertId: z.string(),
22+
severity: z.string().optional(),
23+
description: z.string().optional(),
3524
}),
25+
comments: z
26+
.array(
27+
z.object({
28+
comment: z.string(),
29+
commentId: z.string(),
30+
})
31+
)
32+
.optional(),
3633
});
3734

3835
export const SwimlaneUpdateRecordParamsSchema = z.object({
39-
subAction: z.literal('pushToService'),
40-
subActionParams: z.object({
41-
incident: z.object({
42-
ruleName: z.string(),
43-
alertId: z.string(),
44-
severity: z.string().optional(),
45-
description: z.string().optional(),
46-
}),
47-
incidentId: z.string(),
48-
comments: z
49-
.array(
50-
z.object({
51-
comment: z.string(),
52-
commentId: z.string(),
53-
})
54-
)
55-
.optional(),
36+
incident: z.object({
37+
ruleName: z.string(),
38+
alertId: z.string(),
39+
severity: z.string().optional(),
40+
description: z.string().optional(),
5641
}),
42+
incidentId: z.string(),
43+
comments: z
44+
.array(
45+
z.object({
46+
comment: z.string(),
47+
commentId: z.string(),
48+
})
49+
)
50+
.optional(),
5751
});
5852

5953
// Swimlane connector response schema

0 commit comments

Comments
 (0)