Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SECURITY_SOLUTION][ENDPOINT] Trusted Apps - fix error for duplicate fields to correctly mention the field at fault #79853

Merged
Changes from 1 commit
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 @@ -5,6 +5,7 @@
*/

import { schema } from '@kbn/config-schema';
import { TrustedApp } from '../types';

const hashLengths: readonly number[] = [
32, // MD5
Expand All @@ -13,6 +14,12 @@ const hashLengths: readonly number[] = [
];
const hasInvalidCharacters = /[^0-9a-f]/i;

const entryFieldLabels: { [k in TrustedApp['entries'][0]['field']]: string } = {
'process.hash.*': 'Hash',
'process.executable.caseless': 'Path',
'process.code_signature': 'Signer',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Signer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, its already part of the Type (TrustedApp), thus its coming up as required in this object (typescript error). I did not want to exclude it out of the type here in order to keep the type simpler.

};

export const DeleteTrustedAppsRequestSchema = {
params: schema.object({
id: schema.string(),
Expand Down Expand Up @@ -47,7 +54,7 @@ export const PostTrustedAppCreateRequestSchema = {
const usedFields: string[] = [];
for (const { field, value } of entries) {
if (usedFields.includes(field)) {
return `[Hash] field can only be used once`;
return `[${entryFieldLabels[field]}] field can only be used once`;
}

usedFields.push(field);
Expand Down