diff --git a/opencti-platform/opencti-graphql/src/utils/syntax.js b/opencti-platform/opencti-graphql/src/utils/syntax.js index 817c862a07f8..fcec243d19e2 100644 --- a/opencti-platform/opencti-graphql/src/utils/syntax.js +++ b/opencti-platform/opencti-graphql/src/utils/syntax.js @@ -135,7 +135,7 @@ export const cleanupIndicatorPattern = (patternType, pattern) => { }; export const systemChecker = /^\d{0,10}$/; -export const domainChecker = /^(?:(?:[\p{L}\d_]+\.?)*[\p{L}\d_]+\.)?[\p{L}\d]+(?:\.[\p{L}]{2,})?$/u; +export const domainChecker = /^(?:(?:[\p{L}\d_-]+\.)*[\p{L}\d_-]+\.)?[\p{L}\d-]+(?:\.[\p{L}]{2,})?$/u; export const hostnameChecker = /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-_]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-_]*[A-Za-z0-9])$/; export const emailChecker = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/; export const ipv6Checker = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))(?:\/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8]))?$/; diff --git a/opencti-platform/opencti-graphql/tests/01-unit/utils/syntax-test.ts b/opencti-platform/opencti-graphql/tests/01-unit/utils/syntax-test.ts index 2172e6ae3eac..8bf94e125d5c 100644 --- a/opencti-platform/opencti-graphql/tests/01-unit/utils/syntax-test.ts +++ b/opencti-platform/opencti-graphql/tests/01-unit/utils/syntax-test.ts @@ -14,6 +14,8 @@ describe('Regex Pattern Tests', () => { expect('løveskateboards.com').toMatch(domainChecker); expect('test._mysubdomain.mydomain.com').toMatch(domainChecker); expect('test_mysubdomain.domain.io').toMatch(domainChecker); + expect('test-test.com').toMatch(domainChecker); + expect('test-test.mytest.com').toMatch(domainChecker); expect('invalid_domain.12_3').not.toMatch(domainChecker); expect('invalid_domain').not.toMatch(domainChecker); });