The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Varsha Srinivas
ServiceNow Employee
ServiceNow Employee

Issue:

"name" field of software installations/software packages is not consistent for different versions of Visual C++ packages.
Some include version, some doesn't, and some has "-" at the end.

For example:

Microsoft Visual C++ 2008 Redistributable - x86
Microsoft Visual C++ 2015-2019 Redistributable (x86) - 14.27.29016
Microsoft Visual C++ 2019 X64 Minimum Runtime -

 

Payload data - 

{
"cmdb_ci_spkg":{
"data":[
{
"msi_id":"E493B8F4-E300-43EC-95D0-BDF3711297EA",
"uniqueName":"Microsoft Visual C++ 2019 X64 Minimum Runtime - 14.27.29016 14.27.29016",
"uninstall_string":"MsiExec.exe /I{E493B8F4-E300-43EC-95D0-BDF3711297EA}",
"vendor":"Microsoft Corporation",
"name":"Microsoft Visual C++ 2019 X64 Minimum Runtime - 14.27.29016",
"install_date":"2021-07-19 17:00:00",
"version":"14.27.29016"
},
{
"uniqueName":"Microsoft Visual C++ 2015-2019 Redistributable (x86) - 14.27.29016 14.27.29016.0",
"uninstall_string":"\"C:\\ProgramData\\Package Cache\\{1aaa01ad-3069-4288-9c6f-37a140a8f6c7}\\VC_redist.x86.exe\" /uninstall",
"vendor":"Microsoft Corporation",
"name":"Microsoft Visual C++ 2015-2019 Redistributable (x86) - 14.27.29016",
"install_date":"",
"version":"14.27.29016.0"
},
{
"msi_id":"9BE518E6-ECC6-35A9-88E4-87755C07200F",
"uniqueName":"Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.6161 9.0.30729.6161",
"uninstall_string":"MsiExec.exe /X{9BE518E6-ECC6-35A9-88E4-87755C07200F}",
"vendor":"Microsoft Corporation",
"name":"Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.6161",
"install_date":"2019-09-02 17:00:00",
"version":"9.0.30729.6161"
}
],
"refName":"",
"keyName":"",
"deleteGr":false
}
}

 

Root cause:

The payload goes through the SoftwareMunger.java where the name is trimmed in the below function
===================================================================
private void mungeName(Map software) {
String name = (String) software.get(NAME);
String version = (String) software.get(VERSION);
if (StringUtil.nil(version)) {
Matcher mat = PAT_VERSION_IN_NAME.matcher(name);
name = mat.matches() ? mat.group(1) : name;
version = mat.matches() ? mat.group(2) : "";
} else {
name = deleteTrailing(name, version).trim(); <===================
name = deleteTrailing(name, ",").trim();
}
//code snippet
}
==================================================
private String deleteTrailing(String str, String trailing) {
if (StringUtil.nil(str) || StringUtil.nil(trailing))
return str;

if (str.length() <= trailing.length())
return str;

if (!str.endsWith(trailing))
return str;

return str.substring(0, str.length() - trailing.length());
}


The version is not trimmed off in the Microsoft Visual C++ 2015-2019 Redistributable (x86) - 14.27.29016 because it's version contains an extra 0 at the end

 

Work around:

The work around for the issue is to create field transformation on the name field that avoids the inconsistency. Please refer the attached document for the detailed step by step fix

 

Version history
Last update:
‎10-04-2021 09:42 AM
Updated by: