Pandora FMS Community

CIDR regex in manage_recontask.php

catdude · 10 dic 2014, 20:56 · 3 mensajes · 55 visitas

  1. Inicio del debate

    Yesterday I was looking through the code, trying to determine why I was encountering an error setting up a recon server. In the process, I looked at the CIDR regex in servers/manage_recontask.php. The line in question reads: if (($id_recon_script == 'NULL') && preg_match("/[0-9]+.+[0-9]+.+[0-9]+.+[0-9]+/+[0-9]/", $network)) My question is, using this regex wouldn't the last part ("/+[0-9]/") match only a single digit in the width expression? Shouldn't it actually be "/+[0-9]+/" to allow for 2-digit prefix size?

  2. hello, Thanks for the report. It is a bug, will be fixed for the next update. Proof: 0 + 2digit-ip. For example, if 10.0.0.1, try typing, 010,001,001. Regards

  3. Actually, as I look at this a little closer, I realize that another change to the regex could improve input safety. Using the existing regex, if someone entered a bizarrely weird value like "128445.97458754.975487.937859745/99" it would match. If we replace the preg_match string with "/[0-9]{1,3}.+[0-9]{1,3}.+[0-9]{1,3}.+[0-9]{1,3}/+[0-9]{1,2}/" we could at least verify that a legal number of digits is present in each octet and in the width prefix. Would this change to too pedantic, or would it be worthwhile?

Entra en tu cuenta para publicar.