aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Youri/Check/Input/Signature.pm
blob: 57b49bc76d7570a0245aeb4ae400af2d13654ff4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# $Id: Rpmlint.pm 567 2005-12-12 21:24:56Z guillomovitch $
package Youri::Check::Input::Signature;

=head1 NAME

Youri::Check::Input::Signature - Check signature

=head1 DESCRIPTION

This plugin checks packages signature, and report unsigned ones. 

=cut

use warnings;
use strict;
use Carp;
use base 'Youri::Check::Input';

sub columns {
    return qw/
        arch
        file
        error
    /;
}

sub links {
    return qw//;
}

=head2 new(%args)

Creates and returns a new Youri::Check::Input::Signature object.

Specific parameters:

=over

=item key $key

Expected GPG key identity

=back

=cut

sub _init {
    my $self    = shift;
    my %options = (
        key => '',
        @_
    );

    $self->{_key} = $options{key};
}

sub run {
    my ($self, $media, $resultset) = @_;
    croak "Not a class method" unless ref $self;

    my $check = sub {
        my ($package) = @_;

        my $arch = $package->get_arch();
        my $name = $package->get_name();

        my $key = $package->get_gpg_key();

        if (!$key) {
            $resultset->add_result($self->{_id}, $media, $package, { 
                arch  => $arch,
                file  => $name,
                error => "unsigned package $name"
            });
        } elsif ($key ne $self->{_key}) {
            $resultset->add_result($self->{_id}, $media, $package, { 
                arch  => $arch,
                file  => $name,
                error => "invalid key id $key for package $name (allowed $self->{_key})"
            });
        }
        
    };

    $media->traverse_headers($check);
}

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2002-2006, YOURI project

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

=cut

1;