Skip to content

Commit 3ca94f4

Browse files
Corrected the regexes
1 parent 98349bd commit 3ca94f4

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

sormas-api/src/main/java/de/symeda/sormas/api/i18n/Validations.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,8 @@ public interface Validations {
277277
String systemConfigurationValueValidationNotAFile = "systemConfigurationValueValidationNotAFile";
278278
String systemConfigurationValueValidationNotAIPAddr = "systemConfigurationValueValidationNotAIPAddr";
279279
String systemConfigurationValueValidationNotANumber = "systemConfigurationValueValidationNotANumber";
280-
String systemConfigurationValueValidationNotAValidName = "systemConfigurationValueValidationNotAValidName";
280+
String systemConfigurationValueValidationNotAValidEmailsenderName = "systemConfigurationValueValidationNotAValidEmailsenderName";
281+
String systemConfigurationValueValidationNotAValidSmsSenderName = "systemConfigurationValueValidationNotAValidSmsSenderName";
281282
String systemConfigurationValueValidationNotValid = "systemConfigurationValueValidationNotValid";
282283
String taskMissingCaseLink = "taskMissingCaseLink";
283284
String taskMissingContactLink = "taskMissingContactLink";

sormas-api/src/main/resources/validations.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ systemConfigurationValueValidationNotANumber = Value is not a valid number
324324
systemConfigurationValueValidationNotADirectory = Value is not a valid directory
325325
systemConfigurationValueValidationNotAFile = Value is not a valid file
326326
systemConfigurationValueValidationNotAEmail = Value is not a valid email address
327-
systemConfigurationValueValidationNotAValidName = Value is not a valid name. Name should contain only letters and numbers without spaces & special characters. For more info please see https://developer.vonage.com/en/messaging/sms/guides/custom-sender-id .
327+
systemConfigurationValueValidationNotAValidEmailsenderName = Value is not a valid email sender name. Name should contain only alphabets.
328+
systemConfigurationValueValidationNotAValidSmsSenderName = Value is not a valid name. Name should contain only letters and numbers without spaces & special characters. For more info please see https://developer.vonage.com/en/messaging/sms/guides/custom-sender-id .
328329
smsAuthKeyValueValidation = SMS Auth key value is not valid
329330
smsAuthSecretValueValidation = SMS Auth secret value is not valid

sormas-backend/src/main/resources/sql/sormas_schema.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14145,8 +14145,8 @@ WHERE category_id = email_configuration_id
1414514145
INSERT INTO systemconfigurationvalue(config_key, config_value, category_id, value_optional, value_pattern,
1414614146
value_encrypt, data_provider, validation_message, changedate, creationdate, id,
1414714147
uuid)
14148-
VALUES ('EMAIL_SENDER_NAME', 'SORMAS Support', email_configuration_id, true, '\s*[^\s]+', false, null,
14149-
'i18n/systemConfigurationValueValidationNotAValidName', now(), now(), nextval('entity_seq'),
14148+
VALUES ('EMAIL_SENDER_NAME', 'SORMAS Support', email_configuration_id, true, '^[A-Za-z]+( [A-Za-z]+)*$', false, null,
14149+
'i18n/systemConfigurationValueValidationNotAValidEmailsenderName', now(), now(), nextval('entity_seq'),
1415014150
generate_base32_uuid());
1415114151

1415214152

@@ -14162,8 +14162,8 @@ INSERT INTO systemconfigurationvalue(config_key, config_value, category_id, valu
1416214162
value_encrypt, data_provider, validation_message, changedate, creationdate, id,
1416314163
uuid)
1416414164
VALUES ('SMS_SENDER_NAME', '', sms_configuration_id, true,
14165-
'^((?:[1-9]{2}[0-9]{0,13})|(?:[A-Za-z1-9]{1}[A-Za-z0-9]{1,10}))$', false, null,
14166-
'i18n/systemConfigurationValueValidationNotAValidName', now(), now(), nextval('entity_seq'),
14165+
'^(([1-9]{2}[0-9]{0,13})|([A-Za-z1-9]{1}[A-Za-z0-9]{0,10}))$', false, null,
14166+
'i18n/systemConfigurationValueValidationNotAValidSmsSenderName', now(), now(), nextval('entity_seq'),
1416714167
generate_base32_uuid());
1416814168

1416914169
DELETE

sormas-backend/src/test/java/de/symeda/sormas/backend/systemconfiguration/SystemConfigurationValueFacadeEJbTest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,9 @@ void testValidateSystemConfigurationValuePipeSeparatedWordsPatternFail() {
232232
@CsvSource({
233233
"'^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$', 192.168.1.1",
234234
"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$, test@sormas.org", // Valid email
235-
"'^((?:[1-9]{2}[0-9]{0,13})|(?:[A-Za-z1-9]{1}[A-Za-z0-9]{1,10}))$', 'abcXYZ123'", // Valid sms sender name as name
236-
"'^((?:[1-9]{2}[0-9]{0,13})|(?:[A-Za-z1-9]{1}[A-Za-z0-9]{0,10}))$', '12345678901234'", // Valid sms sender as phone number
235+
"^[A-Za-z]+( [A-Za-z]+)*$, Sormas Support", // Valid email sender name
236+
"'^(([1-9]{2}[0-9]{0,13})|([A-Za-z1-9]{1}[A-Za-z0-9]{0,10}))$', 'abcXYZ123'", // Valid sms sender name as name
237+
"'^(([1-9]{2}[0-9]{0,13})|([A-Za-z1-9]{1}[A-Za-z0-9]{0,10}))$', '12345678901234'", // Valid sms sender as phone number
237238
"'\\s*[^\\s]+', 'abCD12!@efGH34#$'", // Valid Auth Key
238239
"'(?i)(secret|password|token|api[_-]?key)\\s*[:=]\\s*[^\\s]+', 'apiKey=sormas2025orgKEY'", // Valid secret api key
239240
"'(?i)(secret|password|token|api[_-]?key)\\s*[:=]\\s*[^\\s]+', 'Secret : s3cr3tV@lu3P@ssw0rd!'", // Valid secret key
@@ -257,9 +258,10 @@ void testValidateSystemConfigurationValuePattern(String pattern, String value) {
257258
@ParameterizedTest
258259
@CsvSource({
259260
"'^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$', 1.234343.2.3", // invalid IP
260-
"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$, test.sormas.org", // Invalid email
261-
"'^((?:[1-9]{2}[0-9]{0,13})|(?:[A-Za-z1-9]{1}[A-Za-z0-9]{1,10}))$', 'abc XYZ123'", // Invalid sms sender name as name
262-
"'^((?:[1-9]{2}[0-9]{0,13})|(?:[A-Za-z1-9]{1}[A-Za-z0-9]{0,10}))$', 'ABCdefHI055202'", // Invalid sms sender as phone number
261+
"'^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$', test.sormas.org", // Invalid email
262+
"'^[A-Za-z]+( [A-Za-z]+)*$', Sormas 123", // Valid email sender name
263+
"'^(([1-9]{2}[0-9]{0,13})|([A-Za-z1-9]{1}[A-Za-z0-9]{0,10}))$', 'abc XYZ123'", // Invalid sms sender name as name
264+
"'^(([1-9]{2}[0-9]{0,13})|([A-Za-z1-9]{1}[A-Za-z0-9]{0,10}))$', 'ABCdefHI055202'", // Invalid sms sender as phone number
263265
"'\\s*[^\\s]+', 'abCD12 !@efG H34#$'", // Valid Auth Key
264266
"'(?i)(secret|password|token|api[_-]?key)\\s*[:=]\\s*[^\\s]+', 'apiKey=abcd EFGH1234ijk lMNOP'", // Invalid secret api key
265267
"'(?i)(secret|password|token|api[_-]?key)\\s*[:=]\\s*[^\\s]+', 'Secret : s3cr3 tV@lu3P@ ssw0rd!'", // Invalid secret key

0 commit comments

Comments
 (0)