-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove '.' from @INC #181
remove '.' from @INC #181
Conversation
As described in the link below: http://search.cpan.org/dist/perl-5.26.0/pod/perldelta.pod#Removal_of_the_current_directory_(%22.%22)_from_@INC Perls before 5.26 include dot in INC unless taint mode is enabled. Most script supplied by quattor does have taint enabled except a few. Here I am using the recommendation to remove dot from @inc. This is safe invocation as if someone enables taint mode or upgrades perl it still does the right thing.
@@ -10,6 +10,7 @@ use warnings; | |||
# required for CAF | |||
BEGIN { | |||
unshift(@INC, '/usr/lib/perl'); | |||
pop @INC if $INC[-1] eq '.'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
title should be changed to "only remove '.' when it's the last element in INC".
or replace the BEGIN block with (untested)
BEGIN {
@INC = ('/usr/lib/perl', grep {$_ ne '.'} @INC);
}
btw, this should be turned in a template in maven-tools, i made quattor/maven-tools#169
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea comes from here (a respected member of the perl community):
https://www.masteringperl.org/2017/01/perl-v5-26-removes-from-inc-but-dont-think-youre-safe/
dot is always last in INC so it should suffice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, i wasn't sure. can you also open an issue to switch remaining scripts to taint mode, so this isn't forgotten?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
This is the same as in quattor/CCM#181
This is the same as in quattor/CCM#181
As described in the link below:
http://search.cpan.org/dist/perl-5.26.0/pod/perldelta.pod#Removal_of_the_current_directory_(%22.%22)_from_@INC
Perls before 5.26 include dot in INC unless taint mode is enabled.
Most script supplied by quattor does have taint enabled except a few.
Here I am using the recommendation to remove dot from
@INC
. This is safeinvocation as if someone enables taint mode or upgrades perl it still does the
right thing.