Match/EUIDset.pm

filter: Statementstmt 91.6% 33 / 36 Branchbran 70.0% 7 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 88.8% 48 / 54 CC 6 SCAR 13.6
CC
6
Cov
87%
match
6.3
BEGIN
1.0
BEGIN
1.0
CRAP 3.9
« Match/EGIDset.pm ↑ Summary
1 package Proc::ProcessTable::Match::EUIDset;
2  
3 2 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use User::pwent;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 Proc::ProcessTable::Match::EUIDset - Check if the the process has a EUID set.
11  
12 =head1 VERSION
13  
14 Version 0.1.0
15  
16 =cut
17  
18 2 our $VERSION = '0.1.0';
19  
20  
21 =head1 SYNOPSIS
22  
23 use Proc::ProcessTable::Match::EUIDset;
24
25 my $checker=Proc::ProcessTable::Match::EUIDset->new;
26
27 if ( $checker->match( $proc ) ){
28 print "It matches.\n";
29 }
30  
31 =head1 METHODS
32  
33 =head2 new
34  
35 This intiates the object.
36  
37 my $checker=Proc::ProcessTable::Match::EUIDset->new;
38  
39 =cut
40  
41 1 ▶sub new{
Subroutine new: called CC=1 SCAR=0.0
Pod documented
42 1 my $class=$_[0];
43 1 my $self = {
44 };
45 1 bless $self, $class;
46  
47 1 return $self;
48 }
49  
50 =head2 match
51  
52 Checks if a single Proc::ProcessTable::Process object matches the stack.
53  
54 One argument is taken and that is a Proc::ProcessTable::Process object.
55  
56 The returned value is a boolean.
57  
58 if ( $checker->match( $proc ) ){
59 print "The process matches.\n";
60 }
61  
62 =cut
63  
64 3 ▶sub match{
Subroutine match: called CC=6 SCAR=18.4
Pod documented
65 3 my $self=$_[0];
66 3 my $object=$_[1];
67  
68 3 ▶ if ( !defined( $object ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $object) 0 3 3
69 0 return 0;
70 }
71  
72 3 ▶ if ( ref( $object ) ne 'Proc::ProcessTable::Process' ){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $object ne "Proc::ProcessTable::Process") 0 3 3
73 0 return 0;
74 }
75  
76 3 my $proc_uid;
77 3 eval{
78 3 $proc_uid=$object->uid;
79 };
80  
81 # don't bother proceeding, the object won't match ever
82 # as it does not have a UID
83 3 ▶ if ( ! defined( $proc_uid ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $proc_uid) 0 3 3
84 0 return 0;
85 }
86  
87 3 my $proc_euid;
88 3 eval{
89 3 $proc_euid=$object->euid;
90 };
91  
92 # don't bother proceeding, the object won't match ever
93 # as it does not have a EUID
94 3 ▶ if ( ! defined( $proc_euid ) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $proc_euid) 1 2 3
95 1 return 0;
96 }
97  
98 2 ▶ if ( $proc_euid != $proc_uid ){
Branch: 1 branch
BranchTrueFalseTotal
if ($proc_euid != $proc_uid) 1 1 2
99 1 return 1;
100 }
101  
102 1 return 0;
103 }
104  
105 =head1 AUTHOR
106  
107 Zane C. Bowers-Hadley, C<< <vvelox at vvelox.net> >>
108  
109 =head1 BUGS
110  
111 Please report any bugs or feature requests to C<bug-Proc-ProcessTable-Match at rt.cpan.org>, or through
112 the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Proc-ProcessTable-Match>. I will be notified, and then you'll
113 automatically be notified of progress on your bug as I make changes.
114  
115  
116  
117  
118 =head1 SUPPORT
119  
120 You can find documentation for this module with the perldoc command.
121  
122 perldoc Proc::ProcessTable::Match
123  
124  
125 You can also look for information at:
126  
127 =over 4
128  
129 =item * RT: CPAN's request tracker (report bugs here)
130  
131 L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Proc-ProcessTable-Match>
132  
133 =item * Search CPAN
134  
135 L<https://metacpan.org/release/Proc-ProcessTable-Match>
136  
137 =back
138  
139  
140 =head1 ACKNOWLEDGEMENTS
141  
142  
143 =head1 LICENSE AND COPYRIGHT
144  
145 Copyright 2019 Zane C. Bowers-Hadley.
146  
147 This program is free software; you can redistribute it and/or modify it
148 under the terms of the the Artistic License (2.0). You may obtain a
149 copy of the full license at:
150  
151 L<http://www.perlfoundation.org/artistic_license_2_0>
152  
153 Any use, modification, and distribution of the Standard or Modified
154 Versions is governed by this Artistic License. By using, modifying or
155 distributing the Package, you accept this license. Do not use, modify,
156 or distribute the Package, if you do not accept this license.
157  
158 If your Modified Version has been derived from a Modified Version made
159 by someone other than you, you are nevertheless required to ensure that
160 your Modified Version complies with the requirements of this license.
161  
162 This license does not grant you the right to use any trademark, service
163 mark, tradename, or logo of the Copyright Holder.
164  
165 This license includes the non-exclusive, worldwide, free-of-charge
166 patent license to make, have made, use, offer to sell, sell, import and
167 otherwise transfer the Package with respect to any patent claims
168 licensable by the Copyright Holder that are necessarily infringed by the
169 Package. If you institute patent litigation (including a cross-claim or
170 counterclaim) against any party alleging that the Package constitutes
171 direct or contributory patent infringement, then this Artistic License
172 to you shall terminate on the date that such litigation is filed.
173  
174 Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
175 AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
176 THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
177 PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
178 YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
179 CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
180 CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
181 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
182  
183  
184 =cut
185  
186 2 1; # End of Proc::ProcessTable::Match
« Match/EGIDset.pm ↑ Summary