From b9fd6bbb91056649f3dde5570d37fc47f05825d7 Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Mon, 13 May 2013 20:06:46 +0200 Subject: [PATCH] =?UTF-8?q?[dnsAttr]=20On=20verifie=20que=20le=20domaine?= =?UTF-8?q?=20existe,=20les=20nom=20commen=C3=A7ant=20par=20une=20chiffre?= =?UTF-8?q?=20sont=20valident?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit par exemple 4chan.org. Si on ne vérifie pas le domaine, on permet à l'utilisateur de mettre des points dans les noms de machines, ce qui n'est pas souhaitable. --- attributs.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/attributs.py b/attributs.py index 6bce468..acf3f62 100644 --- a/attributs.py +++ b/attributs.py @@ -508,8 +508,10 @@ class dnsAttr(Attr): category = 'dns' def parse_value(self, val): val = val.lower() - name, _ = val.split('.', 1) - if not re.match('^[a-z](-*[a-z0-9]+)*$', name): + name, domain = val.split('.', 1) + if not domain in ['ferme.crans.org', 'crans.org', 'federez.net', 'wifi.crans.org', 'adm.crans.org', 'crans.ens-cachan.fr']: + raise ValueError("Nom d'hote invalide %r" % val) # somme toute vraisemblance il y a un point dans le nom de la machine + if not re.match('^[a-z0-9](-*[a-z0-9]+)*$', name): raise ValueError("Nom d'hote invalide %r" % val) self.value = val