line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use 5.006001; |
3
|
2
|
|
|
2
|
|
377555
|
use strict; |
|
2
|
|
|
|
|
11
|
|
4
|
2
|
|
|
2
|
|
18
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
42
|
|
5
|
2
|
|
|
2
|
|
9
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
37
|
|
6
|
|
|
|
|
|
|
use Readonly; |
7
|
2
|
|
|
2
|
|
7
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
83
|
|
8
|
|
|
|
|
|
|
use version; |
9
|
2
|
|
|
2
|
|
630
|
|
|
2
|
|
|
|
|
2713
|
|
|
2
|
|
|
|
|
9
|
|
10
|
|
|
|
|
|
|
use base 'Perl::Critic::Policy'; |
11
|
2
|
|
|
2
|
|
107
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
845
|
|
12
|
|
|
|
|
|
|
use Perl::Critic::Utils qw{ :severities :classification :ppi :booleans |
13
|
2
|
|
|
|
|
93
|
:language hashify }; |
14
|
2
|
|
|
2
|
|
38290
|
use PPI; |
|
2
|
|
|
|
|
4
|
|
15
|
2
|
|
|
2
|
|
1322
|
use PPI::Document; |
|
2
|
|
|
|
|
29615
|
|
|
2
|
|
|
|
|
54
|
|
16
|
2
|
|
|
2
|
|
11
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
376
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.000_901'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => q{Use of file access test %s}; |
22
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => |
23
|
|
|
|
|
|
|
q{File access test results may not reflect actual accessability}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Readonly::Hash my %FILE_ACCESS => hashify( qw{ -r -w -x -R -W -X } ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
3
|
|
|
3
|
0
|
22261
|
|
31
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
32
|
6
|
|
|
6
|
1
|
68
|
|
33
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $elem ) = @_; |
34
|
2
|
|
|
2
|
1
|
26837
|
|
35
|
|
|
|
|
|
|
$elem |
36
|
|
|
|
|
|
|
or return; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$FILE_ACCESS{ $elem->content() } |
39
|
27
|
|
|
27
|
1
|
911
|
or return; |
40
|
|
|
|
|
|
|
|
41
|
27
|
50
|
|
|
|
60
|
return $self->violation( |
42
|
|
|
|
|
|
|
sprintf( $DESC, $elem->content() ), |
43
|
|
|
|
|
|
|
$EXPL, |
44
|
27
|
100
|
|
|
|
50
|
$elem, |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
} |
47
|
6
|
|
|
|
|
72
|
|
48
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=pod |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=for stopwords builtins |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 NAME |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Perl::Critic::Policy::ValuesAndExpressions::ProhibitFiletest_rwxRWX - Prohibit file access tests. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 AFFILIATION |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
This Policy is stand-alone, and is not part of the core |
66
|
|
|
|
|
|
|
L<Perl::Critic|Perl::Critic>. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 DESCRIPTION |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
This policy prohibits the file access tests C<-r>, C<-w>, C<-x>, C<-R>, C<-W>, |
71
|
|
|
|
|
|
|
and C<-X>. All these do by default is to check the file's access control bits. |
72
|
|
|
|
|
|
|
Access to a file can succeed or fail for other reasons such as the presence of |
73
|
|
|
|
|
|
|
Access Control Lists (ACLs), a file system being mounted read-only, or an |
74
|
|
|
|
|
|
|
executable being corrupt. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This policy is under the "bugs" theme, with low severity. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 CONFIGURATION |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This Policy has no configuration options. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 SEE ALSO |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
L<Perl::Critic::Policy::ValuesAndExpressions::ProhibitFiletest_f|Perl::Critic::Policy::ValuesAndExpressions::ProhibitFiletest_f> |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
L<https://blogs.perl.org/users/tom_wyant/2022/06/the-file-access-operators-to-use-or-not-to-use.html> |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 SUPPORT |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Support is by the author. Please file bug reports at |
91
|
|
|
|
|
|
|
L<https://rt.cpan.org/Public/Dist/Display.html?Name=Perl-Critic-Policy-ValuesAndExpressions-ProhibitFiletest_rwxRWX>, |
92
|
|
|
|
|
|
|
L<https://github.com/trwyant/perl-Perl-Critic-Policy-ValuesAndExpressions-ProhibitFiletest_rwxRWX/issues>, |
93
|
|
|
|
|
|
|
or in electronic mail to the author. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 AUTHOR |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Thomas R. Wyant, III F<wyant at cpan dot org>. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 COPYRIGHT |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Copyright 2022 Thomas R. Wyant, III. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
104
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# Local Variables: |
109
|
|
|
|
|
|
|
# mode: cperl |
110
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
111
|
|
|
|
|
|
|
# fill-column: 78 |
112
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
113
|
|
|
|
|
|
|
# c-indentation-style: bsd |
114
|
|
|
|
|
|
|
# End: |
115
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |