Skip to content

Commit 524ab01

Browse files
Remove string as a valid registry var type value (#94174) (#94752)
Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Jen Huang <[email protected]>
1 parent a8eb5a9 commit 524ab01

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

x-pack/plugins/fleet/common/types/models/epm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ export interface RegistryElasticsearch {
274274
'index_template.mappings'?: object;
275275
}
276276

277+
export type RegistryVarType = 'integer' | 'bool' | 'password' | 'text' | 'yaml' | 'string';
277278
export enum RegistryVarsEntryKeys {
278279
name = 'name',
279280
title = 'title',
@@ -286,7 +287,6 @@ export enum RegistryVarsEntryKeys {
286287
os = 'os',
287288
}
288289

289-
export type RegistryVarType = 'integer' | 'bool' | 'password' | 'text' | 'yaml' | 'string';
290290
// EPR types this as `[]map[string]interface{}`
291291
// which means the official/possible type is Record<string, any>
292292
// but we effectively only see this shape

x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/services/validate_package_policy.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,7 @@ export const validatePackagePolicyConfig = (
229229
})
230230
);
231231
}
232-
if (
233-
(varDef.type === 'text' || varDef.type === 'string') &&
234-
parsedValue &&
235-
Array.isArray(parsedValue)
236-
) {
232+
if (varDef.type === 'text' && parsedValue && Array.isArray(parsedValue)) {
237233
const invalidStrings = parsedValue.filter((cand) => /^[*&]/.test(cand));
238234
// only show one error if multiple strings in array are invalid
239235
if (invalidStrings.length > 0) {
@@ -247,11 +243,7 @@ export const validatePackagePolicyConfig = (
247243
}
248244
}
249245

250-
if (
251-
(varDef.type === 'text' || varDef.type === 'string') &&
252-
parsedValue &&
253-
!Array.isArray(parsedValue)
254-
) {
246+
if (varDef.type === 'text' && parsedValue && !Array.isArray(parsedValue)) {
255247
if (/^[*&]/.test(parsedValue)) {
256248
errors.push(
257249
i18n.translate('xpack.fleet.packagePolicyValidation.quoteStringErrorMessage', {

x-pack/plugins/fleet/server/services/epm/agent/agent.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,14 @@ my-package:
193193
{{{ search }}} | streamstats`;
194194

195195
const vars = {
196-
asteriskOnly: { value: '"*"', type: 'string' },
197-
startsWithAsterisk: { value: '"*lala"', type: 'string' },
198-
numeric: { value: '100', type: 'string' },
199-
mixed: { value: '1s', type: 'string' },
200-
a: { value: '/opt/package/*', type: 'string' },
201-
b: { value: '/logs/my.log*', type: 'string' },
202-
c: { value: '/opt/*/package/', type: 'string' },
203-
d: { value: 'logs/*my.log', type: 'string' },
196+
asteriskOnly: { value: '"*"', type: 'text' },
197+
startsWithAsterisk: { value: '"*lala"', type: 'text' },
198+
numeric: { value: '100', type: 'text' },
199+
mixed: { value: '1s', type: 'text' },
200+
a: { value: '/opt/package/*', type: 'text' },
201+
b: { value: '/logs/my.log*', type: 'text' },
202+
c: { value: '/opt/*/package/', type: 'text' },
203+
d: { value: 'logs/*my.log', type: 'text' },
204204
search: { value: 'search sourcetype="access*"', type: 'text' },
205205
};
206206

0 commit comments

Comments
 (0)