Unable to include Special Characters ( ), [ ], ', or $ in Model Names in Spectrum after upgrade to 21.2.8
search cancel

Unable to include Special Characters ( ), [ ], ', or $ in Model Names in Spectrum after upgrade to 21.2.8

book

Article ID: 238716

calendar_today

Updated On:

Products

CA Spectrum DX NetOps

Issue/Introduction

Prior to Spectrum release 21.2.8, you could update the Model Name with special characters like [] () $ '. However, after 21.2.8 upgrade, the following error is thrown if these characters are included in a Model Name:

SPC-OCC-10563: An invalid model name was entered. It should match with the pattern defined.

Environment

DX NetOps Spectrum 21.2.8 or later

Cause

There is a security vulnerability with outside scripts creating models in Spectrum without character validation.   This regex entry addresses the character validation entry and must be edited and/or modified by each individual customer to determine what they will or will not allow.

Resolution

In Spectrum 21.2.8+, a new Regular Expression filter is being used for Model naming:

RegEx for Model Names (broadcom.com)

In the file:

$SPECROOT/tomcat/webapps/spectrum/WEB-INF/topo/config/topo-app-config.xml

There is the following section:

<attribute-config>

    <id>AttributeID.MODEL_NAME</id>

    <verifier>

      <class>com.aprisma.spectrum.app.swing.widget.ModelNameVerifier</class>

      <param name="regex">[\p{L}\p{Digit}/., _-]+</param>

    </verifier>

</attribute-config>

The regex section in green is what you will have to add to to allow other special characters. To match a character having special meaning in regex such as

( ) [ and ]

You need to use a escape sequence prefix with a backslash (\). For example:

\. matches "."

\+ matches "+"

\( matches "("

The last three characters of the regex:

-]+

Meaning if the regex finds any of the preceding characters, anywhere in the given string, then allow it. So you would need to use the escape prefix \ before these special characters:

[\p{L}\p{Digit}/., _\(\)\[\]\$-]+

If & is required, it will need to be encoded like the below:

<param name="regex">[\p{L}\p{Digit}/.', _&amp;-]+</param>

 

You will need to stop and restart the OneClick Tomcat process for the changes to take effect.

 

Spectrum 22.2.5 and onwards:
----------------------------------------

Starting on Spectrum 22.2.5, the default regex was changed to the following:

<param name="regex">[\p{L}\p{Digit}/.', _\(\)\[\]\$&amp;:-]+</param>

This Regex permits the following characters to be inserted:

All Unicode letters (uppercase and lowercase)
All Unicode decimal digit characters
The forward slash character /
The period character .
The comma character ,
The space character _
The parentheses characters (  )
The square brackets characters [  ]
The dollar sign character $
The ampersand character &
The colon character :
The hyphen character –
The single quote character '

Additional Information

Make sure you are editing this file:

$SPECROOT/tomcat/webapps/spectrum/WEB-INF/topo/config/topo-app-config.xml

IMPORTANT: Do not move this or edit the one in custom/topo/config.

Please note your changes may be overwritten during an upgrade. If you want to have new characters added to default Regex, please open an Enhancement Request (ER) case to have them added in a future Spectrum version.

ServerConfigValidation.properties file has the regEx for validating the data entered in the OneClick Administration pages whereas ModelNameVerifier is to validate model name at OC client side. 
Updating the ServerConfigValidation.properties file will not have any effect on ModelName verification.

 

Use the following template to allow editing the " < > " characters:

<param name="regex">[\p{L}\p{Digit}/.', _\(\)\[\]\>\$&lt;&amp;:-]+</param>