Project

General

Profile

Revision 8ef154dd

ID8ef154dd268a7f5abaaa9fb337060bb1c16a07dd
Parent 420b5990
Child 925171f8

Added by Francois POIROTTE about 7 years ago

[#1638] Echappement noms d'interfaces/partitions

La recherche des partitions/interfaces se fait par expression régulière
dans GLPI. Il faut donc échapper les méta-caractères susceptibles
d'interférer et présents dans les noms d'interfaces/partitions.

Change-Id: Iba22348ca9baeb9ab115bd85e2866957a668194f
Refs: #1638
Reviewed-on: https://vigilo-dev.si.c-s.fr/review/2574
Tested-by: Build system <>
Reviewed-by: Yves OUATTARA <>
Reviewed-by: Francois POIROTTE <>

View differences:

src/plugins/vigilo/inc/abstractmonitoreditem.class.php
46 46
        );
47 47
    }
48 48

  
49
    protected static function escapeRegex($regex)
50
    {
51
        $res = preg_quote($regex);
52
        $res = preg_replace("/[\x80-\xFF]+/",'.+', $res);
53
        return $res;
54
    }
55

  
49 56
    protected function selectTemplates()
50 57
    {
51 58
        $template = isset($this->item->fields['vigilo_template']) ?
......
136 143
            $this->children[] =
137 144
                        $test = new VigiloTest('Interface');
138 145
            $test['label']  = $label;
139
            $test['ifname'] = $port->getName();
146
            $test['ifname'] = self::escapeRegex($port->getName());
140 147

  
141 148
            $ethport    = $ethport->find('networkports_id=' . $np['id']);
142 149
            foreach ($ethport as $rowEthPort) {
src/plugins/vigilo/inc/monitoredcomputer.class.php
70 70
            $this->children[] =
71 71
                        $test = new VigiloTest('Partition');
72 72
            $test['label']      = $disk->getName();
73
            $test['partname']   = $disk->fields['mountpoint'];
73
            $test['partname']   = self::escapeRegex($disk->fields['mountpoint']);
74 74
            if (!empty($total)) {
75 75
                $test[] = new VigiloArg('max', $total * 1024 * 1024);
76 76
            }

Also available in: Unified diff