Bug 24879: Use perl shebang to list the exec

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit f4a52fbc317067b62881110557aeb2b2cc63c41e)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 5d713e293d5e3b28f1f0611855df88ea886de9e1)
Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
This commit is contained in:
Jonathan Druart 2024-03-14 16:53:35 +01:00 committed by Frédéric Demians
parent c76b77ad42
commit 9845a19a4f

View file

@ -18,54 +18,24 @@
use Modern::Perl;
use Test::More;
use File::Spec;
use File::Find;
use File::Slurp qw(read_file);
my @files;
sub wanted {
my $name = $File::Find::name;
push @files, $name
if $name =~ m{^\./(
acqui
|admin
|authorities
|basket
|catalogue
|cataloguing
|circ
|clubs
|course_reserves
|labels
|members
|patroncards
|pos
|reports
|reserve
|reviews
|rotating_collections
|serials
|services
|suggestion
|svc
|tags
|tools
|virtualshelves
)}xms
&& $name =~ m{\.(pl)$}
&& -f $name;
}
my @excluded_paths = qw(C4 debian docs etc installer/data install_misc Koha misc selenium t test tmp xt changelanguage.pl build-resources.PL fix-perl-path.PL );
push @excluded_paths, 'opac'; # We cannot test the OPAC scripts, some can be accessed without authentication
find({ wanted => \&wanted, no_chdir => 1 }, File::Spec->curdir());
my $grep_cmd = q{git grep -l '#!/usr/bin/perl' -- } . join( ' ', map { qq{':!$_'} } @excluded_paths );
my @files = `$grep_cmd`;
my @missing_auth_check;
FILE: foreach my $name (@files) {
open( FILE, $name ) || die "cannot open file $name $!";
while ( my $line = <FILE> ) {
FILE: foreach my $file (@files) {
chomp $file;
my @lines = read_file($file);
for my $line ( @lines ) {
for my $routine ( qw( get_template_and_user check_cookie_auth checkauth check_api_auth C4::Service->init ) ) {
next FILE if $line =~ m|^[^#]*$routine|;
}
}
push @missing_auth_check, $name;
push @missing_auth_check, $file;
}
is( scalar @missing_auth_check, 0 ) or diag "No auth check in the following files:\n" . join "\n", @missing_auth_check;
done_testing;