Skip to content

SNMP inventory on Fortigate produces invalid IP addresses (concatenation of ipAdEntAddr + ifIndex) #1065

@teopost

Description

@teopost

Bug reporting acknowledgment

Yes, I read it

Professional support

Yes, I know

Describe the bug

When running an SNMP inventory against a Fortigate firewall, the GLPI Agent generates invalid IPv4 addresses in the XML output.
The IP addresses exported under the → and fields contain five octets, such as:

10.10.10.1.1
192.168.1.100.2
37.176.253.36.3
93.42.196.3.4

These values are not valid IPv4 addresses and cause GLPI to reject the inventory import with the following validation error:

JSON does not validate. Violations: Invalid ipv4 / Invalid ipv6 at content->network_ports->ips

This happens because the agent appears to concatenate the value of ipAdEntAddr (.1.3.6.1.2.1.4.20.1.1) with the corresponding ipAdEntIfIndex (.1.3.6.1.2.1.4.20.1.2).
The resulting string is treated as an IP address even though it is not valid.

Fortigate devices do not use IP addresses in this format, so this concatenation is incorrect and leads to invalid output.

To reproduce

  1. Run an SNMP inventory against any Fortigate firewall using GLPI Agent (tested with vX.Y.Z).
  2. Check the generated XML file, specifically the section.
  3. Notice that the and fields contain concatenated values (IP + ifIndex).
  4. Attempt to import the XML into GLPI: the import fails with an IPv4/IPv6 validation error.

Expected behavior

The agent should export only the real IPv4 address retrieved from ipAdEntAddr, without appending the interface index.
Each IP address in the XML should be a valid IPv4 string (A.B.C.D).
GLPI should be able to import the inventory without validation errors.

Operating system

Linux

GLPI Agent version

v1.15

GLPI version

Other (Details in additional context below)

GLPIInventory plugin or other plugin version

Other (Details in additional context below)

Additional context

Environment

GLPI version 11.0.4
GLPI Inventory Plugin  1.6.4

Paths involved in IP extraction (from grep):

/usr/share/glpi-agent/lib/GLPI/Agent/SNMP/Device.pm:386
/usr/share/glpi-agent/lib/GLPI/Agent/SNMP/Device.pm:592

Example XML excerpt (sanitized)

<PORT>
    <IFNAME>wan1</IFNAME>
    <IFNUMBER>3</IFNUMBER>
    <MAC>00:11:22:33:44:55</MAC>
    <IP>37.176.253.36.3</IP>   <!-- Invalid: ipAdEntAddr + ifIndex -->
    <IPS>
        <IP>37.176.253.36.3</IP>
    </IPS>
</PORT>

<PORT>
    <IFNAME>internal</IFNAME>
    <IFNUMBER>12</IFNUMBER>
    <IP>10.0.99.248.12</IP>    <!-- Invalid -->
</PORT>

Correct value should by

37.176.253.36
10.0.99.248

When uploading the XML, GLPI rejects the inventory with the following error:

An error occurs during import: Array ( [0] => JSON does not validate. 
Violations: No valid results for anyOf {
  0: Invalid ipv4 at #->properties:content->properties:network_ports->items[0]:0->properties:ips->items[0]:0->anyOf[0]
  1: Invalid ipv6 at #->properties:content->properties:network_ports->items[0]:0->properties:ips->items[0]:0->anyOf[1]
} at #->properties:content->properties:network_ports->items[0]:0->properties:ips->items[0]:0 )

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions