[interchange-cvs] [SCM] Interchange branch, master, updated. 104d0006f1d7f6bb1d34508b0cf91b47a30b15e9

Jon Jensen interchange-cvs at icdevgroup.org
Wed Sep 2 00:35:46 UTC 2009


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Interchange".

The branch, master has been updated
       via  104d0006f1d7f6bb1d34508b0cf91b47a30b15e9 (commit)
      from  0a6e3b6af1c2e7d72f9bb606db55b5f70ed52518 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 104d0006f1d7f6bb1d34508b0cf91b47a30b15e9
Author: Jon Jensen <jon at endpoint.com>
Date:   Tue Sep 1 18:28:12 2009 -0600

    Move AllowedFileRegex from catalog into global configuration
    
    This prevents catalog-level tampering of the regular expression used for
    checking paths are allowed by NoAbsolute. It is set at startup time but
    before as a catalog configuration entry could be manipulated even in
    Safe page code.
    
    Problem reported by Peter Ajamian.

-----------------------------------------------------------------------

Summary of changes and diff:
 dist/test/products/tests.asc |   28 ++++++++++++++++++++++++++++
 lib/Vend/Config.pm           |    4 ++--
 lib/Vend/Dispatch.pm         |   16 ++++++++--------
 lib/Vend/File.pm             |    8 +++-----
 4 files changed, 41 insertions(+), 15 deletions(-)

diff --git a/dist/test/products/tests.asc b/dist/test/products/tests.asc
index 44e5ce4..bf154a8 100644
--- a/dist/test/products/tests.asc
+++ b/dist/test/products/tests.asc
@@ -2969,6 +2969,34 @@ foo=foo_2 bar=bar_2 baz=baz_2
 %%
 Test of [value], $Values, and $Session->{values} equivalency.
 %%%
+000166
+%%
+<pre>Before munging AllowedFileRegex:
+Should fail: [write-relative-file file='/tmp/superdogfood']One special line[/write-relative-file]
+Should succeed: [write-relative-file file='tmp/superdogfood']One special line[/write-relative-file]
+[calcn]
+    $Config->{AllowedFileRegex} = '.*';
+    return;
+[/calcn]
+After munging AllowedFileRegex:
+Should fail: [write-relative-file file='/tmp/superdogfood']One special line[/write-relative-file]
+Should succeed: [write-relative-file file='tmp/superdogfood']One special line[/write-relative-file]
+</pre>
+%%
+<pre>Before munging AllowedFileRegex:
+Should fail: 
+Should succeed: 1
+
+After munging AllowedFileRegex:
+Should fail: 
+Should succeed: 1
+</pre>
+%%
+%%
+
+%%
+Verify fix of AllowedFileRegex circumvention
+%%%
 999999
 %%
 [the test] [perl]
diff --git a/lib/Vend/Config.pm b/lib/Vend/Config.pm
index 0cc079a..6a19eb8 100644
--- a/lib/Vend/Config.pm
+++ b/lib/Vend/Config.pm
@@ -53,7 +53,7 @@ use Vend::Data;
 use Vend::Cron;
 use Vend::CharSet ();
 
-$VERSION = substr(q$Revision: 2.246 $, 10);
+$VERSION = '2.247';
 
 my %CDname;
 my %CPname;
@@ -3582,7 +3582,7 @@ sub set_default_search {
 							@{$C->{TemplateDir} || []},
 							@{$Global::TemplateDir || []};
 			my $re = join "|", @paths;
-			$C->{AllowedFileRegex} = qr{^($re)};
+			$Global::AllowedFileRegex->{$C->{CatalogName}} = qr{^($re)};
 			return 1;
 		},
 		Autoload => sub {
diff --git a/lib/Vend/Dispatch.pm b/lib/Vend/Dispatch.pm
index 17445c1..caf3415 100644
--- a/lib/Vend/Dispatch.pm
+++ b/lib/Vend/Dispatch.pm
@@ -1,7 +1,5 @@
 # Vend::Dispatch - Handle Interchange page requests
 #
-# $Id: Dispatch.pm,v 1.112 2009-04-27 10:00:17 racke Exp $
-#
 # Copyright (C) 2002-2009 Interchange Development Group
 # Copyright (C) 2002 Mike Heins <mike at perusion.net>
 #
@@ -26,7 +24,7 @@
 package Vend::Dispatch;
 
 use vars qw($VERSION);
-$VERSION = substr(q$Revision: 1.112 $, 10);
+$VERSION = '1.113';
 
 use POSIX qw(strftime);
 use Vend::Util;
@@ -734,16 +732,17 @@ sub run_in_catalog {
 	my $dir;
 	my @itl;
 	if($job) {
-		my ($d, $global_dir, $tmp);
 		my @jobdirs = ([$jobscfg->{base_directory} || 'etc/jobs', 0]);
 
 		if (is_yes($jobscfg->{use_global}) || is_yes($Global::Jobs->{UseGlobal})) {
 			push (@jobdirs, ["$Global::ConfDir/jobs", 1]);
 		}
 
+		my $global_dir;
 		for my $r (@jobdirs) {
-#::logGlobal("check directory=$d for $job");
+			my $d;
 			($d, $global_dir) = @$r;
+#::logGlobal("check directory=$d for $job");
 			next unless $d;
 			next unless -d "$d/$job";
 			$dir = "$d/$job";
@@ -751,9 +750,10 @@ sub run_in_catalog {
 		}
 
 		if($dir) {
+			my $tmp;
 			if ($global_dir) {
-				$tmp = $Vend::Cfg->{AllowedFileRegex};
-				$Vend::Cfg->{AllowedFileRegex} = qr{^$dir};
+				$tmp = $Global::AllowedFileRegex->{$cat};
+				$Global::AllowedFileRegex->{$cat} = qr{^$dir};
 			}
 			
 			my @f = glob("$dir/*");
@@ -766,7 +766,7 @@ sub run_in_catalog {
 			}
 
 			if ($global_dir) {
-				$Vend::Cfg->{AllowedFileRegex} = $tmp;
+				$Global::AllowedFileRegex->{$cat} = $tmp;
 			}
 		}
 	}
diff --git a/lib/Vend/File.pm b/lib/Vend/File.pm
index a716454..a575ce8 100644
--- a/lib/Vend/File.pm
+++ b/lib/Vend/File.pm
@@ -1,8 +1,6 @@
 # Vend::File - Interchange file functions
 #
-# $Id: File.pm,v 2.32 2009-04-29 05:08:13 mheins Exp $
-# 
-# Copyright (C) 2002-2008 Interchange Development Group
+# Copyright (C) 2002-2009 Interchange Development Group
 # Copyright (C) 1996-2002 Red Hat, Inc.
 #
 # This program was originally based on Vend 0.2 and 0.3
@@ -61,7 +59,7 @@ use File::Path;
 use File::Copy;
 use subs qw(logError logGlobal);
 use vars qw($VERSION @EXPORT @EXPORT_OK $errstr);
-$VERSION = substr(q$Revision: 2.32 $, 10);
+$VERSION = '2.33';
 
 sub writefile {
     my($file, $data, $opt) = @_;
@@ -708,7 +706,7 @@ sub allowed_file {
 	$Vend::File::errstr = '';
 	if(	$Global::NoAbsolute
 			and
-		$fn !~ $Vend::Cfg->{AllowedFileRegex}
+		$fn !~ $Global::AllowedFileRegex->{$Vend::Cat}
 			and
 		absolute_or_relative($fn)
 		)


hooks/post-receive
-- 
Interchange



More information about the interchange-cvs mailing list