Skip to content

Commit

Permalink
[frontend] External reference URL are not properly validated during c…
Browse files Browse the repository at this point in the history
…reation (OpenCTI-Platform#7431)

Co-authored-by: Samuel Hassine <[email protected]>
  • Loading branch information
SarahBocognano and SamuelHassine authored Jul 8, 2024
1 parent 957c9d2 commit 2b09daa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ export const externalReferenceCreationMutation = graphql`
const externalReferenceValidation = (t: (value: string) => string) => Yup.object().shape({
source_name: Yup.string().required(t('This field is required')),
external_id: Yup.string().nullable(),
url: Yup.string().url(t('The value must be an URL')).nullable(),
url: Yup.string()
.nullable()
.matches(
/^(https?:\/\/[^\s/$.?#].[^\s]*)$/,
t('The value must be an URL'),
),
description: Yup.string().nullable(),
file: Yup.mixed().nullable(),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ export const externalReferenceEditionOverviewFocus = graphql`
const externalReferenceValidation = (t: (value: string) => string) => Yup.object().shape({
source_name: Yup.string().required(t('This field is required')),
external_id: Yup.string().nullable(),
url: Yup.string().url(t('The value must be an URL')).nullable(),
url: Yup.string()
.nullable()
.matches(
/^(https?:\/\/[^\s/$.?#].[^\s]*)$/,
t('The value must be an URL'),
),
description: Yup.string().nullable(),
});

Expand Down

0 comments on commit 2b09daa

Please sign in to comment.