[lintian] 02/04: Add a new php-script-with-unusual-interpreter check
This is an automated email from the git hooks/post-receive script.
nthykier pushed a commit to branch master
in repository lintian.
commit d0dc109512475329db6bced652d3e006d8a572b7
Author: Antonio Ospite <ao2@ao2.it>
Date: Thu Nov 3 22:51:23 2016 +0100
Add a new php-script-with-unusual-interpreter check
The PHP maintainers suggest to use unversioned interpreters in the
shebang line of scripts, add a check for that which allows either
"#!/usr/bin/php" or "#!/usr/bin/env php" as shebang lines.
The changes pass these tests:
debian/rules runtests onlyrun=scripts-missing-dep
debian/rules runtests onlyrun=legacy-scripts
Signed-off-by: Antonio Ospite <ao2@ao2.it>
Signed-off-by: Niels Thykier <niels@thykier.net>
---
checks/scripts.desc | 7 +++++++
checks/scripts.pm | 12 +++++++-----
t/tests/legacy-scripts/debian/debian/rules | 4 ++++
t/tests/legacy-scripts/tags | 5 ++++-
t/tests/legacy-scripts/upstream/phpenvfoo | 7 +++++++
5 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/checks/scripts.desc b/checks/scripts.desc
index d2c14b8..db34239 100644
--- a/checks/scripts.desc
+++ b/checks/scripts.desc
@@ -71,6 +71,13 @@ Info: This package contains an example script for an interpreter that
If not, please file a wishlist bug against lintian, so it can be
added to the list of known interpreters.
+Tag: php-script-with-unusual-interpreter
+Severity: normal
+Certainty: possible
+Info: This package contains a php script using an unusual interpreter in the
+ shebang line. The recommended shebang line is either <tt>#!/usr/bin/php</tt>
+ or <tt>#!/usr/bin/env php</tt> without any version number.
+
Tag: script-uses-bin-env
Severity: normal
Certainty: certain
diff --git a/checks/scripts.pm b/checks/scripts.pm
index f6e27ec..f7c3705 100644
--- a/checks/scripts.pm
+++ b/checks/scripts.pm
@@ -373,6 +373,13 @@ sub run {
script_tag('interpreter-in-usr-local', $filename,"#!$interpreter");
} elsif ($interpreter eq '/bin/env') {
script_tag('script-uses-bin-env', $filename);
+ } elsif ($base =~ /^php/) {
+ script_tag('php-script-with-unusual-interpreter',
+ $filename, "$interpreter");
+
+ # This allows us to still perform the dependencies checks
+ # below even when an unusual interpreter has been found.
+ $data = $INTERPRETERS->value('php');
} else {
my $pinter = 0;
if ($interpreter =~ m,^/,) {
@@ -391,11 +398,6 @@ sub run {
script_tag('unusual-interpreter', $filename, "#!$interpreter")
unless $pinter;
- # This allows us to still perform the dependencies checks
- # below even when an unusual interpreter has been found.
- if ($base =~ /^php/) {
- $data = $INTERPRETERS->value('php');
- }
}
# Check for obsolete perl libraries
diff --git a/t/tests/legacy-scripts/debian/debian/rules b/t/tests/legacy-scripts/debian/debian/rules
index 7bc5e9a..22f8393 100755
--- a/t/tests/legacy-scripts/debian/debian/rules
+++ b/t/tests/legacy-scripts/debian/debian/rules
@@ -69,6 +69,10 @@ binary-indep:
sed 's/php$$/php7.0/' phpfoo > $(tmp)/usr/share/scripts/php7.0foo
chmod 755 $(tmp)/usr/share/scripts/php7.0foo
+ install -m 755 phpenvfoo $(tmp)/usr/share/scripts/
+ sed 's/php$$/php7.0/' phpenvfoo > $(tmp)/usr/share/scripts/php7.0envfoo
+ chmod 755 $(tmp)/usr/share/scripts/php7.0envfoo
+
echo "#!/usr/bin/perl" >> $(tmp)/usr/share/scripts/foobar.in
chmod 644 $(tmp)/usr/share/scripts/foobar.in
diff --git a/t/tests/legacy-scripts/tags b/t/tests/legacy-scripts/tags
index 96fc9d5..58d6d62 100644
--- a/t/tests/legacy-scripts/tags
+++ b/t/tests/legacy-scripts/tags
@@ -14,7 +14,9 @@ E: scripts: init.d-script-needs-depends-on-lsb-base etc/init.d/skeleton (line 40
E: scripts: missing-dep-for-interpreter jruby => jruby | jruby1.0 | jruby1.1 | jruby1.2 (usr/bin/jruby-broken)
E: scripts: missing-dep-for-interpreter lefty => graphviz (usr/bin/lefty-foo)
E: scripts: package-installs-python-bytecode usr/lib/python2.3/site-packages/test.pyc
+E: scripts: php-script-but-no-php-cli-dep usr/share/scripts/php7.0envfoo
E: scripts: php-script-but-no-php-cli-dep usr/share/scripts/php7.0foo
+E: scripts: php-script-but-no-php-cli-dep usr/share/scripts/phpenvfoo
E: scripts: php-script-but-no-php-cli-dep usr/share/scripts/phpfoo
E: scripts: python-script-but-no-python-dep usr/bin/py2.Xfoo
E: scripts: python-script-but-no-python-dep usr/bin/py2foo
@@ -90,9 +92,10 @@ W: scripts: maintainer-script-has-unexpanded-debhelper-token preinst
W: scripts: maintainer-script-ignores-errors postinst
W: scripts: non-standard-executable-perm usr/bin/perl-bizarre-3 0754 != 0755
W: scripts: non-standard-setuid-executable-perm usr/bin/suidperlfoo 4555
+W: scripts: php-script-with-unusual-interpreter usr/share/scripts/php7.0envfoo php7.0
+W: scripts: php-script-with-unusual-interpreter usr/share/scripts/php7.0foo /usr/bin/php7.0
W: scripts: script-uses-bin-env usr/bin/envfoo
W: scripts: script-with-language-extension usr/bin/test.sh
W: scripts: setuid-binary usr/bin/suidperlfoo 4555 root/root
W: scripts: setuid-binary usr/bin/suidperlfoo2 4751 root/root
W: scripts: unusual-interpreter usr/bin/suidperlfoo #!/usr/bin/suidperl
-W: scripts: unusual-interpreter usr/share/scripts/php7.0foo #!/usr/bin/php7.0
diff --git a/t/tests/legacy-scripts/upstream/phpenvfoo b/t/tests/legacy-scripts/upstream/phpenvfoo
new file mode 100644
index 0000000..cbbfb2e
--- /dev/null
+++ b/t/tests/legacy-scripts/upstream/phpenvfoo
@@ -0,0 +1,7 @@
+#!/usr/bin/env php
+<html>
+<head>
+<title>Dumb PHP script</title>
+</head>
+<body><? print(Date("l F d, Y")); ?></body>
+</html>
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git
Reply to: