]> git.proxmox.com Git - pmg-api.git/blob - PMG/RuleDB/Virus.pm
fix otype attribute
[pmg-api.git] / PMG / RuleDB / Virus.pm
1 package PMG::RuleDB::Virus;
2
3 use strict;
4 use warnings;
5 use Carp;
6 use DBI;
7 use Digest::SHA;
8
9 use PMG::Utils;
10 use PMG::RuleDB::Object;
11
12 use base qw(PMG::RuleDB::Object);
13
14 sub otype {
15 return 3001;
16 }
17
18 sub oclass {
19 return 'what';
20 }
21
22 sub otype_text {
23 return 'Virus Filter';
24 }
25
26 sub oicon {
27 return 'virusdetect.gif';
28 }
29
30 sub oisedit {
31 return 0;
32 }
33
34 sub new {
35 my ($type, $ogroup) = @_;
36
37 my $class = ref($type) || $type;
38
39 my $self = $class->SUPER::new($class->otype(), $ogroup);
40
41 return $self;
42 }
43
44 sub load_attr {
45 my ($type, $ruledb, $id, $ogroup, $value) = @_;
46
47 my $class = ref($type) || $type;
48
49 my $obj = $class->new ($ogroup);
50 $obj->{id} = $id;
51
52 $obj->{digest} = Digest::SHA::sha1_hex($id, $ogroup);
53
54 return $obj;
55 }
56
57 sub save {
58 my ($self, $ruledb) = @_;
59
60 defined($self->{ogroup}) || return undef;
61
62 if (defined ($self->{id})) {
63 # update
64
65 # nothing to update
66 } else {
67 # insert
68
69 my $sth = $ruledb->{dbh}->prepare(
70 "INSERT INTO Object (Objectgroup_ID, ObjectType) VALUES (?, ?);");
71
72 $sth->execute($self->ogroup, $self->otype);
73
74 $self->{id} = PMG::Utils::lastid($ruledb->{dbh}, 'object_id_seq');
75 }
76
77 return $self->{id};
78 }
79
80 sub what_match {
81 my ($self, $queue, $entity, $msginfo) = @_;
82
83 if ($queue->{vinfo}) {
84 return [];
85 }
86
87 return undef;
88 }
89
90 sub short_desc {
91 my $self = shift;
92
93 return "active";
94 }
95
96 1;
97
98 __END__
99
100 =head1 PMG::RuleDB::Virus
101
102 Virus filter