File Coverage

blib/lib/Proc/ProcessTable/Match/KernProc.pm
Criterion Covered Total %
statement 8 35 22.8
branch 0 12 0.0
condition 0 3 0.0
subroutine 3 5 60.0
pod 2 2 100.0
total 13 57 22.8


line stmt bran cond sub pod time code
1             package Proc::ProcessTable::Match::KernProc;
2              
3 1     1   57268 use 5.006;
  1         11  
4 1     1   6 use strict;
  1         1  
  1         17  
5 1     1   4 use warnings;
  1         2  
  1         226  
6              
7             =head1 NAME
8              
9             Proc::ProcessTable::Match::KernProc - Attempts to match the kernel processes.
10              
11             =head1 VERSION
12              
13             Version 0.0.0
14              
15             =cut
16              
17             our $VERSION = '0.0.0';
18              
19             =head1 SYNOPSIS
20              
21             use Proc::ProcessTable::Match::KernProc;
22            
23             my $checker=Proc::ProcessTable::Match::KernProc->new;
24            
25             if ( $checker->match( $proc ) ){
26             print "It matches.\n";
27             }
28              
29             This modules functions via looking for processes matching the following.
30              
31             UID == 0
32             fname present
33             cmndline =~ /^$/
34              
35             =head1 METHODS
36              
37             =head2 new
38              
39             This intiates the object.
40              
41             my $checker=Proc::ProcessTable::Match::KernProc->new;
42              
43             =cut
44              
45             sub new{
46 0     0 1   my $self = {
47             };
48 0           bless $self;
49              
50 0           return $self;
51             }
52              
53             =head2 match
54              
55             Checks if a single Proc::ProcessTable::Process object matches the stack.
56              
57             One argument is taken and that is a Proc::ProcessTable::Process object.
58              
59             The returned value is a boolean.
60              
61             if ( $checker->match( $proc ) ){
62             print "The connection matches.\n";
63             }
64              
65             =cut
66              
67             sub match{
68 0     0 1   my $self=$_[0];
69 0           my $object=$_[1];
70              
71 0 0         if ( !defined( $object ) ){
72 0           return 0;
73             }
74              
75 0 0         if ( ref( $object ) ne 'Proc::ProcessTable::Process' ){
76 0           return 0;
77             }
78              
79 0           my $proc_fname;
80 0           eval{
81 0           $proc_fname=$object->fname;
82             };
83              
84             # don't bother proceeding, the object won't match ever
85             # as it does not have a fname
86 0 0         if ( ! defined( $proc_fname ) ){
87 0           return 0;
88             }
89              
90 0           my $proc_uid;
91 0           eval{
92 0           $proc_uid=$object->uid;
93             };
94              
95             # don't bother proceeding, the object won't match ever
96             # as it does not have a uid
97 0 0         if ( ! defined( $proc_uid ) ){
98 0           return 0;
99             }
100              
101 0           my $proc_cmd;
102 0           eval{
103 0           $proc_cmd=$object->cmndline;
104             };
105              
106             # don't bother proceeding, the object won't match ever
107             # as it does not have a cmndline
108 0 0         if ( ! defined( $proc_cmd ) ){
109 0           return 0;
110             }
111              
112 0 0 0       if (
113             ( $proc_uid eq 0 ) &&
114             ( $proc_cmd =~ /^$/ )
115             ){
116 0           return 1;
117             }
118              
119 0           return 0;
120             }
121              
122             =head1 AUTHOR
123              
124             Zane C. Bowers-Hadley, C<< >>
125              
126             =head1 BUGS
127              
128             Please report any bugs or feature requests to C, or through
129             the web interface at L. I will be notified, and then you'll
130             automatically be notified of progress on your bug as I make changes.
131              
132              
133              
134              
135             =head1 SUPPORT
136              
137             You can find documentation for this module with the perldoc command.
138              
139             perldoc Proc::ProcessTable::Match
140              
141              
142             You can also look for information at:
143              
144             =over 4
145              
146             =item * RT: CPAN's request tracker (report bugs here)
147              
148             L
149              
150             =item * AnnoCPAN: Annotated CPAN documentation
151              
152             L
153              
154             =item * CPAN Ratings
155              
156             L
157              
158             =item * Search CPAN
159              
160             L
161              
162             =back
163              
164              
165             =head1 ACKNOWLEDGEMENTS
166              
167              
168             =head1 LICENSE AND COPYRIGHT
169              
170             Copyright 2019 Zane C. Bowers-Hadley.
171              
172             This program is free software; you can redistribute it and/or modify it
173             under the terms of the the Artistic License (2.0). You may obtain a
174             copy of the full license at:
175              
176             L
177              
178             Any use, modification, and distribution of the Standard or Modified
179             Versions is governed by this Artistic License. By using, modifying or
180             distributing the Package, you accept this license. Do not use, modify,
181             or distribute the Package, if you do not accept this license.
182              
183             If your Modified Version has been derived from a Modified Version made
184             by someone other than you, you are nevertheless required to ensure that
185             your Modified Version complies with the requirements of this license.
186              
187             This license does not grant you the right to use any trademark, service
188             mark, tradename, or logo of the Copyright Holder.
189              
190             This license includes the non-exclusive, worldwide, free-of-charge
191             patent license to make, have made, use, offer to sell, sell, import and
192             otherwise transfer the Package with respect to any patent claims
193             licensable by the Copyright Holder that are necessarily infringed by the
194             Package. If you institute patent litigation (including a cross-claim or
195             counterclaim) against any party alleging that the Package constitutes
196             direct or contributory patent infringement, then this Artistic License
197             to you shall terminate on the date that such litigation is filed.
198              
199             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
200             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
201             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
202             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
203             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
204             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
205             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
206             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
207              
208              
209             =cut
210              
211             1; # End of Proc::ProcessTable::Match