| 1 | # | ||
| 2 | # $Id$ | ||
| 3 | # | ||
| 4 | # antivirus::clamav Brik | ||
| 5 | # | ||
| 6 | package Metabrik::Antivirus::Clamav; | ||
| 7 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 1 | ▶ | use base qw(Metabrik::Shell::Command Metabrik::System::Package); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | sub brik_properties { | ||
| 13 | return { | ||
| 14 | revision => '$Revision$', | ||
| 15 | tags => [ qw(unstable) ], | ||
| 16 | author => 'GomoR <GomoR[at]metabrik.org>', | ||
| 17 | license => 'http://opensource.org/licenses/BSD-3-Clause', | ||
| 18 | attributes => { | ||
| 19 | datadir => [ qw(datadir) ], | ||
| 20 | }, | ||
| 21 | attributes_default => { | ||
| 22 | use_sudo => 0, | ||
| 23 | }, | ||
| 24 | commands => { | ||
| 25 | install => [ ], # Inherited | ||
| 26 | update => [ ], | ||
| 27 | scan => [ qw(target) ], # file or directory | ||
| 28 | }, | ||
| 29 | require_binaries => { | ||
| 30 | 'freshclam' => [ ], | ||
| 31 | 'clamscan' => [ ], | ||
| 32 | }, | ||
| 33 | need_packages => { | ||
| 34 | ubuntu => [ qw(clamav) ], | ||
| 35 | debian => [ qw(clamav) ], | ||
| 36 | kali => [ qw(clamav) ], | ||
| 37 | }, | ||
| 38 | }; | ||
| 39 | } | ||
| 40 | |||
| 41 | sub update { | ||
| 42 | my $self = shift; | ||
| 43 | |||
| 44 | my $datadir = $self->datadir; | ||
| 45 | |||
| 46 | my $cmd = "freshclam"; | ||
| 47 | |||
| 48 | $self->log->verbose($cmd); | ||
| 49 | |||
| 50 | return $self->sudo_system($cmd); | ||
| 51 | } | ||
| 52 | |||
| 53 | sub scan { | ||
| 54 | my $self = shift; | ||
| 55 | my ($target) = @_; | ||
| 56 | |||
| 57 | $self->brik_help_run_undef_arg('scan', $target) or return; | ||
| 58 | |||
| 59 | my $datadir = $self->datadir; | ||
| 60 | if (! -f $target && ! -d $target) { | ||
| 61 | return $self->log->error("scan: target [$target] not found"); | ||
| 62 | } | ||
| 63 | |||
| 64 | my $cmd = "clamscan -r -l $datadir/out.av -i $target"; | ||
| 65 | |||
| 66 | return $self->system($cmd); | ||
| 67 | } | ||
| 68 | |||
| 69 | 1; | ||
| 70 | |||
| 71 | __END__ | ||