glpi-project / glpi-agent

GLPI Agent
GNU General Public License v2.0
252 stars 61 forks source link

GLPI Agent 1.8 Required property missing: name, data: {"publisher":"Carter "} #681

Closed FrostJanV closed 6 months ago

FrostJanV commented 6 months ago

Bug reporting acknowledgment

Yes, I read it

Professional support

Yes, I know

Describe the bug

Hello everyone, unfortunately I get the following message with the GLPI Agent in version 1.8: ERROR: 400 Bad Request, JSON does not validate. Violations: Required property missing: name, data: {“publisher”: “Carter”} at #->properties:content->properties:softwares->items[534]:534

I do not get this message with the GLPI Agent in Version 1.7.3.

The “Inventory XML” contains the following:

<SOFTWARES>
      <PUBLISHER>Carter </PUBLISHER>
</SOFTWARES>

In the registry I cannot find an entry under “Publisher” with the value “Carter ” Using a WMI query, I could not find any software product that has “Carter ” as its publisher.

To reproduce

  1. Update GLPI Agent from 1.7.3 to 1.8
  2. Run Inventory

Expected behavior

XML is not sent and the following error appears: ERROR: 400 Bad Request, JSON does not validate. Violations: Required property missing: name, data: {"publisher":"Carter "} at #->properties:content->properties:softwares->items[534]:534

Operating system

Windows

GLPI Agent version

1.8

GLPI version

10.0.12

GLPIInventory plugin or other plugin version

No response

Additional context

No response

g-bougard commented 6 months ago

Hi @FrostJanV

thank you for your report.

It looks like a regression as I worked on enhanced publisher support. But I still don't see why this can affect windows inventory. I will audit the changed code to see what I could have missed.

g-bougard commented 6 months ago

In registry, did you check under:

  1. HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall
  2. HKEY_LOCAL_MACHINE/SOFTWARE/Wow6432Node/Microsoft/Windows/CurrentVersion/Uninstall
  3. In the case you enabled scan-profiles option:
    1. any of HKEY_USERS/*/SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall
    2. any of HKEY_USERS/*/SOFTWARE/Wow6432Node/Microsoft/Windows/CurrentVersion/Uninstall

If you find it, can you export the related parent registry key from regedit and share it here ?

FrostJanV commented 6 months ago

Hi @g-bougard,

Thanks for your feedback I have searched for the key with the following script:

$SoftwarePub = @("Carter")

$HKLM = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*"
$HKLM_Wow = "HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
$HKCU = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*"

$registryKeys = Get-ChildItem $HKLM, $HKLM_Wow, $HKCU -ErrorAction SilentlyContinue

$installedSoftware = foreach ($key in $registryKeys) {
    $publisher = $key.GetValue("Publisher")
    if ($SoftwarePub | Where-Object { $publisher -like "*$_*" }) {
        [PSCustomObject]@{
            DisplayName = $key.GetValue("DisplayName")
            Publisher = $publisher
            Version = $key.GetValue("DisplayVersion")
            InstallDate = $key.GetValue("InstallDate")
        }
    }
}

$installedSoftware | Select-Object DisplayName, Publisher, Version, InstallDate

I also just searched under HKEY_USERS and found nothing except this:

Computer\HKEY_USERS\S....\SOFTWARE\Microsoft\Notepad image

g-bougard commented 6 months ago

So can you provide a full export of the Computer\HKEY_USERS\S....\SOFTWARE\Microsoft\Notepad registry key ? You can of course obfuscate the user sid in the exported reg file.

So you also confirm you're using scan-profiles option.

g-bougard commented 6 months ago

And can you disable scan-profiles option to see if this at least fixes the problem ?

FrostJanV commented 6 months ago

Hey,

sorry to have taken up your time. Found the error. We do not use the scan-profiles option but an “AdditionalContent” option which our GLPI partner has built. If I upload the XML without this AdditionalContents it works...

I will probably have to contact the partner to adapt this VB script.