Skip to content

Commit c319ada

Browse files
committed
Trim Hash value before validating it (#79545)
1 parent c6fa5cd commit c319ada

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

x-pack/plugins/security_solution/common/endpoint/schema/trusted_apps.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,21 @@ describe('When invoking Trusted Apps Schema', () => {
348348
});
349349
}).toThrow();
350350
});
351+
352+
it('should trim hash value before validation', () => {
353+
expect(() => {
354+
body.validate({
355+
...getCreateTrustedAppItem(),
356+
entries: [
357+
{
358+
...getTrustedAppItemEntryItem(),
359+
field: 'process.hash.*',
360+
value: ` ${VALID_HASH_MD5} \r\n`,
361+
},
362+
],
363+
});
364+
}).not.toThrow();
365+
});
351366
});
352367
});
353368
});

x-pack/plugins/security_solution/common/endpoint/schema/trusted_apps.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,15 @@ export const PostTrustedAppCreateRequestSchema = {
5252

5353
usedFields.push(field);
5454

55-
if (
56-
field === 'process.hash.*' &&
57-
(!hashLengths.includes(value.length) || hasInvalidCharacters.test(value))
58-
) {
59-
return `Invalid hash value [${value}]`;
55+
if (field === 'process.hash.*') {
56+
const trimmedValue = value.trim();
57+
58+
if (
59+
!hashLengths.includes(trimmedValue.length) ||
60+
hasInvalidCharacters.test(trimmedValue)
61+
) {
62+
return `Invalid hash value [${value}]`;
63+
}
6064
}
6165
}
6266
},

0 commit comments

Comments
 (0)