diff glang-galaxy-conf/snippets/perl_snippet_file.pl @ 2:8947fca5f715 draft default tip

Uploaded
author ktnyt
date Fri, 26 Jun 2015 05:21:44 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/glang-galaxy-conf/snippets/perl_snippet_file.pl	Fri Jun 26 05:21:44 2015 -0400
@@ -0,0 +1,29 @@
+#!/usr/bin/env perl
+use warnings;
+
+my $scriptname = shift;
+my $outname = shift;
+open SCR, "<", $scriptname;
+open OUT, ">", $outname;
+open STDOUT, ">", shift;
+open STDERR, ">", shift;
+
+my $open = "";
+my @files;
+for(my $i = 0; @ARGV; $i++) {
+    my $fn = shift;
+    push @files, $fn;
+    $open .= qq(open IN$i, "<", "$fn";\n);
+}
+
+my $script = join("", <SCR>);
+
+if($script =~ /(open)|(system)|(`.+`)|([$@%]ENV)/smg) {
+    printf(STDERR "Found vulnerable code (open, system, backticks) in given script.");
+    exit(1);
+}
+
+eval("$open$script");
+
+close SCR;
+close OUT;