From 14bcdce1dc6029c3676c3640d8148c83c14692e5 Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Mon, 12 Sep 2016 16:22:17 -0400 Subject: Revert "Bug 1283930 - Add Makefile.PL & local/lib/perl5 support to bmo/master + local symlink to data/ directory" This reverts commit e6bf4cacb10f86077fe898349485f5c7ab9fb4b6. --- t/003safesys.t | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 t/003safesys.t (limited to 't/003safesys.t') diff --git a/t/003safesys.t b/t/003safesys.t new file mode 100644 index 000000000..a69500b7a --- /dev/null +++ b/t/003safesys.t @@ -0,0 +1,73 @@ +# -*- Mode: perl; indent-tabs-mode: nil -*- +# +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code are the Bugzilla Tests. +# +# The Initial Developer of the Original Code is Zach Lipton +# Portions created by Zach Lipton are +# Copyright (C) 2001 Zach Lipton. All +# Rights Reserved. +# +# Contributor(s): Zach Lipton + + +################# +#Bugzilla Test 3# +###Safesystem#### + +use strict; + +use lib 't'; + +use Support::Files; +use File::Slurp; + +use Test::More tests => scalar(@Support::Files::testitems); + +# Capture the TESTOUT from Test::More or Test::Builder for printing errors. +# This will handle verbosity for us automatically. +my $fh; +{ + local $^W = 0; # Don't complain about non-existent filehandles + if (-e \*Test::More::TESTOUT) { + $fh = \*Test::More::TESTOUT; + } elsif (-e \*Test::Builder::TESTOUT) { + $fh = \*Test::Builder::TESTOUT; + } else { + $fh = \*STDOUT; + } +} + +my @testitems = @Support::Files::testitems; +my $perlapp = "\"$^X\""; + +foreach my $file (@testitems) { + $file =~ s/\s.*$//; # nuke everything after the first space (#comment) + next if (!$file); # skip null entries + + my $contents = read_file($file); + if ($contents !~ /\b(system|exec)\b/) { + ok(1,"$file does not contain any system or exec calls"); + next; + } + + my $command = "$perlapp -c -It -MSupport::Systemexec $file 2>&1"; + my $loginfo=`$command`; + if ($loginfo =~ /arguments for Support::Systemexec::(system|exec)/im) { + ok(0,"$file DOES NOT use proper system or exec calls"); + print $fh $loginfo; + } else { + ok(1,"$file uses proper system and exec calls"); + } +} + +exit 0; -- cgit v1.2.3-24-g4f1b