File Coverage

blib/lib/Net/SecurityCenter/API/PluginFamily.pm
Criterion Covered Total %
statement 37 38 97.3
branch 5 10 50.0
condition n/a
subroutine 8 8 100.0
pod 3 3 100.0
total 53 59 89.8


line stmt bran cond sub pod time code
1             package Net::SecurityCenter::API::PluginFamily;
2              
3 2     2   730 use warnings;
  2         4  
  2         56  
4 2     2   10 use strict;
  2         3  
  2         32  
5              
6 2     2   8 use Carp;
  2         4  
  2         86  
7              
8 2     2   11 use parent 'Net::SecurityCenter::Base';
  2         4  
  2         16  
9              
10 2     2   112 use Net::SecurityCenter::Utils qw(:all);
  2         4  
  2         1456  
11              
12             our $VERSION = '0.310';
13              
14             my $common_template = {
15              
16             id => {
17             required => 1,
18             allow => qr/^\d+$/,
19             messages => {
20             required => 'Plugin Family ID is required',
21             allow => 'Invalid Plugin Family ID',
22             },
23             },
24              
25             op => {
26             allow => [ 'eq', 'gt', 'gte', 'like', 'lt', 'lte' ]
27             },
28              
29             type => {
30             allow => [ 'active', 'all', 'compliance', 'custom', 'lce', 'notPassive', 'passive' ],
31             },
32              
33             sort_field => {
34             allow => [ 'modifiedTime', 'id', 'name', 'family', 'type' ],
35             remap => 'sortDirection',
36             },
37              
38             sort_direction => {
39             allow => [ 'ASC', 'DESC' ],
40             remap => 'sortDirection',
41             filter => sub { uc $_[0] },
42             },
43              
44             since => {
45             allow => qr/^\d+$/,
46             },
47              
48             start_offset => {
49             allow => qr/^\d+$/,
50             remap => 'startOffset',
51             },
52              
53             end_offset => {
54             allow => qr/^\d+$/,
55             remap => 'endOffset',
56             },
57              
58             filter_field => {
59             allow => [
60             'copyright', 'description', 'exploitAvailable', 'family',
61             'id', 'name', 'patchPubDate', 'patchModDate',
62             'pluginPubDate', 'pluginModDate', 'sourceFile', 'type',
63             'version', 'vulnPubDate', 'xrefs', 'xrefs:',
64             'xrefs:ALAS', 'xrefs:APPLE-SA', 'xrefs:AUSCERT', 'xrefs:BID',
65             'xrefs:CERT', 'xrefs:CERT-CC', 'xrefs:CERT-FI', 'xrefs:CERTA',
66             'xrefs:CISCO-BUG-ID', 'xrefs:CISCO-SA', 'xrefs:CISCO-SR', 'xrefs:CLSA',
67             'xrefs:CONECTIVA', 'xrefs:CVE', 'xrefs:CWE', 'xrefs:DSA',
68             'xrefs:EDB-ID', 'xrefs:FEDORA', 'xrefs:FLSA', 'xrefs:FreeBSD',
69             'xrefs:GLSA', 'xrefs:HP', 'xrefs:HPSB', 'xrefs:IAVA',
70             'xrefs:IAVB', 'xrefs:IAVT', 'xrefs:ICS-ALERT', 'xrefs:ICSA',
71             'xrefs:MDKSA', 'xrefs:MDVSA', 'xrefs:MGASA', 'xrefs:MSFT',
72             'xrefs:MSVR', 'xrefs:NSFOCUS', 'xrefs:NessusID', 'xrefs:OSVDB',
73             'xrefs:OWASP', 'xrefs:OpenPKG-SA', 'xrefs:RHSA', 'xrefs:SSA',
74             'xrefs:Secunia', 'xrefs:SuSE', 'xrefs:TLSA', 'xrefs:TSLSA',
75             'xrefs:USN', 'xrefs:VMSA', 'xrefs:zone-h'
76             ],
77             remap => 'filterField',
78             },
79              
80             fields => {
81             filter => \&sc_filter_array_to_string,
82             },
83              
84             };
85              
86             #-------------------------------------------------------------------------------
87             # METHODS
88             #-------------------------------------------------------------------------------
89              
90             sub list {
91              
92 1     1 1 3 my ( $self, %args ) = @_;
93              
94             my $tmpl = {
95             fields => $common_template->{'fields'},
96             type => $common_template->{'type'},
97             sort_field => $common_template->{'sort_field'},
98             sort_direction => $common_template->{'sort_direction'},
99             since => $common_template->{'since'},
100             filter_field => $common_template->{'filter_field'},
101 1         7 op => $common_template->{'op'},
102             };
103              
104 1         4 my $params = sc_check_params( $tmpl, \%args );
105 1         4 my $response = $self->client->get( '/pluginFamily', $params );
106              
107 1 50       6 return if ( !$response );
108              
109 1 50       8 return wantarray ? @{ sc_normalize_array($response) } : sc_normalize_array($response);
  0         0  
110              
111             }
112              
113             #-------------------------------------------------------------------------------
114              
115             sub list_plugins {
116              
117 1     1 1 3 my ( $self, %args ) = @_;
118              
119             my $tmpl = {
120             fields => $common_template->{'fields'},
121             id => $common_template->{'id'},
122             type => $common_template->{'type'},
123             sort_field => $common_template->{'sort_field'},
124             sort_direction => $common_template->{'sort_direction'},
125             since => $common_template->{'since'},
126             start_offset => $common_template->{'start_offset'},
127             end_offset => $common_template->{'end_offset'},
128             filter_field => $common_template->{'filter_field'},
129 1         9 op => $common_template->{'op'},
130             };
131              
132 1         5 my $params = sc_check_params( $tmpl, \%args );
133 1         3 my $raw = delete( $params->{'raw'} );
134 1         3 my $plugin_family_id = delete( $params->{'id'} );
135 1         5 my $plugins = $self->client->get( "/pluginFamily/$plugin_family_id/plugins", $params );
136              
137 1 50       5 return if ( !$plugins );
138 1 50       3 return $plugins if ($raw);
139 1         5 return sc_normalize_array($plugins);
140              
141             }
142              
143             #-------------------------------------------------------------------------------
144              
145             sub get {
146              
147 1     1 1 4 my ( $self, %args ) = @_;
148              
149             my $tmpl = {
150             fields => $common_template->{'fields'},
151 1         5 id => $common_template->{'id'},
152             };
153              
154 1         5 my $params = sc_check_params( $tmpl, \%args );
155 1         3 my $plugin_family_id = delete( $params->{'id'} );
156              
157 1         10 my $response = $self->client->get( "/pluginFamily/$plugin_family_id", $params );
158              
159 1 50       5 return if ( !$response );
160 1         4 return $response;
161              
162             }
163              
164             #-------------------------------------------------------------------------------
165              
166             1;
167              
168             __END__