generate _cpe_vendor and _cpe_parser fields in LDAP_search response
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 9 Jul 2011 19:09:27 +0000 (21:09 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 9 Jul 2011 19:09:27 +0000 (21:09 +0200)
lib/APKPM/LDAP.pm

index 3002d5f..9b1dd94 100644 (file)
@@ -40,6 +40,18 @@ sub search : Job : Encode(e_json) : MinProcesses(0) {
                my $e = { dn => $entry->dn };
                foreach my $attr ( $entry->attributes ) {
                        $e->{$attr} = join("\n", $entry->get_value($attr));
+                       if ( $attr =~ m/dhcpOption/ ) {
+                               my $vendor = (
+                                       grep { /vendor-class-identifier/ }
+                                       $entry->get_value($attr)
+                               )[0];
+                               $vendor =~ s/^\S+\s+\"([^"]+)\"/$1/;
+                               $e->{_cpe_vendor} = $vendor;
+                               $e->{_cpe_parser} =
+                                       $vendor =~ m/SAMSUNG/ ? 'Davolink' :
+                                       $vendor =~ m/zte/     ? 'EasyGateway' :
+                                       undef;
+                       }
                }
                push @$entries, $e;
        }