Bug: librenms fails to find all device groups containing only numbers in name

Example:

~ czibolski ❯❯❯ curl -H "X-Auth-Token: $LIBRE_TOKEN" https://librenms.infra.rigetti.com/api/v0/devicegroups/FMT
{
    "status": "ok",
    "devices": [
        {
            "device_id": 8
        },
        {
            "device_id": 9
        },
        {
            "device_id": 25
        },
        {
            "device_id": 26
        },
        {
            "device_id": 27
        },
        {
            "device_id": 28
        },
        {
            "device_id": 29
        },
        {
            "device_id": 30
        },
        {
            "device_id": 31
        }
    ],
    "count": 9
}%
~ czibolski ❯❯❯ curl -H "X-Auth-Token: $LIBRE_TOKEN" https://librenms.infra.rigetti.com/api/v0/devicegroups/775
{
    "status": "error",
    "message": "Device group not found"
}%

You can see it’s calling ctype_digit($name) which according to documentation (https://www.php.net/manual/en/function.ctype-digit.php) fails if it’s an integer, rather than a string containing an integer, eg:

$numeric_string = '42';
$integer        = 42;

ctype_digit($numeric_string);  // true
ctype_digit($integer);         // false (ASCII 42 is the * character)

This topic was automatically closed 186 days after the last reply. New replies are no longer allowed.