Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,21 @@ describe('When invoking Trusted Apps Schema', () => {
});
}).toThrow();
});

it('should trim hash value before validation', () => {
expect(() => {
body.validate({
...getCreateTrustedAppItem(),
entries: [
{
...getTrustedAppItemEntryItem(),
field: 'process.hash.*',
value: ` ${VALID_HASH_MD5} \r\n`,
},
],
});
}).not.toThrow();
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,15 @@ export const PostTrustedAppCreateRequestSchema = {

usedFields.push(field);

if (
field === 'process.hash.*' &&
(!hashLengths.includes(value.length) || hasInvalidCharacters.test(value))
) {
return `Invalid hash value [${value}]`;
if (field === 'process.hash.*') {
const trimmedValue = value.trim();

if (
!hashLengths.includes(trimmedValue.length) ||
hasInvalidCharacters.test(trimmedValue)
) {
return `Invalid hash value [${value}]`;
}
}
}
},
Expand Down