Webinject-1.94/0000755000175000017500000000000013135607424012076 5ustar svensvenWebinject-1.94/MANIFEST.SKIP0000644000175000017500000000023012234677616014000 0ustar svensven^blib .gitignore MANIFEST.bak check_webinject ^webinject.pl http.log results.html results.xml Makefile$ Makefile.old$ pm_to_blib MYMETA.json MYMETA.yml Webinject-1.94/inc/0000755000175000017500000000000013135607424012647 5ustar svensvenWebinject-1.94/inc/Module/0000755000175000017500000000000013135607424014074 5ustar svensvenWebinject-1.94/inc/Module/Install/0000755000175000017500000000000013135607424015502 5ustar svensvenWebinject-1.94/inc/Module/Install/Can.pm0000644000175000017500000000615713135607421016547 0ustar svensven#line 1 package Module::Install::Can; use strict; use Config (); use ExtUtils::MakeMaker (); use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.14'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } # check if we can load some module ### Upgrade this to not have to load the module if possible sub can_use { my ($self, $mod, $ver) = @_; $mod =~ s{::|\\}{/}g; $mod .= '.pm' unless $mod =~ /\.pm$/i; my $pkg = $mod; $pkg =~ s{/}{::}g; $pkg =~ s{\.pm$}{}i; local $@; eval { require $mod; $pkg->VERSION($ver || 0); 1 }; } # Check if we can run some command sub can_run { my ($self, $cmd) = @_; my $_cmd = $cmd; return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd)); for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') { next if $dir eq ''; require File::Spec; my $abs = File::Spec->catfile($dir, $cmd); return $abs if (-x $abs or $abs = MM->maybe_command($abs)); } return; } # Can our C compiler environment build XS files sub can_xs { my $self = shift; # Ensure we have the CBuilder module $self->configure_requires( 'ExtUtils::CBuilder' => 0.27 ); # Do we have the configure_requires checker? local $@; eval "require ExtUtils::CBuilder;"; if ( $@ ) { # They don't obey configure_requires, so it is # someone old and delicate. Try to avoid hurting # them by falling back to an older simpler test. return $self->can_cc(); } # Do we have a working C compiler my $builder = ExtUtils::CBuilder->new( quiet => 1, ); unless ( $builder->have_compiler ) { # No working C compiler return 0; } # Write a C file representative of what XS becomes require File::Temp; my ( $FH, $tmpfile ) = File::Temp::tempfile( "compilexs-XXXXX", SUFFIX => '.c', ); binmode $FH; print $FH <<'END_C'; #include "EXTERN.h" #include "perl.h" #include "XSUB.h" int main(int argc, char **argv) { return 0; } int boot_sanexs() { return 1; } END_C close $FH; # Can the C compiler access the same headers XS does my @libs = (); my $object = undef; eval { local $^W = 0; $object = $builder->compile( source => $tmpfile, ); @libs = $builder->link( objects => $object, module_name => 'sanexs', ); }; my $result = $@ ? 0 : 1; # Clean up all the build files foreach ( $tmpfile, $object, @libs ) { next unless defined $_; 1 while unlink; } return $result; } # Can we locate a (the) C compiler sub can_cc { my $self = shift; my @chunks = split(/ /, $Config::Config{cc}) or return; # $Config{cc} may contain args; try to find out the program part while (@chunks) { return $self->can_run("@chunks") || (pop(@chunks), next); } return; } # Fix Cygwin bug on maybe_command(); if ( $^O eq 'cygwin' ) { require ExtUtils::MM_Cygwin; require ExtUtils::MM_Win32; if ( ! defined(&ExtUtils::MM_Cygwin::maybe_command) ) { *ExtUtils::MM_Cygwin::maybe_command = sub { my ($self, $file) = @_; if ($file =~ m{^/cygdrive/}i and ExtUtils::MM_Win32->can('maybe_command')) { ExtUtils::MM_Win32->maybe_command($file); } else { ExtUtils::MM_Unix->maybe_command($file); } } } } 1; __END__ #line 236 Webinject-1.94/inc/Module/Install/ReadmeFromPod.pm0000644000175000017500000000631113135607421020522 0ustar svensven#line 1 package Module::Install::ReadmeFromPod; use 5.006; use strict; use warnings; use base qw(Module::Install::Base); use vars qw($VERSION); $VERSION = '0.22'; sub readme_from { my $self = shift; return unless $self->is_admin; # Input file my $in_file = shift || $self->_all_from or die "Can't determine file to make readme_from"; # Get optional arguments my ($clean, $format, $out_file, $options); my $args = shift; if ( ref $args ) { # Arguments are in a hashref if ( ref($args) ne 'HASH' ) { die "Expected a hashref but got a ".ref($args)."\n"; } else { $clean = $args->{'clean'}; $format = $args->{'format'}; $out_file = $args->{'output_file'}; $options = $args->{'options'}; } } else { # Arguments are in a list $clean = $args; $format = shift; $out_file = shift; $options = \@_; } # Default values; $clean ||= 0; $format ||= 'txt'; # Generate README print "readme_from $in_file to $format\n"; if ($format =~ m/te?xt/) { $out_file = $self->_readme_txt($in_file, $out_file, $options); } elsif ($format =~ m/html?/) { $out_file = $self->_readme_htm($in_file, $out_file, $options); } elsif ($format eq 'man') { $out_file = $self->_readme_man($in_file, $out_file, $options); } elsif ($format eq 'pdf') { $out_file = $self->_readme_pdf($in_file, $out_file, $options); } if ($clean) { $self->clean_files($out_file); } return 1; } sub _readme_txt { my ($self, $in_file, $out_file, $options) = @_; $out_file ||= 'README'; require Pod::Text; my $parser = Pod::Text->new( @$options ); open my $out_fh, '>', $out_file or die "Could not write file $out_file:\n$!\n"; $parser->output_fh( *$out_fh ); $parser->parse_file( $in_file ); close $out_fh; return $out_file; } sub _readme_htm { my ($self, $in_file, $out_file, $options) = @_; $out_file ||= 'README.htm'; require Pod::Html; Pod::Html::pod2html( "--infile=$in_file", "--outfile=$out_file", @$options, ); # Remove temporary files if needed for my $file ('pod2htmd.tmp', 'pod2htmi.tmp') { if (-e $file) { unlink $file or warn "Warning: Could not remove file '$file'.\n$!\n"; } } return $out_file; } sub _readme_man { my ($self, $in_file, $out_file, $options) = @_; $out_file ||= 'README.1'; require Pod::Man; my $parser = Pod::Man->new( @$options ); $parser->parse_from_file($in_file, $out_file); return $out_file; } sub _readme_pdf { my ($self, $in_file, $out_file, $options) = @_; $out_file ||= 'README.pdf'; eval { require App::pod2pdf; } or die "Could not generate $out_file because pod2pdf could not be found\n"; my $parser = App::pod2pdf->new( @$options ); $parser->parse_from_file($in_file); open my $out_fh, '>', $out_file or die "Could not write file $out_file:\n$!\n"; select $out_fh; $parser->output; select STDOUT; close $out_fh; return $out_file; } sub _all_from { my $self = shift; return unless $self->admin->{extensions}; my ($metadata) = grep { ref($_) eq 'Module::Install::Metadata'; } @{$self->admin->{extensions}}; return unless $metadata; return $metadata->{values}{all_from} || ''; } 'Readme!'; __END__ #line 254 Webinject-1.94/inc/Module/Install/Scripts.pm0000644000175000017500000000101113135607421017455 0ustar svensven#line 1 package Module::Install::Scripts; use strict 'vars'; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.14'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } sub install_script { my $self = shift; my $args = $self->makemaker_args; my $exe = $args->{EXE_FILES} ||= []; foreach ( @_ ) { if ( -f $_ ) { push @$exe, $_; } elsif ( -d 'script' and -f "script/$_" ) { push @$exe, "script/$_"; } else { die("Cannot find script '$_'"); } } } 1; Webinject-1.94/inc/Module/Install/Metadata.pm0000644000175000017500000004330213135607421017557 0ustar svensven#line 1 package Module::Install::Metadata; use strict 'vars'; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.14'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } my @boolean_keys = qw{ sign }; my @scalar_keys = qw{ name module_name abstract version distribution_type tests installdirs }; my @tuple_keys = qw{ configure_requires build_requires requires recommends bundles resources }; my @resource_keys = qw{ homepage bugtracker repository }; my @array_keys = qw{ keywords author }; *authors = \&author; sub Meta { shift } sub Meta_BooleanKeys { @boolean_keys } sub Meta_ScalarKeys { @scalar_keys } sub Meta_TupleKeys { @tuple_keys } sub Meta_ResourceKeys { @resource_keys } sub Meta_ArrayKeys { @array_keys } foreach my $key ( @boolean_keys ) { *$key = sub { my $self = shift; if ( defined wantarray and not @_ ) { return $self->{values}->{$key}; } $self->{values}->{$key} = ( @_ ? $_[0] : 1 ); return $self; }; } foreach my $key ( @scalar_keys ) { *$key = sub { my $self = shift; return $self->{values}->{$key} if defined wantarray and !@_; $self->{values}->{$key} = shift; return $self; }; } foreach my $key ( @array_keys ) { *$key = sub { my $self = shift; return $self->{values}->{$key} if defined wantarray and !@_; $self->{values}->{$key} ||= []; push @{$self->{values}->{$key}}, @_; return $self; }; } foreach my $key ( @resource_keys ) { *$key = sub { my $self = shift; unless ( @_ ) { return () unless $self->{values}->{resources}; return map { $_->[1] } grep { $_->[0] eq $key } @{ $self->{values}->{resources} }; } return $self->{values}->{resources}->{$key} unless @_; my $uri = shift or die( "Did not provide a value to $key()" ); $self->resources( $key => $uri ); return 1; }; } foreach my $key ( grep { $_ ne "resources" } @tuple_keys) { *$key = sub { my $self = shift; return $self->{values}->{$key} unless @_; my @added; while ( @_ ) { my $module = shift or last; my $version = shift || 0; push @added, [ $module, $version ]; } push @{ $self->{values}->{$key} }, @added; return map {@$_} @added; }; } # Resource handling my %lc_resource = map { $_ => 1 } qw{ homepage license bugtracker repository }; sub resources { my $self = shift; while ( @_ ) { my $name = shift or last; my $value = shift or next; if ( $name eq lc $name and ! $lc_resource{$name} ) { die("Unsupported reserved lowercase resource '$name'"); } $self->{values}->{resources} ||= []; push @{ $self->{values}->{resources} }, [ $name, $value ]; } $self->{values}->{resources}; } # Aliases for build_requires that will have alternative # meanings in some future version of META.yml. sub test_requires { shift->build_requires(@_) } sub install_requires { shift->build_requires(@_) } # Aliases for installdirs options sub install_as_core { $_[0]->installdirs('perl') } sub install_as_cpan { $_[0]->installdirs('site') } sub install_as_site { $_[0]->installdirs('site') } sub install_as_vendor { $_[0]->installdirs('vendor') } sub dynamic_config { my $self = shift; my $value = @_ ? shift : 1; if ( $self->{values}->{dynamic_config} ) { # Once dynamic we never change to static, for safety return 0; } $self->{values}->{dynamic_config} = $value ? 1 : 0; return 1; } # Convenience command sub static_config { shift->dynamic_config(0); } sub perl_version { my $self = shift; return $self->{values}->{perl_version} unless @_; my $version = shift or die( "Did not provide a value to perl_version()" ); # Normalize the version $version = $self->_perl_version($version); # We don't support the really old versions unless ( $version >= 5.005 ) { die "Module::Install only supports 5.005 or newer (use ExtUtils::MakeMaker)\n"; } $self->{values}->{perl_version} = $version; } sub all_from { my ( $self, $file ) = @_; unless ( defined($file) ) { my $name = $self->name or die( "all_from called with no args without setting name() first" ); $file = join('/', 'lib', split(/-/, $name)) . '.pm'; $file =~ s{.*/}{} unless -e $file; unless ( -e $file ) { die("all_from cannot find $file from $name"); } } unless ( -f $file ) { die("The path '$file' does not exist, or is not a file"); } $self->{values}{all_from} = $file; # Some methods pull from POD instead of code. # If there is a matching .pod, use that instead my $pod = $file; $pod =~ s/\.pm$/.pod/i; $pod = $file unless -e $pod; # Pull the different values $self->name_from($file) unless $self->name; $self->version_from($file) unless $self->version; $self->perl_version_from($file) unless $self->perl_version; $self->author_from($pod) unless @{$self->author || []}; $self->license_from($pod) unless $self->license; $self->abstract_from($pod) unless $self->abstract; return 1; } sub provides { my $self = shift; my $provides = ( $self->{values}->{provides} ||= {} ); %$provides = (%$provides, @_) if @_; return $provides; } sub auto_provides { my $self = shift; return $self unless $self->is_admin; unless (-e 'MANIFEST') { warn "Cannot deduce auto_provides without a MANIFEST, skipping\n"; return $self; } # Avoid spurious warnings as we are not checking manifest here. local $SIG{__WARN__} = sub {1}; require ExtUtils::Manifest; local *ExtUtils::Manifest::manicheck = sub { return }; require Module::Build; my $build = Module::Build->new( dist_name => $self->name, dist_version => $self->version, license => $self->license, ); $self->provides( %{ $build->find_dist_packages || {} } ); } sub feature { my $self = shift; my $name = shift; my $features = ( $self->{values}->{features} ||= [] ); my $mods; if ( @_ == 1 and ref( $_[0] ) ) { # The user used ->feature like ->features by passing in the second # argument as a reference. Accomodate for that. $mods = $_[0]; } else { $mods = \@_; } my $count = 0; push @$features, ( $name => [ map { ref($_) ? ( ref($_) eq 'HASH' ) ? %$_ : @$_ : $_ } @$mods ] ); return @$features; } sub features { my $self = shift; while ( my ( $name, $mods ) = splice( @_, 0, 2 ) ) { $self->feature( $name, @$mods ); } return $self->{values}->{features} ? @{ $self->{values}->{features} } : (); } sub no_index { my $self = shift; my $type = shift; push @{ $self->{values}->{no_index}->{$type} }, @_ if $type; return $self->{values}->{no_index}; } sub read { my $self = shift; $self->include_deps( 'YAML::Tiny', 0 ); require YAML::Tiny; my $data = YAML::Tiny::LoadFile('META.yml'); # Call methods explicitly in case user has already set some values. while ( my ( $key, $value ) = each %$data ) { next unless $self->can($key); if ( ref $value eq 'HASH' ) { while ( my ( $module, $version ) = each %$value ) { $self->can($key)->($self, $module => $version ); } } else { $self->can($key)->($self, $value); } } return $self; } sub write { my $self = shift; return $self unless $self->is_admin; $self->admin->write_meta; return $self; } sub version_from { require ExtUtils::MM_Unix; my ( $self, $file ) = @_; $self->version( ExtUtils::MM_Unix->parse_version($file) ); # for version integrity check $self->makemaker_args( VERSION_FROM => $file ); } sub abstract_from { require ExtUtils::MM_Unix; my ( $self, $file ) = @_; $self->abstract( bless( { DISTNAME => $self->name }, 'ExtUtils::MM_Unix' )->parse_abstract($file) ); } # Add both distribution and module name sub name_from { my ($self, $file) = @_; if ( Module::Install::_read($file) =~ m/ ^ \s* package \s* ([\w:]+) [\s|;]* /ixms ) { my ($name, $module_name) = ($1, $1); $name =~ s{::}{-}g; $self->name($name); unless ( $self->module_name ) { $self->module_name($module_name); } } else { die("Cannot determine name from $file\n"); } } sub _extract_perl_version { if ( $_[0] =~ m/ ^\s* (?:use|require) \s* v? ([\d_\.]+) \s* ; /ixms ) { my $perl_version = $1; $perl_version =~ s{_}{}g; return $perl_version; } else { return; } } sub perl_version_from { my $self = shift; my $perl_version=_extract_perl_version(Module::Install::_read($_[0])); if ($perl_version) { $self->perl_version($perl_version); } else { warn "Cannot determine perl version info from $_[0]\n"; return; } } sub author_from { my $self = shift; my $content = Module::Install::_read($_[0]); if ($content =~ m/ =head \d \s+ (?:authors?)\b \s* ([^\n]*) | =head \d \s+ (?:licen[cs]e|licensing|copyright|legal)\b \s* .*? copyright .*? \d\d\d[\d.]+ \s* (?:\bby\b)? \s* ([^\n]*) /ixms) { my $author = $1 || $2; # XXX: ugly but should work anyway... if (eval "require Pod::Escapes; 1") { # Pod::Escapes has a mapping table. # It's in core of perl >= 5.9.3, and should be installed # as one of the Pod::Simple's prereqs, which is a prereq # of Pod::Text 3.x (see also below). $author =~ s{ E<( (\d+) | ([A-Za-z]+) )> } { defined $2 ? chr($2) : defined $Pod::Escapes::Name2character_number{$1} ? chr($Pod::Escapes::Name2character_number{$1}) : do { warn "Unknown escape: E<$1>"; "E<$1>"; }; }gex; } elsif (eval "require Pod::Text; 1" && $Pod::Text::VERSION < 3) { # Pod::Text < 3.0 has yet another mapping table, # though the table name of 2.x and 1.x are different. # (1.x is in core of Perl < 5.6, 2.x is in core of # Perl < 5.9.3) my $mapping = ($Pod::Text::VERSION < 2) ? \%Pod::Text::HTML_Escapes : \%Pod::Text::ESCAPES; $author =~ s{ E<( (\d+) | ([A-Za-z]+) )> } { defined $2 ? chr($2) : defined $mapping->{$1} ? $mapping->{$1} : do { warn "Unknown escape: E<$1>"; "E<$1>"; }; }gex; } else { $author =~ s{E}{<}g; $author =~ s{E}{>}g; } $self->author($author); } else { warn "Cannot determine author info from $_[0]\n"; } } #Stolen from M::B my %license_urls = ( perl => 'http://dev.perl.org/licenses/', apache => 'http://apache.org/licenses/LICENSE-2.0', apache_1_1 => 'http://apache.org/licenses/LICENSE-1.1', artistic => 'http://opensource.org/licenses/artistic-license.php', artistic_2 => 'http://opensource.org/licenses/artistic-license-2.0.php', lgpl => 'http://opensource.org/licenses/lgpl-license.php', lgpl2 => 'http://opensource.org/licenses/lgpl-2.1.php', lgpl3 => 'http://opensource.org/licenses/lgpl-3.0.html', bsd => 'http://opensource.org/licenses/bsd-license.php', gpl => 'http://opensource.org/licenses/gpl-license.php', gpl2 => 'http://opensource.org/licenses/gpl-2.0.php', gpl3 => 'http://opensource.org/licenses/gpl-3.0.html', mit => 'http://opensource.org/licenses/mit-license.php', mozilla => 'http://opensource.org/licenses/mozilla1.1.php', open_source => undef, unrestricted => undef, restrictive => undef, unknown => undef, ); sub license { my $self = shift; return $self->{values}->{license} unless @_; my $license = shift or die( 'Did not provide a value to license()' ); $license = __extract_license($license) || lc $license; $self->{values}->{license} = $license; # Automatically fill in license URLs if ( $license_urls{$license} ) { $self->resources( license => $license_urls{$license} ); } return 1; } sub _extract_license { my $pod = shift; my $matched; return __extract_license( ($matched) = $pod =~ m/ (=head \d \s+ L(?i:ICEN[CS]E|ICENSING)\b.*?) (=head \d.*|=cut.*|)\z /xms ) || __extract_license( ($matched) = $pod =~ m/ (=head \d \s+ (?:C(?i:OPYRIGHTS?)|L(?i:EGAL))\b.*?) (=head \d.*|=cut.*|)\z /xms ); } sub __extract_license { my $license_text = shift or return; my @phrases = ( '(?:under )?the same (?:terms|license) as (?:perl|the perl (?:\d )?programming language)' => 'perl', 1, '(?:under )?the terms of (?:perl|the perl programming language) itself' => 'perl', 1, 'Artistic and GPL' => 'perl', 1, 'GNU general public license' => 'gpl', 1, 'GNU public license' => 'gpl', 1, 'GNU lesser general public license' => 'lgpl', 1, 'GNU lesser public license' => 'lgpl', 1, 'GNU library general public license' => 'lgpl', 1, 'GNU library public license' => 'lgpl', 1, 'GNU Free Documentation license' => 'unrestricted', 1, 'GNU Affero General Public License' => 'open_source', 1, '(?:Free)?BSD license' => 'bsd', 1, 'Artistic license 2\.0' => 'artistic_2', 1, 'Artistic license' => 'artistic', 1, 'Apache (?:Software )?license' => 'apache', 1, 'GPL' => 'gpl', 1, 'LGPL' => 'lgpl', 1, 'BSD' => 'bsd', 1, 'Artistic' => 'artistic', 1, 'MIT' => 'mit', 1, 'Mozilla Public License' => 'mozilla', 1, 'Q Public License' => 'open_source', 1, 'OpenSSL License' => 'unrestricted', 1, 'SSLeay License' => 'unrestricted', 1, 'zlib License' => 'open_source', 1, 'proprietary' => 'proprietary', 0, ); while ( my ($pattern, $license, $osi) = splice(@phrases, 0, 3) ) { $pattern =~ s#\s+#\\s+#gs; if ( $license_text =~ /\b$pattern\b/i ) { return $license; } } return ''; } sub license_from { my $self = shift; if (my $license=_extract_license(Module::Install::_read($_[0]))) { $self->license($license); } else { warn "Cannot determine license info from $_[0]\n"; return 'unknown'; } } sub _extract_bugtracker { my @links = $_[0] =~ m#L<( https?\Q://rt.cpan.org/\E[^>]+| https?\Q://github.com/\E[\w_]+/[\w_]+/issues| https?\Q://code.google.com/p/\E[\w_\-]+/issues/list )>#gx; my %links; @links{@links}=(); @links=keys %links; return @links; } sub bugtracker_from { my $self = shift; my $content = Module::Install::_read($_[0]); my @links = _extract_bugtracker($content); unless ( @links ) { warn "Cannot determine bugtracker info from $_[0]\n"; return 0; } if ( @links > 1 ) { warn "Found more than one bugtracker link in $_[0]\n"; return 0; } # Set the bugtracker bugtracker( $links[0] ); return 1; } sub requires_from { my $self = shift; my $content = Module::Install::_readperl($_[0]); my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+(v?[\d\.]+)/mg; while ( @requires ) { my $module = shift @requires; my $version = shift @requires; $self->requires( $module => $version ); } } sub test_requires_from { my $self = shift; my $content = Module::Install::_readperl($_[0]); my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+([\d\.]+)/mg; while ( @requires ) { my $module = shift @requires; my $version = shift @requires; $self->test_requires( $module => $version ); } } # Convert triple-part versions (eg, 5.6.1 or 5.8.9) to # numbers (eg, 5.006001 or 5.008009). # Also, convert double-part versions (eg, 5.8) sub _perl_version { my $v = $_[-1]; $v =~ s/^([1-9])\.([1-9]\d?\d?)$/sprintf("%d.%03d",$1,$2)/e; $v =~ s/^([1-9])\.([1-9]\d?\d?)\.(0|[1-9]\d?\d?)$/sprintf("%d.%03d%03d",$1,$2,$3 || 0)/e; $v =~ s/(\.\d\d\d)000$/$1/; $v =~ s/_.+$//; if ( ref($v) ) { # Numify $v = $v + 0; } return $v; } sub add_metadata { my $self = shift; my %hash = @_; for my $key (keys %hash) { warn "add_metadata: $key is not prefixed with 'x_'.\n" . "Use appopriate function to add non-private metadata.\n" unless $key =~ /^x_/; $self->{values}->{$key} = $hash{$key}; } } ###################################################################### # MYMETA Support sub WriteMyMeta { die "WriteMyMeta has been deprecated"; } sub write_mymeta_yaml { my $self = shift; # We need YAML::Tiny to write the MYMETA.yml file unless ( eval { require YAML::Tiny; 1; } ) { return 1; } # Generate the data my $meta = $self->_write_mymeta_data or return 1; # Save as the MYMETA.yml file print "Writing MYMETA.yml\n"; YAML::Tiny::DumpFile('MYMETA.yml', $meta); } sub write_mymeta_json { my $self = shift; # We need JSON to write the MYMETA.json file unless ( eval { require JSON; 1; } ) { return 1; } # Generate the data my $meta = $self->_write_mymeta_data or return 1; # Save as the MYMETA.yml file print "Writing MYMETA.json\n"; Module::Install::_write( 'MYMETA.json', JSON->new->pretty(1)->canonical->encode($meta), ); } sub _write_mymeta_data { my $self = shift; # If there's no existing META.yml there is nothing we can do return undef unless -f 'META.yml'; # We need Parse::CPAN::Meta to load the file unless ( eval { require Parse::CPAN::Meta; 1; } ) { return undef; } # Merge the perl version into the dependencies my $val = $self->Meta->{values}; my $perl = delete $val->{perl_version}; if ( $perl ) { $val->{requires} ||= []; my $requires = $val->{requires}; # Canonize to three-dot version after Perl 5.6 if ( $perl >= 5.006 ) { $perl =~ s{^(\d+)\.(\d\d\d)(\d*)}{join('.', $1, int($2||0), int($3||0))}e } unshift @$requires, [ perl => $perl ]; } # Load the advisory META.yml file my @yaml = Parse::CPAN::Meta::LoadFile('META.yml'); my $meta = $yaml[0]; # Overwrite the non-configure dependency hashes delete $meta->{requires}; delete $meta->{build_requires}; delete $meta->{recommends}; if ( exists $val->{requires} ) { $meta->{requires} = { map { @$_ } @{ $val->{requires} } }; } if ( exists $val->{build_requires} ) { $meta->{build_requires} = { map { @$_ } @{ $val->{build_requires} } }; } return $meta; } 1; Webinject-1.94/inc/Module/Install/Makefile.pm0000644000175000017500000002743713135607421017567 0ustar svensven#line 1 package Module::Install::Makefile; use strict 'vars'; use ExtUtils::MakeMaker (); use Module::Install::Base (); use Fcntl qw/:flock :seek/; use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.14'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } sub Makefile { $_[0] } my %seen = (); sub prompt { shift; # Infinite loop protection my @c = caller(); if ( ++$seen{"$c[1]|$c[2]|$_[0]"} > 3 ) { die "Caught an potential prompt infinite loop ($c[1]|$c[2]|$_[0])"; } # In automated testing or non-interactive session, always use defaults if ( ($ENV{AUTOMATED_TESTING} or -! -t STDIN) and ! $ENV{PERL_MM_USE_DEFAULT} ) { local $ENV{PERL_MM_USE_DEFAULT} = 1; goto &ExtUtils::MakeMaker::prompt; } else { goto &ExtUtils::MakeMaker::prompt; } } # Store a cleaned up version of the MakeMaker version, # since we need to behave differently in a variety of # ways based on the MM version. my $makemaker = eval $ExtUtils::MakeMaker::VERSION; # If we are passed a param, do a "newer than" comparison. # Otherwise, just return the MakeMaker version. sub makemaker { ( @_ < 2 or $makemaker >= eval($_[1]) ) ? $makemaker : 0 } # Ripped from ExtUtils::MakeMaker 6.56, and slightly modified # as we only need to know here whether the attribute is an array # or a hash or something else (which may or may not be appendable). my %makemaker_argtype = ( C => 'ARRAY', CONFIG => 'ARRAY', # CONFIGURE => 'CODE', # ignore DIR => 'ARRAY', DL_FUNCS => 'HASH', DL_VARS => 'ARRAY', EXCLUDE_EXT => 'ARRAY', EXE_FILES => 'ARRAY', FUNCLIST => 'ARRAY', H => 'ARRAY', IMPORTS => 'HASH', INCLUDE_EXT => 'ARRAY', LIBS => 'ARRAY', # ignore '' MAN1PODS => 'HASH', MAN3PODS => 'HASH', META_ADD => 'HASH', META_MERGE => 'HASH', PL_FILES => 'HASH', PM => 'HASH', PMLIBDIRS => 'ARRAY', PMLIBPARENTDIRS => 'ARRAY', PREREQ_PM => 'HASH', CONFIGURE_REQUIRES => 'HASH', SKIP => 'ARRAY', TYPEMAPS => 'ARRAY', XS => 'HASH', # VERSION => ['version',''], # ignore # _KEEP_AFTER_FLUSH => '', clean => 'HASH', depend => 'HASH', dist => 'HASH', dynamic_lib=> 'HASH', linkext => 'HASH', macro => 'HASH', postamble => 'HASH', realclean => 'HASH', test => 'HASH', tool_autosplit => 'HASH', # special cases where you can use makemaker_append CCFLAGS => 'APPENDABLE', DEFINE => 'APPENDABLE', INC => 'APPENDABLE', LDDLFLAGS => 'APPENDABLE', LDFROM => 'APPENDABLE', ); sub makemaker_args { my ($self, %new_args) = @_; my $args = ( $self->{makemaker_args} ||= {} ); foreach my $key (keys %new_args) { if ($makemaker_argtype{$key}) { if ($makemaker_argtype{$key} eq 'ARRAY') { $args->{$key} = [] unless defined $args->{$key}; unless (ref $args->{$key} eq 'ARRAY') { $args->{$key} = [$args->{$key}] } push @{$args->{$key}}, ref $new_args{$key} eq 'ARRAY' ? @{$new_args{$key}} : $new_args{$key}; } elsif ($makemaker_argtype{$key} eq 'HASH') { $args->{$key} = {} unless defined $args->{$key}; foreach my $skey (keys %{ $new_args{$key} }) { $args->{$key}{$skey} = $new_args{$key}{$skey}; } } elsif ($makemaker_argtype{$key} eq 'APPENDABLE') { $self->makemaker_append($key => $new_args{$key}); } } else { if (defined $args->{$key}) { warn qq{MakeMaker attribute "$key" is overriden; use "makemaker_append" to append values\n}; } $args->{$key} = $new_args{$key}; } } return $args; } # For mm args that take multiple space-separated args, # append an argument to the current list. sub makemaker_append { my $self = shift; my $name = shift; my $args = $self->makemaker_args; $args->{$name} = defined $args->{$name} ? join( ' ', $args->{$name}, @_ ) : join( ' ', @_ ); } sub build_subdirs { my $self = shift; my $subdirs = $self->makemaker_args->{DIR} ||= []; for my $subdir (@_) { push @$subdirs, $subdir; } } sub clean_files { my $self = shift; my $clean = $self->makemaker_args->{clean} ||= {}; %$clean = ( %$clean, FILES => join ' ', grep { length $_ } ($clean->{FILES} || (), @_), ); } sub realclean_files { my $self = shift; my $realclean = $self->makemaker_args->{realclean} ||= {}; %$realclean = ( %$realclean, FILES => join ' ', grep { length $_ } ($realclean->{FILES} || (), @_), ); } sub libs { my $self = shift; my $libs = ref $_[0] ? shift : [ shift ]; $self->makemaker_args( LIBS => $libs ); } sub inc { my $self = shift; $self->makemaker_args( INC => shift ); } sub _wanted_t { } sub tests_recursive { my $self = shift; my $dir = shift || 't'; unless ( -d $dir ) { die "tests_recursive dir '$dir' does not exist"; } my %tests = map { $_ => 1 } split / /, ($self->tests || ''); require File::Find; File::Find::find( sub { /\.t$/ and -f $_ and $tests{"$File::Find::dir/*.t"} = 1 }, $dir ); $self->tests( join ' ', sort keys %tests ); } sub write { my $self = shift; die "&Makefile->write() takes no arguments\n" if @_; # Check the current Perl version my $perl_version = $self->perl_version; if ( $perl_version ) { eval "use $perl_version; 1" or die "ERROR: perl: Version $] is installed, " . "but we need version >= $perl_version"; } # Make sure we have a new enough MakeMaker require ExtUtils::MakeMaker; if ( $perl_version and $self->_cmp($perl_version, '5.006') >= 0 ) { # This previous attempted to inherit the version of # ExtUtils::MakeMaker in use by the module author, but this # was found to be untenable as some authors build releases # using future dev versions of EU:MM that nobody else has. # Instead, #toolchain suggests we use 6.59 which is the most # stable version on CPAN at time of writing and is, to quote # ribasushi, "not terminally fucked, > and tested enough". # TODO: We will now need to maintain this over time to push # the version up as new versions are released. $self->build_requires( 'ExtUtils::MakeMaker' => 6.59 ); $self->configure_requires( 'ExtUtils::MakeMaker' => 6.59 ); } else { # Allow legacy-compatibility with 5.005 by depending on the # most recent EU:MM that supported 5.005. $self->build_requires( 'ExtUtils::MakeMaker' => 6.36 ); $self->configure_requires( 'ExtUtils::MakeMaker' => 6.36 ); } # Generate the MakeMaker params my $args = $self->makemaker_args; $args->{DISTNAME} = $self->name; $args->{NAME} = $self->module_name || $self->name; $args->{NAME} =~ s/-/::/g; $args->{VERSION} = $self->version or die <<'EOT'; ERROR: Can't determine distribution version. Please specify it explicitly via 'version' in Makefile.PL, or set a valid $VERSION in a module, and provide its file path via 'version_from' (or 'all_from' if you prefer) in Makefile.PL. EOT if ( $self->tests ) { my @tests = split ' ', $self->tests; my %seen; $args->{test} = { TESTS => (join ' ', grep {!$seen{$_}++} @tests), }; } elsif ( $Module::Install::ExtraTests::use_extratests ) { # Module::Install::ExtraTests doesn't set $self->tests and does its own tests via harness. # So, just ignore our xt tests here. } elsif ( -d 'xt' and ($Module::Install::AUTHOR or $ENV{RELEASE_TESTING}) ) { $args->{test} = { TESTS => join( ' ', map { "$_/*.t" } grep { -d $_ } qw{ t xt } ), }; } if ( $] >= 5.005 ) { $args->{ABSTRACT} = $self->abstract; $args->{AUTHOR} = join ', ', @{$self->author || []}; } if ( $self->makemaker(6.10) ) { $args->{NO_META} = 1; #$args->{NO_MYMETA} = 1; } if ( $self->makemaker(6.17) and $self->sign ) { $args->{SIGN} = 1; } unless ( $self->is_admin ) { delete $args->{SIGN}; } if ( $self->makemaker(6.31) and $self->license ) { $args->{LICENSE} = $self->license; } my $prereq = ($args->{PREREQ_PM} ||= {}); %$prereq = ( %$prereq, map { @$_ } # flatten [module => version] map { @$_ } grep $_, ($self->requires) ); # Remove any reference to perl, PREREQ_PM doesn't support it delete $args->{PREREQ_PM}->{perl}; # Merge both kinds of requires into BUILD_REQUIRES my $build_prereq = ($args->{BUILD_REQUIRES} ||= {}); %$build_prereq = ( %$build_prereq, map { @$_ } # flatten [module => version] map { @$_ } grep $_, ($self->configure_requires, $self->build_requires) ); # Remove any reference to perl, BUILD_REQUIRES doesn't support it delete $args->{BUILD_REQUIRES}->{perl}; # Delete bundled dists from prereq_pm, add it to Makefile DIR my $subdirs = ($args->{DIR} || []); if ($self->bundles) { my %processed; foreach my $bundle (@{ $self->bundles }) { my ($mod_name, $dist_dir) = @$bundle; delete $prereq->{$mod_name}; $dist_dir = File::Basename::basename($dist_dir); # dir for building this module if (not exists $processed{$dist_dir}) { if (-d $dist_dir) { # List as sub-directory to be processed by make push @$subdirs, $dist_dir; } # Else do nothing: the module is already present on the system $processed{$dist_dir} = undef; } } } unless ( $self->makemaker('6.55_03') ) { %$prereq = (%$prereq,%$build_prereq); delete $args->{BUILD_REQUIRES}; } if ( my $perl_version = $self->perl_version ) { eval "use $perl_version; 1" or die "ERROR: perl: Version $] is installed, " . "but we need version >= $perl_version"; if ( $self->makemaker(6.48) ) { $args->{MIN_PERL_VERSION} = $perl_version; } } if ($self->installdirs) { warn qq{old INSTALLDIRS (probably set by makemaker_args) is overriden by installdirs\n} if $args->{INSTALLDIRS}; $args->{INSTALLDIRS} = $self->installdirs; } my %args = map { ( $_ => $args->{$_} ) } grep {defined($args->{$_} ) } keys %$args; my $user_preop = delete $args{dist}->{PREOP}; if ( my $preop = $self->admin->preop($user_preop) ) { foreach my $key ( keys %$preop ) { $args{dist}->{$key} = $preop->{$key}; } } my $mm = ExtUtils::MakeMaker::WriteMakefile(%args); $self->fix_up_makefile($mm->{FIRST_MAKEFILE} || 'Makefile'); } sub fix_up_makefile { my $self = shift; my $makefile_name = shift; my $top_class = ref($self->_top) || ''; my $top_version = $self->_top->VERSION || ''; my $preamble = $self->preamble ? "# Preamble by $top_class $top_version\n" . $self->preamble : ''; my $postamble = "# Postamble by $top_class $top_version\n" . ($self->postamble || ''); local *MAKEFILE; open MAKEFILE, "+< $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!"; eval { flock MAKEFILE, LOCK_EX }; my $makefile = do { local $/; }; $makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /; $makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g; $makefile =~ s/( "-I\$\(INST_LIB\)")/ "-Iinc"$1/g; $makefile =~ s/^(FULLPERL = .*)/$1 "-Iinc"/m; $makefile =~ s/^(PERL = .*)/$1 "-Iinc"/m; # Module::Install will never be used to build the Core Perl # Sometimes PERL_LIB and PERL_ARCHLIB get written anyway, which breaks # PREFIX/PERL5LIB, and thus, install_share. Blank them if they exist $makefile =~ s/^PERL_LIB = .+/PERL_LIB =/m; #$makefile =~ s/^PERL_ARCHLIB = .+/PERL_ARCHLIB =/m; # Perl 5.005 mentions PERL_LIB explicitly, so we have to remove that as well. $makefile =~ s/(\"?)-I\$\(PERL_LIB\)\1//g; # XXX - This is currently unused; not sure if it breaks other MM-users # $makefile =~ s/^pm_to_blib\s+:\s+/pm_to_blib :: /mg; seek MAKEFILE, 0, SEEK_SET; truncate MAKEFILE, 0; print MAKEFILE "$preamble$makefile$postamble" or die $!; close MAKEFILE or die $!; 1; } sub preamble { my ($self, $text) = @_; $self->{preamble} = $text . $self->{preamble} if defined $text; $self->{preamble}; } sub postamble { my ($self, $text) = @_; $self->{postamble} ||= $self->admin->postamble; $self->{postamble} .= $text if defined $text; $self->{postamble} } 1; __END__ #line 544 Webinject-1.94/inc/Module/Install/Include.pm0000644000175000017500000000101513135607421017415 0ustar svensven#line 1 package Module::Install::Include; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.14'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } sub include { shift()->admin->include(@_); } sub include_deps { shift()->admin->include_deps(@_); } sub auto_include { shift()->admin->auto_include(@_); } sub auto_include_deps { shift()->admin->auto_include_deps(@_); } sub auto_include_dependent_dists { shift()->admin->auto_include_dependent_dists(@_); } 1; Webinject-1.94/inc/Module/Install/Fetch.pm0000644000175000017500000000462713135607421017077 0ustar svensven#line 1 package Module::Install::Fetch; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.14'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } sub get_file { my ($self, %args) = @_; my ($scheme, $host, $path, $file) = $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return; if ( $scheme eq 'http' and ! eval { require LWP::Simple; 1 } ) { $args{url} = $args{ftp_url} or (warn("LWP support unavailable!\n"), return); ($scheme, $host, $path, $file) = $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return; } $|++; print "Fetching '$file' from $host... "; unless (eval { require Socket; Socket::inet_aton($host) }) { warn "'$host' resolve failed!\n"; return; } return unless $scheme eq 'ftp' or $scheme eq 'http'; require Cwd; my $dir = Cwd::getcwd(); chdir $args{local_dir} or return if exists $args{local_dir}; if (eval { require LWP::Simple; 1 }) { LWP::Simple::mirror($args{url}, $file); } elsif (eval { require Net::FTP; 1 }) { eval { # use Net::FTP to get past firewall my $ftp = Net::FTP->new($host, Passive => 1, Timeout => 600); $ftp->login("anonymous", 'anonymous@example.com'); $ftp->cwd($path); $ftp->binary; $ftp->get($file) or (warn("$!\n"), return); $ftp->quit; } } elsif (my $ftp = $self->can_run('ftp')) { eval { # no Net::FTP, fallback to ftp.exe require FileHandle; my $fh = FileHandle->new; local $SIG{CHLD} = 'IGNORE'; unless ($fh->open("|$ftp -n")) { warn "Couldn't open ftp: $!\n"; chdir $dir; return; } my @dialog = split(/\n/, <<"END_FTP"); open $host user anonymous anonymous\@example.com cd $path binary get $file $file quit END_FTP foreach (@dialog) { $fh->print("$_\n") } $fh->close; } } else { warn "No working 'ftp' program available!\n"; chdir $dir; return; } unless (-f $file) { warn "Fetching failed: $@\n"; chdir $dir; return; } return if exists $args{size} and -s $file != $args{size}; system($args{run}) if exists $args{run}; unlink($file) if $args{remove}; print(((!exists $args{check_for} or -e $args{check_for}) ? "done!" : "failed! ($!)"), "\n"); chdir $dir; return !$?; } 1; Webinject-1.94/inc/Module/Install/WriteAll.pm0000644000175000017500000000237613135607421017570 0ustar svensven#line 1 package Module::Install::WriteAll; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.14'; @ISA = qw{Module::Install::Base}; $ISCORE = 1; } sub WriteAll { my $self = shift; my %args = ( meta => 1, sign => 0, inline => 0, check_nmake => 1, @_, ); $self->sign(1) if $args{sign}; $self->admin->WriteAll(%args) if $self->is_admin; $self->check_nmake if $args{check_nmake}; unless ( $self->makemaker_args->{PL_FILES} ) { # XXX: This still may be a bit over-defensive... unless ($self->makemaker(6.25)) { $self->makemaker_args( PL_FILES => {} ) if -f 'Build.PL'; } } # Until ExtUtils::MakeMaker support MYMETA.yml, make sure # we clean it up properly ourself. $self->realclean_files('MYMETA.yml'); if ( $args{inline} ) { $self->Inline->write; } else { $self->Makefile->write; } # The Makefile write process adds a couple of dependencies, # so write the META.yml files after the Makefile. if ( $args{meta} ) { $self->Meta->write; } # Experimental support for MYMETA if ( $ENV{X_MYMETA} ) { if ( $ENV{X_MYMETA} eq 'JSON' ) { $self->Meta->write_mymeta_json; } else { $self->Meta->write_mymeta_yaml; } } return 1; } 1; Webinject-1.94/inc/Module/Install/Win32.pm0000644000175000017500000000340313135607421016737 0ustar svensven#line 1 package Module::Install::Win32; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.14'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } # determine if the user needs nmake, and download it if needed sub check_nmake { my $self = shift; $self->load('can_run'); $self->load('get_file'); require Config; return unless ( $^O eq 'MSWin32' and $Config::Config{make} and $Config::Config{make} =~ /^nmake\b/i and ! $self->can_run('nmake') ); print "The required 'nmake' executable not found, fetching it...\n"; require File::Basename; my $rv = $self->get_file( url => 'http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe', ftp_url => 'ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe', local_dir => File::Basename::dirname($^X), size => 51928, run => 'Nmake15.exe /o > nul', check_for => 'Nmake.exe', remove => 1, ); die <<'END_MESSAGE' unless $rv; ------------------------------------------------------------------------------- Since you are using Microsoft Windows, you will need the 'nmake' utility before installation. It's available at: http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe or ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe Please download the file manually, save it to a directory in %PATH% (e.g. C:\WINDOWS\COMMAND\), then launch the MS-DOS command line shell, "cd" to that directory, and run "Nmake15.exe" from there; that will create the 'nmake.exe' file needed by this module. You may then resume the installation process described in README. ------------------------------------------------------------------------------- END_MESSAGE } 1; Webinject-1.94/inc/Module/Install/Base.pm0000644000175000017500000000214713135607421016713 0ustar svensven#line 1 package Module::Install::Base; use strict 'vars'; use vars qw{$VERSION}; BEGIN { $VERSION = '1.14'; } # Suspend handler for "redefined" warnings BEGIN { my $w = $SIG{__WARN__}; $SIG{__WARN__} = sub { $w }; } #line 42 sub new { my $class = shift; unless ( defined &{"${class}::call"} ) { *{"${class}::call"} = sub { shift->_top->call(@_) }; } unless ( defined &{"${class}::load"} ) { *{"${class}::load"} = sub { shift->_top->load(@_) }; } bless { @_ }, $class; } #line 61 sub AUTOLOAD { local $@; my $func = eval { shift->_top->autoload } or return; goto &$func; } #line 75 sub _top { $_[0]->{_top}; } #line 90 sub admin { $_[0]->_top->{admin} or Module::Install::Base::FakeAdmin->new; } #line 106 sub is_admin { ! $_[0]->admin->isa('Module::Install::Base::FakeAdmin'); } sub DESTROY {} package Module::Install::Base::FakeAdmin; use vars qw{$VERSION}; BEGIN { $VERSION = $Module::Install::Base::VERSION; } my $fake; sub new { $fake ||= bless(\@_, $_[0]); } sub AUTOLOAD {} sub DESTROY {} # Restore warning handler BEGIN { $SIG{__WARN__} = $SIG{__WARN__}->(); } 1; #line 159 Webinject-1.94/inc/Module/Install/AutoInstall.pm0000644000175000017500000000416213135607421020277 0ustar svensven#line 1 package Module::Install::AutoInstall; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.14'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } sub AutoInstall { $_[0] } sub run { my $self = shift; $self->auto_install_now(@_); } sub write { my $self = shift; $self->auto_install(@_); } sub auto_install { my $self = shift; return if $self->{done}++; # Flatten array of arrays into a single array my @core = map @$_, map @$_, grep ref, $self->build_requires, $self->requires; my @config = @_; # We'll need Module::AutoInstall $self->include('Module::AutoInstall'); require Module::AutoInstall; my @features_require = Module::AutoInstall->import( (@config ? (-config => \@config) : ()), (@core ? (-core => \@core) : ()), $self->features, ); my %seen; my @requires = map @$_, map @$_, grep ref, $self->requires; while (my ($mod, $ver) = splice(@requires, 0, 2)) { $seen{$mod}{$ver}++; } my @build_requires = map @$_, map @$_, grep ref, $self->build_requires; while (my ($mod, $ver) = splice(@build_requires, 0, 2)) { $seen{$mod}{$ver}++; } my @configure_requires = map @$_, map @$_, grep ref, $self->configure_requires; while (my ($mod, $ver) = splice(@configure_requires, 0, 2)) { $seen{$mod}{$ver}++; } my @deduped; while (my ($mod, $ver) = splice(@features_require, 0, 2)) { push @deduped, $mod => $ver unless $seen{$mod}{$ver}++; } $self->requires(@deduped); $self->makemaker_args( Module::AutoInstall::_make_args() ); my $class = ref($self); $self->postamble( "# --- $class section:\n" . Module::AutoInstall::postamble() ); } sub installdeps_target { my ($self, @args) = @_; $self->include('Module::AutoInstall'); require Module::AutoInstall; Module::AutoInstall::_installdeps_target(1); $self->auto_install(@args); } sub auto_install_now { my $self = shift; $self->auto_install(@_); Module::AutoInstall::do_install(); } 1; Webinject-1.94/inc/Module/Install.pm0000644000175000017500000003021713135607421016040 0ustar svensven#line 1 package Module::Install; # For any maintainers: # The load order for Module::Install is a bit magic. # It goes something like this... # # IF ( host has Module::Install installed, creating author mode ) { # 1. Makefile.PL calls "use inc::Module::Install" # 2. $INC{inc/Module/Install.pm} set to installed version of inc::Module::Install # 3. The installed version of inc::Module::Install loads # 4. inc::Module::Install calls "require Module::Install" # 5. The ./inc/ version of Module::Install loads # } ELSE { # 1. Makefile.PL calls "use inc::Module::Install" # 2. $INC{inc/Module/Install.pm} set to ./inc/ version of Module::Install # 3. The ./inc/ version of Module::Install loads # } use 5.006; use strict 'vars'; use Cwd (); use File::Find (); use File::Path (); use vars qw{$VERSION $MAIN}; BEGIN { # All Module::Install core packages now require synchronised versions. # This will be used to ensure we don't accidentally load old or # different versions of modules. # This is not enforced yet, but will be some time in the next few # releases once we can make sure it won't clash with custom # Module::Install extensions. $VERSION = '1.14'; # Storage for the pseudo-singleton $MAIN = undef; *inc::Module::Install::VERSION = *VERSION; @inc::Module::Install::ISA = __PACKAGE__; } sub import { my $class = shift; my $self = $class->new(@_); my $who = $self->_caller; #------------------------------------------------------------- # all of the following checks should be included in import(), # to allow "eval 'require Module::Install; 1' to test # installation of Module::Install. (RT #51267) #------------------------------------------------------------- # Whether or not inc::Module::Install is actually loaded, the # $INC{inc/Module/Install.pm} is what will still get set as long as # the caller loaded module this in the documented manner. # If not set, the caller may NOT have loaded the bundled version, and thus # they may not have a MI version that works with the Makefile.PL. This would # result in false errors or unexpected behaviour. And we don't want that. my $file = join( '/', 'inc', split /::/, __PACKAGE__ ) . '.pm'; unless ( $INC{$file} ) { die <<"END_DIE" } Please invoke ${\__PACKAGE__} with: use inc::${\__PACKAGE__}; not: use ${\__PACKAGE__}; END_DIE # This reportedly fixes a rare Win32 UTC file time issue, but # as this is a non-cross-platform XS module not in the core, # we shouldn't really depend on it. See RT #24194 for detail. # (Also, this module only supports Perl 5.6 and above). eval "use Win32::UTCFileTime" if $^O eq 'MSWin32' && $] >= 5.006; # If the script that is loading Module::Install is from the future, # then make will detect this and cause it to re-run over and over # again. This is bad. Rather than taking action to touch it (which # is unreliable on some platforms and requires write permissions) # for now we should catch this and refuse to run. if ( -f $0 ) { my $s = (stat($0))[9]; # If the modification time is only slightly in the future, # sleep briefly to remove the problem. my $a = $s - time; if ( $a > 0 and $a < 5 ) { sleep 5 } # Too far in the future, throw an error. my $t = time; if ( $s > $t ) { die <<"END_DIE" } Your installer $0 has a modification time in the future ($s > $t). This is known to create infinite loops in make. Please correct this, then run $0 again. END_DIE } # Build.PL was formerly supported, but no longer is due to excessive # difficulty in implementing every single feature twice. if ( $0 =~ /Build.PL$/i ) { die <<"END_DIE" } Module::Install no longer supports Build.PL. It was impossible to maintain duel backends, and has been deprecated. Please remove all Build.PL files and only use the Makefile.PL installer. END_DIE #------------------------------------------------------------- # To save some more typing in Module::Install installers, every... # use inc::Module::Install # ...also acts as an implicit use strict. $^H |= strict::bits(qw(refs subs vars)); #------------------------------------------------------------- unless ( -f $self->{file} ) { foreach my $key (keys %INC) { delete $INC{$key} if $key =~ /Module\/Install/; } local $^W; require "$self->{path}/$self->{dispatch}.pm"; File::Path::mkpath("$self->{prefix}/$self->{author}"); $self->{admin} = "$self->{name}::$self->{dispatch}"->new( _top => $self ); $self->{admin}->init; @_ = ($class, _self => $self); goto &{"$self->{name}::import"}; } local $^W; *{"${who}::AUTOLOAD"} = $self->autoload; $self->preload; # Unregister loader and worker packages so subdirs can use them again delete $INC{'inc/Module/Install.pm'}; delete $INC{'Module/Install.pm'}; # Save to the singleton $MAIN = $self; return 1; } sub autoload { my $self = shift; my $who = $self->_caller; my $cwd = Cwd::getcwd(); my $sym = "${who}::AUTOLOAD"; $sym->{$cwd} = sub { my $pwd = Cwd::getcwd(); if ( my $code = $sym->{$pwd} ) { # Delegate back to parent dirs goto &$code unless $cwd eq $pwd; } unless ($$sym =~ s/([^:]+)$//) { # XXX: it looks like we can't retrieve the missing function # via $$sym (usually $main::AUTOLOAD) in this case. # I'm still wondering if we should slurp Makefile.PL to # get some context or not ... my ($package, $file, $line) = caller; die <<"EOT"; Unknown function is found at $file line $line. Execution of $file aborted due to runtime errors. If you're a contributor to a project, you may need to install some Module::Install extensions from CPAN (or other repository). If you're a user of a module, please contact the author. EOT } my $method = $1; if ( uc($method) eq $method ) { # Do nothing return; } elsif ( $method =~ /^_/ and $self->can($method) ) { # Dispatch to the root M:I class return $self->$method(@_); } # Dispatch to the appropriate plugin unshift @_, ( $self, $1 ); goto &{$self->can('call')}; }; } sub preload { my $self = shift; unless ( $self->{extensions} ) { $self->load_extensions( "$self->{prefix}/$self->{path}", $self ); } my @exts = @{$self->{extensions}}; unless ( @exts ) { @exts = $self->{admin}->load_all_extensions; } my %seen; foreach my $obj ( @exts ) { while (my ($method, $glob) = each %{ref($obj) . '::'}) { next unless $obj->can($method); next if $method =~ /^_/; next if $method eq uc($method); $seen{$method}++; } } my $who = $self->_caller; foreach my $name ( sort keys %seen ) { local $^W; *{"${who}::$name"} = sub { ${"${who}::AUTOLOAD"} = "${who}::$name"; goto &{"${who}::AUTOLOAD"}; }; } } sub new { my ($class, %args) = @_; delete $INC{'FindBin.pm'}; { # to suppress the redefine warning local $SIG{__WARN__} = sub {}; require FindBin; } # ignore the prefix on extension modules built from top level. my $base_path = Cwd::abs_path($FindBin::Bin); unless ( Cwd::abs_path(Cwd::getcwd()) eq $base_path ) { delete $args{prefix}; } return $args{_self} if $args{_self}; $args{dispatch} ||= 'Admin'; $args{prefix} ||= 'inc'; $args{author} ||= ($^O eq 'VMS' ? '_author' : '.author'); $args{bundle} ||= 'inc/BUNDLES'; $args{base} ||= $base_path; $class =~ s/^\Q$args{prefix}\E:://; $args{name} ||= $class; $args{version} ||= $class->VERSION; unless ( $args{path} ) { $args{path} = $args{name}; $args{path} =~ s!::!/!g; } $args{file} ||= "$args{base}/$args{prefix}/$args{path}.pm"; $args{wrote} = 0; bless( \%args, $class ); } sub call { my ($self, $method) = @_; my $obj = $self->load($method) or return; splice(@_, 0, 2, $obj); goto &{$obj->can($method)}; } sub load { my ($self, $method) = @_; $self->load_extensions( "$self->{prefix}/$self->{path}", $self ) unless $self->{extensions}; foreach my $obj (@{$self->{extensions}}) { return $obj if $obj->can($method); } my $admin = $self->{admin} or die <<"END_DIE"; The '$method' method does not exist in the '$self->{prefix}' path! Please remove the '$self->{prefix}' directory and run $0 again to load it. END_DIE my $obj = $admin->load($method, 1); push @{$self->{extensions}}, $obj; $obj; } sub load_extensions { my ($self, $path, $top) = @_; my $should_reload = 0; unless ( grep { ! ref $_ and lc $_ eq lc $self->{prefix} } @INC ) { unshift @INC, $self->{prefix}; $should_reload = 1; } foreach my $rv ( $self->find_extensions($path) ) { my ($file, $pkg) = @{$rv}; next if $self->{pathnames}{$pkg}; local $@; my $new = eval { local $^W; require $file; $pkg->can('new') }; unless ( $new ) { warn $@ if $@; next; } $self->{pathnames}{$pkg} = $should_reload ? delete $INC{$file} : $INC{$file}; push @{$self->{extensions}}, &{$new}($pkg, _top => $top ); } $self->{extensions} ||= []; } sub find_extensions { my ($self, $path) = @_; my @found; File::Find::find( sub { my $file = $File::Find::name; return unless $file =~ m!^\Q$path\E/(.+)\.pm\Z!is; my $subpath = $1; return if lc($subpath) eq lc($self->{dispatch}); $file = "$self->{path}/$subpath.pm"; my $pkg = "$self->{name}::$subpath"; $pkg =~ s!/!::!g; # If we have a mixed-case package name, assume case has been preserved # correctly. Otherwise, root through the file to locate the case-preserved # version of the package name. if ( $subpath eq lc($subpath) || $subpath eq uc($subpath) ) { my $content = Module::Install::_read($subpath . '.pm'); my $in_pod = 0; foreach ( split /\n/, $content ) { $in_pod = 1 if /^=\w/; $in_pod = 0 if /^=cut/; next if ($in_pod || /^=cut/); # skip pod text next if /^\s*#/; # and comments if ( m/^\s*package\s+($pkg)\s*;/i ) { $pkg = $1; last; } } } push @found, [ $file, $pkg ]; }, $path ) if -d $path; @found; } ##################################################################### # Common Utility Functions sub _caller { my $depth = 0; my $call = caller($depth); while ( $call eq __PACKAGE__ ) { $depth++; $call = caller($depth); } return $call; } # Done in evals to avoid confusing Perl::MinimumVersion eval( $] >= 5.006 ? <<'END_NEW' : <<'END_OLD' ); die $@ if $@; sub _read { local *FH; open( FH, '<', $_[0] ) or die "open($_[0]): $!"; binmode FH; my $string = do { local $/; }; close FH or die "close($_[0]): $!"; return $string; } END_NEW sub _read { local *FH; open( FH, "< $_[0]" ) or die "open($_[0]): $!"; binmode FH; my $string = do { local $/; }; close FH or die "close($_[0]): $!"; return $string; } END_OLD sub _readperl { my $string = Module::Install::_read($_[0]); $string =~ s/(?:\015{1,2}\012|\015|\012)/\n/sg; $string =~ s/(\n)\n*__(?:DATA|END)__\b.*\z/$1/s; $string =~ s/\n\n=\w+.+?\n\n=cut\b.+?\n+/\n\n/sg; return $string; } sub _readpod { my $string = Module::Install::_read($_[0]); $string =~ s/(?:\015{1,2}\012|\015|\012)/\n/sg; return $string if $_[0] =~ /\.pod\z/; $string =~ s/(^|\n=cut\b.+?\n+)[^=\s].+?\n(\n=\w+|\z)/$1$2/sg; $string =~ s/\n*=pod\b[^\n]*\n+/\n\n/sg; $string =~ s/\n*=cut\b[^\n]*\n+/\n\n/sg; $string =~ s/^\n+//s; return $string; } # Done in evals to avoid confusing Perl::MinimumVersion eval( $] >= 5.006 ? <<'END_NEW' : <<'END_OLD' ); die $@ if $@; sub _write { local *FH; open( FH, '>', $_[0] ) or die "open($_[0]): $!"; binmode FH; foreach ( 1 .. $#_ ) { print FH $_[$_] or die "print($_[0]): $!"; } close FH or die "close($_[0]): $!"; } END_NEW sub _write { local *FH; open( FH, "> $_[0]" ) or die "open($_[0]): $!"; binmode FH; foreach ( 1 .. $#_ ) { print FH $_[$_] or die "print($_[0]): $!"; } close FH or die "close($_[0]): $!"; } END_OLD # _version is for processing module versions (eg, 1.03_05) not # Perl versions (eg, 5.8.1). sub _version { my $s = shift || 0; my $d =()= $s =~ /(\.)/g; if ( $d >= 2 ) { # Normalise multipart versions $s =~ s/(\.)(\d{1,3})/sprintf("$1%03d",$2)/eg; } $s =~ s/^(\d+)\.?//; my $l = $1 || 0; my @v = map { $_ . '0' x (3 - length $_) } $s =~ /(\d{1,3})\D?/g; $l = $l . '.' . join '', @v if @v; return $l + 0; } sub _cmp { _version($_[1]) <=> _version($_[2]); } # Cloned from Params::Util::_CLASS sub _CLASS { ( defined $_[0] and ! ref $_[0] and $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*\z/s ) ? $_[0] : undef; } 1; # Copyright 2008 - 2012 Adam Kennedy. Webinject-1.94/inc/Module/AutoInstall.pm0000644000175000017500000006225413135607421016677 0ustar svensven#line 1 package Module::AutoInstall; use strict; use Cwd (); use File::Spec (); use ExtUtils::MakeMaker (); use vars qw{$VERSION}; BEGIN { $VERSION = '1.14'; } # special map on pre-defined feature sets my %FeatureMap = ( '' => 'Core Features', # XXX: deprecated '-core' => 'Core Features', ); # various lexical flags my ( @Missing, @Existing, %DisabledTests, $UnderCPAN, $InstallDepsTarget, $HasCPANPLUS ); my ( $Config, $CheckOnly, $SkipInstall, $AcceptDefault, $TestOnly, $AllDeps, $UpgradeDeps ); my ( $PostambleActions, $PostambleActionsNoTest, $PostambleActionsUpgradeDeps, $PostambleActionsUpgradeDepsNoTest, $PostambleActionsListDeps, $PostambleActionsListAllDeps, $PostambleUsed, $NoTest); # See if it's a testing or non-interactive session _accept_default( $ENV{AUTOMATED_TESTING} or ! -t STDIN ); _init(); sub _accept_default { $AcceptDefault = shift; } sub _installdeps_target { $InstallDepsTarget = shift; } sub missing_modules { return @Missing; } sub do_install { __PACKAGE__->install( [ $Config ? ( UNIVERSAL::isa( $Config, 'HASH' ) ? %{$Config} : @{$Config} ) : () ], @Missing, ); } # initialize various flags, and/or perform install sub _init { foreach my $arg ( @ARGV, split( /[\s\t]+/, $ENV{PERL_AUTOINSTALL} || $ENV{PERL_EXTUTILS_AUTOINSTALL} || '' ) ) { if ( $arg =~ /^--config=(.*)$/ ) { $Config = [ split( ',', $1 ) ]; } elsif ( $arg =~ /^--installdeps=(.*)$/ ) { __PACKAGE__->install( $Config, @Missing = split( /,/, $1 ) ); exit 0; } elsif ( $arg =~ /^--upgradedeps=(.*)$/ ) { $UpgradeDeps = 1; __PACKAGE__->install( $Config, @Missing = split( /,/, $1 ) ); exit 0; } elsif ( $arg =~ /^--default(?:deps)?$/ ) { $AcceptDefault = 1; } elsif ( $arg =~ /^--check(?:deps)?$/ ) { $CheckOnly = 1; } elsif ( $arg =~ /^--skip(?:deps)?$/ ) { $SkipInstall = 1; } elsif ( $arg =~ /^--test(?:only)?$/ ) { $TestOnly = 1; } elsif ( $arg =~ /^--all(?:deps)?$/ ) { $AllDeps = 1; } } } # overrides MakeMaker's prompt() to automatically accept the default choice sub _prompt { goto &ExtUtils::MakeMaker::prompt unless $AcceptDefault; my ( $prompt, $default ) = @_; my $y = ( $default =~ /^[Yy]/ ); print $prompt, ' [', ( $y ? 'Y' : 'y' ), '/', ( $y ? 'n' : 'N' ), '] '; print "$default\n"; return $default; } # the workhorse sub import { my $class = shift; my @args = @_ or return; my $core_all; print "*** $class version " . $class->VERSION . "\n"; print "*** Checking for Perl dependencies...\n"; my $cwd = Cwd::getcwd(); $Config = []; my $maxlen = length( ( sort { length($b) <=> length($a) } grep { /^[^\-]/ } map { ref($_) ? ( ( ref($_) eq 'HASH' ) ? keys(%$_) : @{$_} ) : '' } map { +{@args}->{$_} } grep { /^[^\-]/ or /^-core$/i } keys %{ +{@args} } )[0] ); # We want to know if we're under CPAN early to avoid prompting, but # if we aren't going to try and install anything anyway then skip the # check entirely since we don't want to have to load (and configure) # an old CPAN just for a cosmetic message $UnderCPAN = _check_lock(1) unless $SkipInstall || $InstallDepsTarget; while ( my ( $feature, $modules ) = splice( @args, 0, 2 ) ) { my ( @required, @tests, @skiptests ); my $default = 1; my $conflict = 0; if ( $feature =~ m/^-(\w+)$/ ) { my $option = lc($1); # check for a newer version of myself _update_to( $modules, @_ ) and return if $option eq 'version'; # sets CPAN configuration options $Config = $modules if $option eq 'config'; # promote every features to core status $core_all = ( $modules =~ /^all$/i ) and next if $option eq 'core'; next unless $option eq 'core'; } print "[" . ( $FeatureMap{ lc($feature) } || $feature ) . "]\n"; $modules = [ %{$modules} ] if UNIVERSAL::isa( $modules, 'HASH' ); unshift @$modules, -default => &{ shift(@$modules) } if ( ref( $modules->[0] ) eq 'CODE' ); # XXX: bugward compatibility while ( my ( $mod, $arg ) = splice( @$modules, 0, 2 ) ) { if ( $mod =~ m/^-(\w+)$/ ) { my $option = lc($1); $default = $arg if ( $option eq 'default' ); $conflict = $arg if ( $option eq 'conflict' ); @tests = @{$arg} if ( $option eq 'tests' ); @skiptests = @{$arg} if ( $option eq 'skiptests' ); next; } printf( "- %-${maxlen}s ...", $mod ); if ( $arg and $arg =~ /^\D/ ) { unshift @$modules, $arg; $arg = 0; } # XXX: check for conflicts and uninstalls(!) them. my $cur = _version_of($mod); if (_version_cmp ($cur, $arg) >= 0) { print "loaded. ($cur" . ( $arg ? " >= $arg" : '' ) . ")\n"; push @Existing, $mod => $arg; $DisabledTests{$_} = 1 for map { glob($_) } @skiptests; } else { if (not defined $cur) # indeed missing { print "missing." . ( $arg ? " (would need $arg)" : '' ) . "\n"; } else { # no need to check $arg as _version_cmp ($cur, undef) would satisfy >= above print "too old. ($cur < $arg)\n"; } push @required, $mod => $arg; } } next unless @required; my $mandatory = ( $feature eq '-core' or $core_all ); if ( !$SkipInstall and ( $CheckOnly or ($mandatory and $UnderCPAN) or $AllDeps or $InstallDepsTarget or _prompt( qq{==> Auto-install the } . ( @required / 2 ) . ( $mandatory ? ' mandatory' : ' optional' ) . qq{ module(s) from CPAN?}, $default ? 'y' : 'n', ) =~ /^[Yy]/ ) ) { push( @Missing, @required ); $DisabledTests{$_} = 1 for map { glob($_) } @skiptests; } elsif ( !$SkipInstall and $default and $mandatory and _prompt( qq{==> The module(s) are mandatory! Really skip?}, 'n', ) =~ /^[Nn]/ ) { push( @Missing, @required ); $DisabledTests{$_} = 1 for map { glob($_) } @skiptests; } else { $DisabledTests{$_} = 1 for map { glob($_) } @tests; } } if ( @Missing and not( $CheckOnly or $UnderCPAN) ) { require Config; my $make = $Config::Config{make}; if ($InstallDepsTarget) { print "*** To install dependencies type '$make installdeps' or '$make installdeps_notest'.\n"; } else { print "*** Dependencies will be installed the next time you type '$make'.\n"; } # make an educated guess of whether we'll need root permission. print " (You may need to do that as the 'root' user.)\n" if eval '$>'; } print "*** $class configuration finished.\n"; chdir $cwd; # import to main:: no strict 'refs'; *{'main::WriteMakefile'} = \&Write if caller(0) eq 'main'; return (@Existing, @Missing); } sub _running_under { my $thing = shift; print <<"END_MESSAGE"; *** Since we're running under ${thing}, I'll just let it take care of the dependency's installation later. END_MESSAGE return 1; } # Check to see if we are currently running under CPAN.pm and/or CPANPLUS; # if we are, then we simply let it taking care of our dependencies sub _check_lock { return unless @Missing or @_; if ($ENV{PERL5_CPANM_IS_RUNNING}) { return _running_under('cpanminus'); } my $cpan_env = $ENV{PERL5_CPAN_IS_RUNNING}; if ($ENV{PERL5_CPANPLUS_IS_RUNNING}) { return _running_under($cpan_env ? 'CPAN' : 'CPANPLUS'); } require CPAN; if ($CPAN::VERSION > '1.89') { if ($cpan_env) { return _running_under('CPAN'); } return; # CPAN.pm new enough, don't need to check further } # last ditch attempt, this -will- configure CPAN, very sorry _load_cpan(1); # force initialize even though it's already loaded # Find the CPAN lock-file my $lock = MM->catfile( $CPAN::Config->{cpan_home}, ".lock" ); return unless -f $lock; # Check the lock local *LOCK; return unless open(LOCK, $lock); if ( ( $^O eq 'MSWin32' ? _under_cpan() : == getppid() ) and ( $CPAN::Config->{prerequisites_policy} || '' ) ne 'ignore' ) { print <<'END_MESSAGE'; *** Since we're running under CPAN, I'll just let it take care of the dependency's installation later. END_MESSAGE return 1; } close LOCK; return; } sub install { my $class = shift; my $i; # used below to strip leading '-' from config keys my @config = ( map { s/^-// if ++$i; $_ } @{ +shift } ); my ( @modules, @installed, @modules_to_upgrade ); while (my ($pkg, $ver) = splice(@_, 0, 2)) { # grep out those already installed if (_version_cmp(_version_of($pkg), $ver) >= 0) { push @installed, $pkg; if ($UpgradeDeps) { push @modules_to_upgrade, $pkg, $ver; } } else { push @modules, $pkg, $ver; } } if ($UpgradeDeps) { push @modules, @modules_to_upgrade; @installed = (); @modules_to_upgrade = (); } return @installed unless @modules; # nothing to do return @installed if _check_lock(); # defer to the CPAN shell print "*** Installing dependencies...\n"; return unless _connected_to('cpan.org'); my %args = @config; my %failed; local *FAILED; if ( $args{do_once} and open( FAILED, '.#autoinstall.failed' ) ) { while () { chomp; $failed{$_}++ } close FAILED; my @newmod; while ( my ( $k, $v ) = splice( @modules, 0, 2 ) ) { push @newmod, ( $k => $v ) unless $failed{$k}; } @modules = @newmod; } if ( _has_cpanplus() and not $ENV{PERL_AUTOINSTALL_PREFER_CPAN} ) { _install_cpanplus( \@modules, \@config ); } else { _install_cpan( \@modules, \@config ); } print "*** $class installation finished.\n"; # see if we have successfully installed them while ( my ( $pkg, $ver ) = splice( @modules, 0, 2 ) ) { if ( _version_cmp( _version_of($pkg), $ver ) >= 0 ) { push @installed, $pkg; } elsif ( $args{do_once} and open( FAILED, '>> .#autoinstall.failed' ) ) { print FAILED "$pkg\n"; } } close FAILED if $args{do_once}; return @installed; } sub _install_cpanplus { my @modules = @{ +shift }; my @config = _cpanplus_config( @{ +shift } ); my $installed = 0; require CPANPLUS::Backend; my $cp = CPANPLUS::Backend->new; my $conf = $cp->configure_object; return unless $conf->can('conf') # 0.05x+ with "sudo" support or _can_write($conf->_get_build('base')); # 0.04x # if we're root, set UNINST=1 to avoid trouble unless user asked for it. my $makeflags = $conf->get_conf('makeflags') || ''; if ( UNIVERSAL::isa( $makeflags, 'HASH' ) ) { # 0.03+ uses a hashref here $makeflags->{UNINST} = 1 unless exists $makeflags->{UNINST}; } else { # 0.02 and below uses a scalar $makeflags = join( ' ', split( ' ', $makeflags ), 'UNINST=1' ) if ( $makeflags !~ /\bUNINST\b/ and eval qq{ $> eq '0' } ); } $conf->set_conf( makeflags => $makeflags ); $conf->set_conf( prereqs => 1 ); while ( my ( $key, $val ) = splice( @config, 0, 2 ) ) { $conf->set_conf( $key, $val ); } my $modtree = $cp->module_tree; while ( my ( $pkg, $ver ) = splice( @modules, 0, 2 ) ) { print "*** Installing $pkg...\n"; MY::preinstall( $pkg, $ver ) or next if defined &MY::preinstall; my $success; my $obj = $modtree->{$pkg}; if ( $obj and _version_cmp( $obj->{version}, $ver ) >= 0 ) { my $pathname = $pkg; $pathname =~ s/::/\\W/; foreach my $inc ( grep { m/$pathname.pm/i } keys(%INC) ) { delete $INC{$inc}; } my $rv = $cp->install( modules => [ $obj->{module} ] ); if ( $rv and ( $rv->{ $obj->{module} } or $rv->{ok} ) ) { print "*** $pkg successfully installed.\n"; $success = 1; } else { print "*** $pkg installation cancelled.\n"; $success = 0; } $installed += $success; } else { print << "."; *** Could not find a version $ver or above for $pkg; skipping. . } MY::postinstall( $pkg, $ver, $success ) if defined &MY::postinstall; } return $installed; } sub _cpanplus_config { my @config = (); while ( @_ ) { my ($key, $value) = (shift(), shift()); if ( $key eq 'prerequisites_policy' ) { if ( $value eq 'follow' ) { $value = CPANPLUS::Internals::Constants::PREREQ_INSTALL(); } elsif ( $value eq 'ask' ) { $value = CPANPLUS::Internals::Constants::PREREQ_ASK(); } elsif ( $value eq 'ignore' ) { $value = CPANPLUS::Internals::Constants::PREREQ_IGNORE(); } else { die "*** Cannot convert option $key = '$value' to CPANPLUS version.\n"; } push @config, 'prereqs', $value; } elsif ( $key eq 'force' ) { push @config, $key, $value; } elsif ( $key eq 'notest' ) { push @config, 'skiptest', $value; } else { die "*** Cannot convert option $key to CPANPLUS version.\n"; } } return @config; } sub _install_cpan { my @modules = @{ +shift }; my @config = @{ +shift }; my $installed = 0; my %args; _load_cpan(); require Config; if (CPAN->VERSION < 1.80) { # no "sudo" support, probe for writableness return unless _can_write( MM->catfile( $CPAN::Config->{cpan_home}, 'sources' ) ) and _can_write( $Config::Config{sitelib} ); } # if we're root, set UNINST=1 to avoid trouble unless user asked for it. my $makeflags = $CPAN::Config->{make_install_arg} || ''; $CPAN::Config->{make_install_arg} = join( ' ', split( ' ', $makeflags ), 'UNINST=1' ) if ( $makeflags !~ /\bUNINST\b/ and eval qq{ $> eq '0' } ); # don't show start-up info $CPAN::Config->{inhibit_startup_message} = 1; # set additional options while ( my ( $opt, $arg ) = splice( @config, 0, 2 ) ) { ( $args{$opt} = $arg, next ) if $opt =~ /^(?:force|notest)$/; # pseudo-option $CPAN::Config->{$opt} = $arg; } if ($args{notest} && (not CPAN::Shell->can('notest'))) { die "Your version of CPAN is too old to support the 'notest' pragma"; } local $CPAN::Config->{prerequisites_policy} = 'follow'; while ( my ( $pkg, $ver ) = splice( @modules, 0, 2 ) ) { MY::preinstall( $pkg, $ver ) or next if defined &MY::preinstall; print "*** Installing $pkg...\n"; my $obj = CPAN::Shell->expand( Module => $pkg ); my $success = 0; if ( $obj and _version_cmp( $obj->cpan_version, $ver ) >= 0 ) { my $pathname = $pkg; $pathname =~ s/::/\\W/; foreach my $inc ( grep { m/$pathname.pm/i } keys(%INC) ) { delete $INC{$inc}; } my $rv = do { if ($args{force}) { CPAN::Shell->force( install => $pkg ) } elsif ($args{notest}) { CPAN::Shell->notest( install => $pkg ) } else { CPAN::Shell->install($pkg) } }; $rv ||= eval { $CPAN::META->instance( 'CPAN::Distribution', $obj->cpan_file, ) ->{install} if $CPAN::META; }; if ( $rv eq 'YES' ) { print "*** $pkg successfully installed.\n"; $success = 1; } else { print "*** $pkg installation failed.\n"; $success = 0; } $installed += $success; } else { print << "."; *** Could not find a version $ver or above for $pkg; skipping. . } MY::postinstall( $pkg, $ver, $success ) if defined &MY::postinstall; } return $installed; } sub _has_cpanplus { return ( $HasCPANPLUS = ( $INC{'CPANPLUS/Config.pm'} or _load('CPANPLUS::Shell::Default') ) ); } # make guesses on whether we're under the CPAN installation directory sub _under_cpan { require Cwd; require File::Spec; my $cwd = File::Spec->canonpath( Cwd::getcwd() ); my $cpan = File::Spec->canonpath( $CPAN::Config->{cpan_home} ); return ( index( $cwd, $cpan ) > -1 ); } sub _update_to { my $class = __PACKAGE__; my $ver = shift; return if _version_cmp( _version_of($class), $ver ) >= 0; # no need to upgrade if ( _prompt( "==> A newer version of $class ($ver) is required. Install?", 'y' ) =~ /^[Nn]/ ) { die "*** Please install $class $ver manually.\n"; } print << "."; *** Trying to fetch it from CPAN... . # install ourselves _load($class) and return $class->import(@_) if $class->install( [], $class, $ver ); print << '.'; exit 1; *** Cannot bootstrap myself. :-( Installation terminated. . } # check if we're connected to some host, using inet_aton sub _connected_to { my $site = shift; return ( ( _load('Socket') and Socket::inet_aton($site) ) or _prompt( qq( *** Your host cannot resolve the domain name '$site', which probably means the Internet connections are unavailable. ==> Should we try to install the required module(s) anyway?), 'n' ) =~ /^[Yy]/ ); } # check if a directory is writable; may create it on demand sub _can_write { my $path = shift; mkdir( $path, 0755 ) unless -e $path; return 1 if -w $path; print << "."; *** You are not allowed to write to the directory '$path'; the installation may fail due to insufficient permissions. . if ( eval '$>' and lc(`sudo -V`) =~ /version/ and _prompt( qq( ==> Should we try to re-execute the autoinstall process with 'sudo'?), ((-t STDIN) ? 'y' : 'n') ) =~ /^[Yy]/ ) { # try to bootstrap ourselves from sudo print << "."; *** Trying to re-execute the autoinstall process with 'sudo'... . my $missing = join( ',', @Missing ); my $config = join( ',', UNIVERSAL::isa( $Config, 'HASH' ) ? %{$Config} : @{$Config} ) if $Config; return unless system( 'sudo', $^X, $0, "--config=$config", "--installdeps=$missing" ); print << "."; *** The 'sudo' command exited with error! Resuming... . } return _prompt( qq( ==> Should we try to install the required module(s) anyway?), 'n' ) =~ /^[Yy]/; } # load a module and return the version it reports sub _load { my $mod = pop; # method/function doesn't matter my $file = $mod; $file =~ s|::|/|g; $file .= '.pm'; local $@; return eval { require $file; $mod->VERSION } || ( $@ ? undef: 0 ); } # report version without loading a module sub _version_of { my $mod = pop; # method/function doesn't matter my $file = $mod; $file =~ s|::|/|g; $file .= '.pm'; foreach my $dir ( @INC ) { next if ref $dir; my $path = File::Spec->catfile($dir, $file); next unless -e $path; require ExtUtils::MM_Unix; return ExtUtils::MM_Unix->parse_version($path); } return undef; } # Load CPAN.pm and it's configuration sub _load_cpan { return if $CPAN::VERSION and $CPAN::Config and not @_; require CPAN; # CPAN-1.82+ adds CPAN::Config::AUTOLOAD to redirect to # CPAN::HandleConfig->load. CPAN reports that the redirection # is deprecated in a warning printed at the user. # CPAN-1.81 expects CPAN::HandleConfig->load, does not have # $CPAN::HandleConfig::VERSION but cannot handle # CPAN::Config->load # Which "versions expect CPAN::Config->load? if ( $CPAN::HandleConfig::VERSION || CPAN::HandleConfig->can('load') ) { # Newer versions of CPAN have a HandleConfig module CPAN::HandleConfig->load; } else { # Older versions had the load method in Config directly CPAN::Config->load; } } # compare two versions, either use Sort::Versions or plain comparison # return values same as <=> sub _version_cmp { my ( $cur, $min ) = @_; return -1 unless defined $cur; # if 0 keep comparing return 1 unless $min; $cur =~ s/\s+$//; # check for version numbers that are not in decimal format if ( ref($cur) or ref($min) or $cur =~ /v|\..*\./ or $min =~ /v|\..*\./ ) { if ( ( $version::VERSION or defined( _load('version') )) and version->can('new') ) { # use version.pm if it is installed. return version->new($cur) <=> version->new($min); } elsif ( $Sort::Versions::VERSION or defined( _load('Sort::Versions') ) ) { # use Sort::Versions as the sorting algorithm for a.b.c versions return Sort::Versions::versioncmp( $cur, $min ); } warn "Cannot reliably compare non-decimal formatted versions.\n" . "Please install version.pm or Sort::Versions.\n"; } # plain comparison local $^W = 0; # shuts off 'not numeric' bugs return $cur <=> $min; } # nothing; this usage is deprecated. sub main::PREREQ_PM { return {}; } sub _make_args { my %args = @_; $args{PREREQ_PM} = { %{ $args{PREREQ_PM} || {} }, @Existing, @Missing } if $UnderCPAN or $TestOnly; if ( $args{EXE_FILES} and -e 'MANIFEST' ) { require ExtUtils::Manifest; my $manifest = ExtUtils::Manifest::maniread('MANIFEST'); $args{EXE_FILES} = [ grep { exists $manifest->{$_} } @{ $args{EXE_FILES} } ]; } $args{test}{TESTS} ||= 't/*.t'; $args{test}{TESTS} = join( ' ', grep { !exists( $DisabledTests{$_} ) } map { glob($_) } split( /\s+/, $args{test}{TESTS} ) ); my $missing = join( ',', @Missing ); my $config = join( ',', UNIVERSAL::isa( $Config, 'HASH' ) ? %{$Config} : @{$Config} ) if $Config; $PostambleActions = ( ($missing and not $UnderCPAN) ? "\$(PERL) $0 --config=$config --installdeps=$missing" : "\$(NOECHO) \$(NOOP)" ); my $deps_list = join( ',', @Missing, @Existing ); $PostambleActionsUpgradeDeps = "\$(PERL) $0 --config=$config --upgradedeps=$deps_list"; my $config_notest = join( ',', (UNIVERSAL::isa( $Config, 'HASH' ) ? %{$Config} : @{$Config}), 'notest', 1 ) if $Config; $PostambleActionsNoTest = ( ($missing and not $UnderCPAN) ? "\$(PERL) $0 --config=$config_notest --installdeps=$missing" : "\$(NOECHO) \$(NOOP)" ); $PostambleActionsUpgradeDepsNoTest = "\$(PERL) $0 --config=$config_notest --upgradedeps=$deps_list"; $PostambleActionsListDeps = '@$(PERL) -le "print for @ARGV" ' . join(' ', map $Missing[$_], grep $_ % 2 == 0, 0..$#Missing); my @all = (@Missing, @Existing); $PostambleActionsListAllDeps = '@$(PERL) -le "print for @ARGV" ' . join(' ', map $all[$_], grep $_ % 2 == 0, 0..$#all); return %args; } # a wrapper to ExtUtils::MakeMaker::WriteMakefile sub Write { require Carp; Carp::croak "WriteMakefile: Need even number of args" if @_ % 2; if ($CheckOnly) { print << "."; *** Makefile not written in check-only mode. . return; } my %args = _make_args(@_); no strict 'refs'; $PostambleUsed = 0; local *MY::postamble = \&postamble unless defined &MY::postamble; ExtUtils::MakeMaker::WriteMakefile(%args); print << "." unless $PostambleUsed; *** WARNING: Makefile written with customized MY::postamble() without including contents from Module::AutoInstall::postamble() -- auto installation features disabled. Please contact the author. . return 1; } sub postamble { $PostambleUsed = 1; my $fragment; $fragment .= <<"AUTO_INSTALL" if !$InstallDepsTarget; config :: installdeps \t\$(NOECHO) \$(NOOP) AUTO_INSTALL $fragment .= <<"END_MAKE"; checkdeps :: \t\$(PERL) $0 --checkdeps installdeps :: \t$PostambleActions installdeps_notest :: \t$PostambleActionsNoTest upgradedeps :: \t$PostambleActionsUpgradeDeps upgradedeps_notest :: \t$PostambleActionsUpgradeDepsNoTest listdeps :: \t$PostambleActionsListDeps listalldeps :: \t$PostambleActionsListAllDeps END_MAKE return $fragment; } 1; __END__ #line 1197 Webinject-1.94/LICENSE0000644000175000017500000004312711422525572013112 0ustar svensven GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. Webinject-1.94/t/0000755000175000017500000000000013135607424012341 5ustar svensvenWebinject-1.94/t/data/0000755000175000017500000000000013135607424013252 5ustar svensvenWebinject-1.94/t/data/03-parse_response3.xml0000644000175000017500000000047012050430614017316 0ustar svensven Webinject-1.94/t/data/01-response_codes.xml0000644000175000017500000000065411422327014017221 0ustar svensven Webinject-1.94/t/data/04-repeated_tests.xml0000644000175000017500000000065411422341661017230 0ustar svensven Webinject-1.94/t/data/09-fileupload.xml0000644000175000017500000000127211540713442016344 0ustar svensven Webinject-1.94/t/data/06-thresholds.xml0000644000175000017500000000143011423366543016376 0ustar svensven Webinject-1.94/t/data/03-parse_response.xml0000644000175000017500000000121712050431251017231 0ustar svensven Webinject-1.94/t/data/fileup1.txt0000644000175000017500000000001411532507701015347 0ustar svensventest upload Webinject-1.94/t/data/30-nagios_perf_data.xml0000644000175000017500000000153111571172231017474 0ustar svensven Webinject-1.94/t/data/20-full_test.xml0000644000175000017500000000275111424517611016216 0ustar svensven teststring1 Webinject-1.94/t/data/03-parse_response2.xml0000644000175000017500000000043012050431141017305 0ustar svensven Webinject-1.94/t/data/05-report_types.xml0000644000175000017500000000065411423366543016764 0ustar svensven Webinject-1.94/t/data/fileup2.png0000644000175000017500000000334111303011142015304 0ustar svensvenPNG  IHDR;0sRGB pHYs B(xtIME 봉sIDATHǕ[P[p$!ՖDe0_:;N>4S:MzNmfSM& I35(616cd 7.}&y8Cz$>H?ONt[-m7)&rcIhVכ VK[h#8?uh~'7QŢ\ߚx. $ r|>?Ph ji^(k-H*E JHMW[y5t: R 򒖖R!R)).AI,bxc^11-x^Kz}*YeɘWsØW3tшshc[ʤ  L8"-]>"r,*ij2m梨iII&gyGSXD" \,O֭jGy\=۶3cՓVqƙӇH%m~\ߪ({# RHs<}O/;Z] H$vW?@EyӇTU/OSXh@&" ) hO184J{% -7Wr YF"j(>@Vҙs4@mxh970;㕳oFq8oSXhX掘1ř׹wo>={>xmR#ǎ/.?힣a7eF.\P(^ہZ*K8211͉FjkK7:tR@z_4?VR)`s鳫lLZ-U*'Z{w7@"pAҒת;:(`f;~Rb#;@&t݆944?VG:O.SPSmZT Z sg =`qWDGA1륬,/#ykU_B@"019_L@(bi)9UBMOӢJT2&33oʰuק/ͨA:.(*.3.ttE tgH$7o!x} 8aȵU$GSzsh[a Îaa̫Qy azq-\p&sn,@r b}^ ~o鰯gV-2p P,Y$U;()z1wŕ!FpgWo/X-m3xx!9ՓX_͘%-֗Wnv3`J;wqwV_ZVK[FqDf) H/.ig~ϕ!r;6Nω[iM"a>\ںfd{C\/g9",_IENDB`Webinject-1.94/t/data/02-string_verification.xml0000644000175000017500000000125111515355552020264 0ustar svensven Webinject-1.94/t/data/external.pm0000644000175000017500000000010411423366543015427 0ustar svensven#!/usr/bin/env perl use Data::Dumper; print Dumper($external); 1; Webinject-1.94/t/data/08-custom_var.xml0000644000175000017500000000070511654533444016411 0ustar svensven Webinject-1.94/t/perlcriticrc0000644000175000017500000001711511422312777014757 0ustar svensven############################################################################## # This Perl::Critic configuration file sets the Policy severity levels # according to Damian Conway's own personal recommendations. Feel free to # use this as your own, or make modifications. ############################################################################## [Perl::Critic::Policy::ValuesAndExpressions::ProhibitAccessOfPrivateData] severity = 3 [Perl::Critic::Policy::BuiltinFunctions::ProhibitLvalueSubstr] severity = 3 [Perl::Critic::Policy::BuiltinFunctions::ProhibitReverseSortBlock] severity = 1 [Perl::Critic::Policy::BuiltinFunctions::ProhibitSleepViaSelect] severity = 5 [Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval] severity = 5 [Perl::Critic::Policy::BuiltinFunctions::ProhibitStringySplit] severity = 2 [Perl::Critic::Policy::BuiltinFunctions::ProhibitUniversalCan] severity = 4 [Perl::Critic::Policy::BuiltinFunctions::ProhibitUniversalIsa] severity = 4 [Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidGrep] severity = 3 [Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidMap] severity = 3 [Perl::Critic::Policy::BuiltinFunctions::RequireBlockGrep] severity = 4 [Perl::Critic::Policy::BuiltinFunctions::RequireBlockMap] severity = 4 [Perl::Critic::Policy::BuiltinFunctions::RequireGlobFunction] severity = 5 [Perl::Critic::Policy::BuiltinFunctions::RequireSimpleSortBlock] severity = 3 [Perl::Critic::Policy::ClassHierarchies::ProhibitAutoloading] severity = 3 [Perl::Critic::Policy::ClassHierarchies::ProhibitExplicitISA] severity = 4 [Perl::Critic::Policy::ClassHierarchies::ProhibitOneArgBless] severity = 5 [Perl::Critic::Policy::CodeLayout::ProhibitHardTabs] severity = 3 [Perl::Critic::Policy::CodeLayout::ProhibitParensWithBuiltins] severity = 1 [Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists] severity = 2 [Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines] severity = 4 [Perl::Critic::Policy::CodeLayout::RequireTidyCode] severity = 1 [Perl::Critic::Policy::CodeLayout::RequireTrailingCommas] severity = 3 [Perl::Critic::Policy::ControlStructures::ProhibitCStyleForLoops] severity = 3 [Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse] severity = 3 [Perl::Critic::Policy::ControlStructures::ProhibitDeepNests] severity = 3 [Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions] severity = 5 [Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls] severity = 4 [Perl::Critic::Policy::ControlStructures::ProhibitUnlessBlocks] severity = 4 [Perl::Critic::Policy::ControlStructures::ProhibitUnreachableCode] severity = 4 [Perl::Critic::Policy::ControlStructures::ProhibitUntilBlocks] severity = 4 [Perl::Critic::Policy::Documentation::RequirePodAtEnd] severity = 2 [Perl::Critic::Policy::Documentation::RequirePodSections] severity = 2 [Perl::Critic::Policy::ErrorHandling::RequireCarping] severity = 4 [Perl::Critic::Policy::InputOutput::ProhibitBacktickOperators] severity = 3 [Perl::Critic::Policy::InputOutput::ProhibitBarewordFileHandles] severity = 5 [Perl::Critic::Policy::InputOutput::ProhibitInteractiveTest] severity = 4 [Perl::Critic::Policy::InputOutput::ProhibitOneArgSelect] severity = 4 [Perl::Critic::Policy::InputOutput::ProhibitReadlineInForLoop] severity = 5 [Perl::Critic::Policy::InputOutput::ProhibitTwoArgOpen] severity = 4 [Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint] severity = 3 [Perl::Critic::Policy::Miscellanea::ProhibitFormats] severity = 3 [Perl::Critic::Policy::Miscellanea::ProhibitTies] severity = 4 [-Perl::Critic::Policy::Miscellanea::RequireRcsKeywords] [Perl::Critic::Policy::Modules::ProhibitAutomaticExportation] severity = 4 [Perl::Critic::Policy::Modules::ProhibitEvilModules] severity = 5 [Perl::Critic::Policy::Modules::ProhibitMultiplePackages] severity = 4 [Perl::Critic::Policy::Modules::RequireBarewordIncludes] severity = 5 [Perl::Critic::Policy::Modules::RequireEndWithOne] severity = 4 [Perl::Critic::Policy::Modules::RequireExplicitPackage] severity = 4 [Perl::Critic::Policy::Modules::RequireFilenameMatchesPackage] severity = 5 [Perl::Critic::Policy::Modules::RequireVersionVar] severity = 4 [Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames] severity = 3 [Perl::Critic::Policy::NamingConventions::ProhibitMixedCaseSubs] severity = 1 [Perl::Critic::Policy::NamingConventions::ProhibitMixedCaseVars] severity = 1 [Perl::Critic::Policy::References::ProhibitDoubleSigils] severity = 4 [Perl::Critic::Policy::RegularExpressions::ProhibitCaptureWithoutTest] severity = 4 [Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting] severity = 5 [Perl::Critic::Policy::RegularExpressions::RequireLineBoundaryMatching] severity = 5 [Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils] severity = 2 [Perl::Critic::Policy::Subroutines::ProhibitBuiltinHomonyms] severity = 4 [Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity] severity = 3 [Perl::Critic::Policy::Subroutines::ProhibitExplicitReturnUndef] severity = 5 [Perl::Critic::Policy::Subroutines::ProhibitSubroutinePrototypes] severity = 4 [Perl::Critic::Policy::Subroutines::ProtectPrivateSubs] severity = 3 [Perl::Critic::Policy::Subroutines::RequireFinalReturn] severity = 5 [Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict] severity = 5 [Perl::Critic::Policy::TestingAndDebugging::ProhibitNoWarnings] severity = 4 [Perl::Critic::Policy::TestingAndDebugging::ProhibitProlongedStrictureOverride] severity = 4 [Perl::Critic::Policy::TestingAndDebugging::RequireTestLabels] severity = 3 [Perl::Critic::Policy::TestingAndDebugging::RequireUseStrict] severity = 5 [Perl::Critic::Policy::TestingAndDebugging::RequireUseWarnings] severity = 4 [Perl::Critic::Policy::ValuesAndExpressions::ProhibitConstantPragma] severity = 4 [Perl::Critic::Policy::ValuesAndExpressions::ProhibitEmptyQuotes] severity = 2 [Perl::Critic::Policy::ValuesAndExpressions::ProhibitEscapedCharacters] severity = 2 [Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals] severity = 1 [Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros] severity = 5 [Perl::Critic::Policy::ValuesAndExpressions::ProhibitMismatchedOperators] severity = 2 [Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators] severity = 4 [Perl::Critic::Policy::ValuesAndExpressions::ProhibitNoisyQuotes] severity = 2 [Perl::Critic::Policy::ValuesAndExpressions::ProhibitVersionStrings] severity = 3 [Perl::Critic::Policy::ValuesAndExpressions::RequireInterpolationOfMetachars] severity = 1 [Perl::Critic::Policy::ValuesAndExpressions::RequireNumberSeparators] severity = 2 [Perl::Critic::Policy::ValuesAndExpressions::RequireQuotedHeredocTerminator] severity = 4 [Perl::Critic::Policy::ValuesAndExpressions::RequireUpperCaseHeredocTerminator] severity = 4 [Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations] severity = 5 [Perl::Critic::Policy::Variables::ProhibitLocalVars] severity = 2 [Perl::Critic::Policy::Variables::ProhibitMatchVars] severity = 4 [Perl::Critic::Policy::Variables::ProhibitPackageVars] severity = 3 [Perl::Critic::Policy::Variables::ProhibitPunctuationVars] severity = 2 [Perl::Critic::Policy::Variables::ProtectPrivateVars] severity = 3 [Perl::Critic::Policy::Variables::RequireInitializationForLocalVars] severity = 5 [Perl::Critic::Policy::Variables::RequireLexicalLoopIterators] severity = 5 [Perl::Critic::Policy::Variables::RequireNegativeIndices] severity = 4Webinject-1.94/t/03-Report_Type_Nagios.t0000644000175000017500000000433411571174607016532 0ustar svensven#!/usr/bin/env perl ################################################## use strict; use Test::More; use Data::Dumper; use FindBin qw($Bin); use lib 't'; if($ENV{TEST_AUTHOR}) { eval "use HTTP::Server::Simple::CGI"; if($@) { plan skip_all => 'HTTP::Server::Simple::CGI required'; } else{ plan tests => 6; } } else{ plan skip_all => 'Author test. Set $ENV{TEST_AUTHOR} to a true value to run.'; } use_ok('Webinject'); my $webinject = Webinject->new(); isa_ok($webinject, "Webinject", 'Object is a Webinject'); require TestWebServer; TestWebServer->start_webserver(); ################################################## # start our test cases test_case_01(); test_case_02(); test_case_03(); test_case_04(); ################################################## # SUBs ################################################## ################################################## # Test File 01 sub test_case_01 { @ARGV = ('-r', 'nagios', $Bin."/data/01-response_codes.xml"); my $webinject = Webinject->new(); $webinject->{'config'}->{'baseurl'} = 'http://localhost:58080'; my $rc = $webinject->engine(); is($rc, 2, '01-response_codes.xml - return code'); } ################################################## # Test File 02 sub test_case_02 { @ARGV = ('-r', 'nagios', $Bin."/data/02-string_verification.xml"); my $webinject = Webinject->new(); $webinject->{'config'}->{'baseurl'} = 'http://localhost:58080'; my $rc = $webinject->engine(); is($rc, 0, '02-string_verification - return code'); } ################################################## # Test File 03 sub test_case_03 { @ARGV = ('-r', 'nagios', $Bin."/data/03-parse_response.xml"); my $webinject = Webinject->new(); $webinject->{'config'}->{'baseurl'} = 'http://localhost:58080'; my $rc = $webinject->engine(); is($rc, 0, '03-parse_response.xml - return code'); } ################################################## # Test File 04 sub test_case_04 { @ARGV = ('-r', 'nagios', $Bin."/data/04-repeated_tests.xml"); my $webinject = Webinject->new(); $webinject->{'config'}->{'baseurl'} = 'http://localhost:58080'; my $rc = $webinject->engine(); is($rc, 2, '04-repeated_tests.xml - return code'); } Webinject-1.94/t/98-Pod-Coverage.t0000644000175000017500000000073611422312777015246 0ustar svensven#!/usr/bin/env perl # # $Id$ # use strict; use warnings; use File::Spec; use Test::More; use English qw(-no_match_vars); if ( not $ENV{TEST_AUTHOR} ) { my $msg = 'Author test. Set $ENV{TEST_AUTHOR} to a true value to run.'; plan( skip_all => $msg ); } eval { require Test::Pod::Coverage; }; if ( $EVAL_ERROR ) { my $msg = 'Test::Pod::Coverage required to criticise pod'; plan( skip_all => $msg ); } eval "use Test::Pod::Coverage 1.00"; all_pod_coverage_ok(); Webinject-1.94/t/01-Webinject.t0000644000175000017500000000123711422312777014662 0ustar svensven#!/usr/bin/env perl ################################################## use strict; use Test::More tests => 4; use Data::Dumper; use_ok('Webinject'); my $webinject = Webinject->new(); isa_ok($webinject, "Webinject", 'Object is a Webinject'); ################################################## # test some internal functions my $teststring = '<äöüß>'; my $verify = '%3C%C3%A4%C3%B6%C3%BC%C3%9F%3E'; is($webinject->_url_escape($teststring), $verify, '_url_escape() in scalar context'); my @test = $webinject->_url_escape(qw'< ä ö ü ß >'); my @verify = qw'%3C %C3%A4 %C3%B6 %C3%BC %C3%9F %3E'; is_deeply(\@test, \@verify, '_url_escape() in list context');Webinject-1.94/t/30-Nagios_Perf_Data.t0000644000175000017500000000362312214553664016102 0ustar svensven#!/usr/bin/env perl ################################################## use strict; use Test::More; use Data::Dumper; use FindBin qw($Bin); use lib 't'; if($ENV{TEST_AUTHOR}) { eval "use HTTP::Server::Simple::CGI"; if($@) { plan skip_all => 'HTTP::Server::Simple::CGI required'; } else{ plan tests => 6; } } else{ plan skip_all => 'Author test. Set $ENV{TEST_AUTHOR} to a true value to run.'; } use_ok('Webinject'); my $webinject = Webinject->new(); isa_ok($webinject, "Webinject", 'Object is a Webinject'); require TestWebServer; TestWebServer->start_webserver(); ################################################## # start our test cases test_case_01(); test_case_02(); ################################################## # SUBs ################################################## ################################################## # Test File 01 sub test_case_01 { @ARGV = ('-r', 'nagios', $Bin."/data/30-nagios_perf_data.xml"); my $webinject = Webinject->new(); $webinject->{'config'}->{'baseurl'} = 'http://localhost:58080'; my $rc = $webinject->engine(); is($rc, 2, '30-nagios_perf_data.xml - return code'); like($webinject->{'result'}->{'perfdata'}, '/time=([\d\.]+)s;0;0;0;0 case1=([\d\.]+)s;0;0;0;0 case2=([\d\.]+)s;0;0;0;0 testlabel=([\d\.]+)s;0;0;0;0 case4=([\d\.]+)s;0;0;0;0/', 'performance data'); } ################################################## # Test File 02 sub test_case_02 { @ARGV = ('-r', 'nagios', '-s', 'break_on_errors=1', $Bin."/data/30-nagios_perf_data.xml"); my $webinject = Webinject->new(); $webinject->{'config'}->{'baseurl'} = 'http://localhost:58080'; my $rc = $webinject->engine(); is($rc, 2, '30-nagios_perf_data.xml - return code'); like($webinject->{'result'}->{'perfdata'}, '/time=([\d\.]+)s;0;0;0;0 case1=([\d\.]+)s;0;0;0;0 case2=0s;0;0;0;0 case3=0s;0;0;0;0 case4=0s;0;0;0;0/', 'performance data'); } Webinject-1.94/t/97-Pod.t0000644000175000017500000000036611422312777013513 0ustar svensvenuse strict; use warnings; use Test::More; eval "use Test::Pod 1.14"; plan skip_all => 'Test::Pod 1.14 required' if $@; plan skip_all => 'Author test. Set $ENV{TEST_AUTHOR} to a true value to run.' unless $ENV{TEST_AUTHOR}; all_pod_files_ok(); Webinject-1.94/t/20-Full_Test_Case.t0000644000175000017500000000743511654537317015621 0ustar svensven#!/usr/bin/env perl ################################################## use strict; use Test::More; use Data::Dumper; use FindBin qw($Bin); use lib 't'; if($ENV{TEST_AUTHOR}) { eval "use HTTP::Server::Simple::CGI"; if($@) { plan skip_all => 'HTTP::Server::Simple::CGI required'; } else{ plan tests => 5; } } else{ plan skip_all => 'Author test. Set $ENV{TEST_AUTHOR} to a true value to run.'; } use_ok('Webinject'); my $webinject = Webinject->new(); isa_ok($webinject, "Webinject", 'Object is a Webinject'); require TestWebServer; TestWebServer->start_webserver(); ################################################## # start our test cases test_case_config(); ################################################## # SUBs ################################################## sub test_case_config { @ARGV = ($Bin."/data/20-full_test.xml"); my $expected = { 'addheader' => 'Blah: Blurbs', 'description1' => 'description', 'description2' => 'description2', 'errormessage' => 'in case of errors display this', 'id' => '1', 'logrequest' => 'yes', 'logresponse' => 'yes', 'method' => 'post', 'parseresponse' => 'Authorization:|\\n', 'parseresponse1' => 'HTTP|\\n', 'parseresponse2' => 'HTTP|\\n', 'parseresponse3' => 'HTTP|\\n', 'parseresponse4' => 'HTTP|\\n', 'parseresponse5' => 'HTTP|\\n', 'postbody' => 'a=1;b=2;c=3;c=4;test=postbodytestmessage;test2=teststring1', 'posttype' => 'application/x-www-form-urlencoded', 'sleep' => '1', 'url' => 'http://localhost:58080/post', 'verifynegative' => 'this should be not visible', 'verifynegative1' => 'this should be not visible', 'verifynegative2' => 'this should be not visible', 'verifynegative3' => 'this should be not visible', 'verifynegativenext' => 'this test is also not available', 'verifypositivenext' => 'bad path:', 'verifypositive' => 'postbodytestmessage', 'verifypositive2' => 'teststring1', 'verifypositive3' => 'Client\-Response\-Num:\ 1', 'verifyresponsecode' => 200, 'passedcount' => 8, 'failedcount' => 0, 'iswarning' => 1, 'iscritical' => 0, }; my $webinject = Webinject->new(); $webinject->{'config'}->{'baseurl'} = 'http://localhost:58080'; my $rc = $webinject->engine(); is($rc, 1, '07-config_options.xml - return code') or diag(Dumper($webinject)); my $firstcase = $webinject->{'result'}->{'files'}->[0]->{'cases'}->[0]; delete $firstcase->{'messages'}; delete $firstcase->{'latency'}; delete $firstcase->{'response'}; delete $firstcase->{'request'}; is_deeply($firstcase, $expected, '20-full_test.xml - first expected case'); my $expected2 = { 'description1' => 'description', 'failedcount' => 0, 'id' => '2', 'method' => 'get', 'passedcount' => 3, 'url' => 'http://localhost:58080/badpath', 'verifyresponsecode' => 400, 'iswarning' => 0, 'iscritical' => 0, }; my $secondcase = $webinject->{'result'}->{'files'}->[0]->{'cases'}->[1]; delete $secondcase->{'messages'}; delete $secondcase->{'latency'}; delete $secondcase->{'response'}; delete $secondcase->{'request'}; is_deeply($secondcase, $expected2, '20-full_test.xml - second expected case'); } Webinject-1.94/t/99-Perl-Critic.t0000644000175000017500000000103611422312777015103 0ustar svensven#!/usr/bin/env perl # # $Id$ # use strict; use warnings; use File::Spec; use Test::More; use English qw(-no_match_vars); if ( not $ENV{TEST_AUTHOR} ) { my $msg = 'Author test. Set $ENV{TEST_AUTHOR} to a true value to run.'; plan( skip_all => $msg ); } eval { require Test::Perl::Critic; }; if ( $EVAL_ERROR ) { my $msg = 'Test::Perl::Critic required to criticise code'; plan( skip_all => $msg ); } my $rcfile = File::Spec->catfile( 't', 'perlcriticrc' ); Test::Perl::Critic->import( -profile => $rcfile ); all_critic_ok(); Webinject-1.94/t/04-Timeouts.t0000644000175000017500000000735712071376716014601 0ustar svensven#!/usr/bin/env perl ################################################## use strict; use Test::More; use Data::Dumper; use FindBin qw($Bin); use lib 't'; if($ENV{TEST_AUTHOR}) { eval "use HTTP::Server::Simple::CGI"; if($@) { plan skip_all => 'HTTP::Server::Simple::CGI required'; } else{ plan tests => 14; } } else{ plan skip_all => 'Author test. Set $ENV{TEST_AUTHOR} to a true value to run.'; } use_ok('Webinject'); my $webinject = Webinject->new(); isa_ok($webinject, "Webinject", 'Object is a Webinject'); require TestWebServer; TestWebServer->start_webserver(); ################################################## # start our test cases test_case_01(); test_case_02(); test_case_03(); ################################################## # SUBs ################################################## ################################################## # Test 01 sub test_case_01 { my $webinject = Webinject->new(); my $case = { 'url' => 'http://localhost:58080/sleep/2', }; my $expected = { 'id' => 1, 'passedcount' => 1, 'failedcount' => 0, 'url' => 'http://localhost:58080/sleep/2', 'iswarning' => 0, 'iscritical' => 0, }; my $result = $webinject->_run_test_case($case); is($result->{'latency'} > 2, 1, '01 - timeouts - latency'); delete $result->{'messages'}; delete $result->{'latency'}; delete $result->{'response'}; delete $result->{'request'}; is_deeply($result, $expected, '01 - timeouts - result') or BAIL_OUT("expected: \n".Dumper($expected)."\nresult: \n".Dumper($result)); is($webinject->{'result'}->{'iscritical'}, 0, '01 - timeouts - iscritical'); is($webinject->{'result'}->{'iswarning'}, 0, '01 - timeouts - iswarning'); } ################################################## # Test 02 sub test_case_02 { my $webinject = Webinject->new(); my $case = { 'url' => 'http://localhost:58080/sleep/2', 'warning' => 1, }; my $expected = { 'id' => 1, 'passedcount' => 1, 'failedcount' => 1, 'url' => 'http://localhost:58080/sleep/2', 'warning' => 1, 'iswarning' => 1, 'iscritical' => 0, }; my $result = $webinject->_run_test_case($case); is($result->{'latency'} > 2, 1, '02 - timeouts - latency'); delete $result->{'messages'}; delete $result->{'latency'}; delete $result->{'response'}; delete $result->{'request'}; is_deeply($result, $expected, '02 - timeouts - result') or BAIL_OUT("expected: \n".Dumper($expected)."\nresult: \n".Dumper($result)); is($webinject->{'result'}->{'iscritical'}, 0, '02 - timeouts - iscritical'); is($webinject->{'result'}->{'iswarning'}, 1, '02 - timeouts - iswarning'); } ################################################## # Test 03 sub test_case_03 { my $webinject = Webinject->new('timeout' => 1); my $case = { 'url' => 'http://localhost:58080/sleep/5', }; my $expected = { 'id' => 1, 'passedcount' => 0, 'failedcount' => 1, 'url' => 'http://localhost:58080/sleep/5', 'iswarning' => 0, 'iscritical' => 1, }; my $result = $webinject->_run_test_case($case); is($result->{'latency'} > 1, 1, '03 - timeouts - latency'); delete $result->{'messages'}; delete $result->{'latency'}; delete $result->{'response'}; delete $result->{'request'}; is_deeply($result, $expected, 'timeouts - result') or diag("expected: \n".Dumper($expected)."\nresult: \n".Dumper($result)); is($webinject->{'result'}->{'iscritical'}, 1, '03 - timeouts - iscritical'); is($webinject->{'result'}->{'iswarning'}, 0, '03 - timeouts - iswarning'); } Webinject-1.94/t/02-Test_Cases.t0000644000175000017500000001752512050431317015003 0ustar svensven#!/usr/bin/env perl ################################################## use strict; use Test::More; use Data::Dumper; use FindBin qw($Bin); use lib 't'; if($ENV{TEST_AUTHOR}) { eval "use HTTP::Server::Simple::CGI"; if($@) { plan skip_all => 'HTTP::Server::Simple::CGI required'; } else{ plan tests => 50; } } else{ plan skip_all => 'Author test. Set $ENV{TEST_AUTHOR} to a true value to run.'; } use_ok('Webinject'); my $webinject = Webinject->new(); isa_ok($webinject, "Webinject", 'Object is a Webinject'); require TestWebServer; TestWebServer->start_webserver(); ################################################## # start our test cases test_case_01(); test_case_02(); test_case_03_1(); test_case_03_2(); test_case_03_3(); test_case_04(); test_case_05(); test_case_06(); test_case_07(); test_case_08(); test_case_09(); ################################################## # SUBs ################################################## ################################################## # Test File 01 sub test_case_01 { @ARGV = ($Bin."/data/01-response_codes.xml"); my $webinject = Webinject->new(); $webinject->{'config'}->{'baseurl'} = 'http://localhost:58080'; my $rc = $webinject->engine(); is($webinject->{'result'}->{'totalpassedcount'}, 1, '01-response_codes.xml - passed count'); is($webinject->{'result'}->{'totalfailedcount'}, 1, '01-response_codes.xml - fail count'); is($rc, 1, '01-response_codes.xml - return code'); } ################################################## # Test File 02 sub test_case_02 { @ARGV = ($Bin."/data/02-string_verification.xml"); my $webinject = Webinject->new(); $webinject->{'config'}->{'baseurl'} = 'http://localhost:58080'; my $rc = $webinject->engine(); is($webinject->{'result'}->{'totalpassedcount'}, 9, '02-string_verification.xml - passed count'); is($webinject->{'result'}->{'totalfailedcount'}, 0, '02-string_verification.xml - fail count'); is($rc, 0, '02-string_verification - return code'); } ################################################## # Test File 03 - 1 sub test_case_03_1 { @ARGV = ($Bin."/data/03-parse_response.xml"); my $webinject = Webinject->new(); $webinject->{'config'}->{'baseurl'} = 'http://localhost:58080'; my $rc = $webinject->engine(); is($webinject->{'result'}->{'totalpassedcount'}, 3, '03-parse_response.xml - passed count'); is($webinject->{'result'}->{'totalfailedcount'}, 0, '03-parse_response.xml - fail count'); is($rc, 0, '03-parse_response.xml - return code'); } ################################################## # Test File 03 - 2 sub test_case_03_2 { @ARGV = ($Bin."/data/03-parse_response2.xml"); my $webinject = Webinject->new(); $webinject->{'config'}->{'baseurl'} = 'http://localhost:58080'; my $rc = $webinject->engine(); is($webinject->{'result'}->{'totalpassedcount'}, 1, '03-parse_response2.xml - passed count'); is($webinject->{'result'}->{'totalfailedcount'}, 0, '03-parse_response2.xml - fail count'); is($rc, 1, '03-parse_response.xml - return code'); } ################################################## # Test File 03 - 3 sub test_case_03_3 { @ARGV = ($Bin."/data/03-parse_response3.xml"); my $webinject = Webinject->new(); $webinject->{'config'}->{'baseurl'} = 'http://localhost:58080'; my $rc = $webinject->engine(); is($webinject->{'result'}->{'totalpassedcount'}, 1, '03-parse_response2.xml - passed count'); is($webinject->{'result'}->{'totalfailedcount'}, 0, '03-parse_response2.xml - fail count'); is($rc, 0, '03-parse_response.xml - return code'); } ################################################## # Test File 04 sub test_case_04 { @ARGV = ($Bin."/data/04-repeated_tests.xml"); my $webinject = Webinject->new(); $webinject->{'config'}->{'baseurl'} = 'http://localhost:58080'; my $rc = $webinject->engine(); is($webinject->{'result'}->{'totalpassedcount'}, 5, '04-repeated_tests.xml - passed count'); is($webinject->{'result'}->{'totalfailedcount'}, 5, '04-repeated_tests.xml - fail count'); is($rc, 1, '04-repeated_tests.xml - return code'); } ################################################## # Reporttypes sub test_case_05 { for my $type (qw/standard nagios mrtg external:t\/data\/external.pm/) { @ARGV = ( "-r", $type, $Bin."/data/05-report_types.xml" ); my $webinject = Webinject->new(); $webinject->{'config'}->{'baseurl'} = 'http://localhost:58080'; my $rc = $webinject->engine(); is($webinject->{'result'}->{'totalpassedcount'}, 1, 'reporttype: '.$type.' 05-report_types.xml - passed count'); is($webinject->{'result'}->{'totalfailedcount'}, 1, 'reporttype: '.$type.' 05-report_types.xml - fail count'); is($rc, 1, '05-report_types.xml - return code') if $type ne 'nagios'; is($rc, 2, '05-report_types.xml - return code') if $type eq 'nagios'; } } ################################################## # Test File 06 sub test_case_06 { @ARGV = ('-r', 'nagios', $Bin."/data/06-thresholds.xml", "testcases/case[1]"); my $webinject = Webinject->new(); $webinject->{'config'}->{'baseurl'} = 'http://localhost:58080'; my $rc = $webinject->engine(); is($webinject->{'result'}->{'totalpassedcount'}, 3, '06-thresholds.xml [1] - passed count'); is($webinject->{'result'}->{'totalfailedcount'}, 0, '06-thresholds.xml [1] - fail count'); is($rc, 0, '06-thresholds.xml [1] - return code'); @ARGV = ('-r', 'nagios', $Bin."/data/06-thresholds.xml", "testcases/case[2]"); $webinject = Webinject->new(); $webinject->{'config'}->{'baseurl'} = 'http://localhost:58080'; $rc = $webinject->engine(); is($webinject->{'result'}->{'totalpassedcount'}, 2, '06-thresholds.xml [2] - passed count'); is($webinject->{'result'}->{'totalfailedcount'}, 1, '06-thresholds.xml [2] - fail count'); is($rc, 1, '06-thresholds.xml [2] - return code'); @ARGV = ('-r', 'nagios', $Bin."/data/06-thresholds.xml", "testcases/case[3]"); $webinject = Webinject->new(); $webinject->{'config'}->{'baseurl'} = 'http://localhost:58080'; $rc = $webinject->engine(); is($webinject->{'result'}->{'totalpassedcount'}, 1, '06-thresholds.xml [3] - passed count'); is($webinject->{'result'}->{'totalfailedcount'}, 2, '06-thresholds.xml [3] - fail count'); is($rc, 2, '06-thresholds.xml [3] - return code'); } ################################################## # Test Case 7 / File 01 sub test_case_07 { @ARGV = ("-s", "baseurl=http://localhost:58080", $Bin."/data/01-response_codes.xml"); my $webinject = Webinject->new(); my $rc = $webinject->engine(); is($webinject->{'result'}->{'totalpassedcount'}, 1, '01-response_codes.xml - passed count'); is($webinject->{'result'}->{'totalfailedcount'}, 1, '01-response_codes.xml - fail count'); is($rc, 1, '01-response_codes.xml - return code'); } ################################################## # Test Case 8 / File 08 sub test_case_08 { @ARGV = ("-s", "baseurl=http://localhost:58080", "-s", "code1=200", "-s", "code_500=500", "-s", "method=get", $Bin."/data/08-custom_var.xml"); my $webinject = Webinject->new(); my $rc = $webinject->engine(); is($webinject->{'result'}->{'totalpassedcount'}, 1, '08-custom_var.xml - passed count'); is($webinject->{'result'}->{'totalfailedcount'}, 1, '08-custom_var.xml - fail count'); is($rc, 1, '01-response_codes.xml - return code'); } ################################################## # Test Case 9 / File 09 sub test_case_09 { @ARGV = ($Bin."/data/09-fileupload.xml"); my $webinject = Webinject->new(); my $rc = $webinject->engine(); is($webinject->{'result'}->{'totalpassedcount'}, 4, '09-fileupload.xml - passed count'); is($webinject->{'result'}->{'totalfailedcount'}, 0, '09-fileupload.xml - fail count'); is($rc, 0, '09-fileupload.xml - return code'); } Webinject-1.94/t/TestWebServer.pm0000644000175000017500000000417611424542053015446 0ustar svensven#!/usr/bin/env perl ################################################## package TestWebServer; use strict; use Test::More; use Data::Dumper; use FindBin qw($Bin); use base qw(HTTP::Server::Simple::CGI); my $webserverpid; # Fire up test webserver sub handle_request { my $self = shift; my $cgi = shift; my $path = $cgi->path_info(); my $method = $cgi->request_method(); # GET Requests if($method eq 'GET' and $path =~ m|/code/(\d+)|) { print "HTTP/1.0 $1\r\n\r\nrequest for response code $1\r\n"; } elsif($method eq 'GET' and $path =~ m|/teststring|) { print "HTTP/1.0 200 OK\r\n\r\nthis is just a teststring"; } elsif($method eq 'GET' and $path =~ m|/sleep/(\d+)|) { sleep($1); print "HTTP/1.0 200 OK\r\n\r\nsleeped $1 seconds"; } elsif($method eq 'GET' and $path =~ m|/auth|) { if(defined $ENV{'HTTP_AUTHORIZATION'} and $ENV{'HTTP_AUTHORIZATION'} eq 'Basic dXNlcjpwYXNz') { print "HTTP/1.0 200 OK\r\n\r\nauth successfull"; } elsif(defined $ENV{'HTTP_AUTHORIZATION'}) { print "HTTP/1.0 403 Forbidden\r\n\r\nyou are not authorized"; } else { print "HTTP/1.0 401 Authorization required\r\n"; print "WWW-Authenticate: Basic realm=\"my_realm\"\r\n"; print "\r\n"; print "got auth request with the following cgi object:\n"; } print Dumper($cgi); print Dumper(\%ENV); } # POST Requests elsif($method eq 'POST' and $path =~ m|/post|) { print "HTTP/1.0 200 OK\r\n\r\n"; print "got post request with the following cgi object:\n"; print Dumper($cgi); } else { print "HTTP/1.0 400 Bad Request\r\n\r\n"; print "bad path: '$path'\r\n"; } } sub start_webserver { # start the server on port 508080 $webserverpid = TestWebServer->new(58080)->background(); $SIG{INT} = sub{ kill 2, $webserverpid if defined $webserverpid; undef $webserverpid; exit 1; }; } ################################################## # stop our test webserver END { kill 2, $webserverpid if defined $webserverpid; } 1;Webinject-1.94/t/06-Proxy.t0000644000175000017500000000456112242366542014101 0ustar svensven#!/usr/bin/env perl ################################################## use strict; use Test::More; use Data::Dumper; use FindBin qw($Bin); use lib 't'; if(!$ENV{TEST_AUTHOR}) { plan skip_all => 'Author test. Set $ENV{TEST_AUTHOR} to a true value to run.'; } elsif(!$ENV{'TEST_PROXY'}) { plan skip_all => 'Author test. Set $ENV{TEST_PROXY} to run this test.'; } else{ plan tests => 8; } use_ok('Webinject'); my $webinject = Webinject->new(); isa_ok($webinject, "Webinject", 'Object is a Webinject'); # clean env for my $key (qw/http_proxy https_proxy HTTP_PROXY HTTPS_PROXY/) { delete($ENV{$key}); } ################################################## # start our test cases $webinject = Webinject->new("proxy" => $ENV{'TEST_PROXY'}); test_case($webinject, 'http://www.google.de'); test_case($webinject, 'https://encrypted.google.com/'); ################################################## # SUBs ################################################## ################################################## # Test Case sub test_case { my $webinject = shift; my $url = shift; my $case = { 'logresponse' => 'yes', 'logrequest' => 'yes', 'verifyresponsecode' => 200, 'verifypositive' => 'Google', 'url' => $url, 'warning' => 30, 'critical' => 30, }; my $expected = { 'id' => 1, 'passedcount' => 4, 'failedcount' => 0, 'url' => $case->{'url'}, 'logresponse' => 'yes', 'logrequest' => 'yes', 'verifyresponsecode' => 200, 'verifypositive' => $case->{'verifypositive'}, 'iscritical' => 0, 'iswarning' => 0, 'warning' => 30, 'critical' => 30, }; my $result = $webinject->_run_test_case($case); delete $result->{'messages'}; delete $result->{'latency'}; delete $result->{'response'}; delete $result->{'request'}; is_deeply($result, $expected, '01 - proxy '.$url.' - result') or BAIL_OUT("expected: \n".Dumper($expected)."\nresult: \n".Dumper($result)); is($webinject->{'result'}->{'iscritical'}, 0, '06 - proxy '.$url.' - iscritical'); is($webinject->{'result'}->{'iswarning'}, 0, '06 - proxy '.$url.' - iswarning'); } Webinject-1.94/t/05-Basic_Auth.t0000644000175000017500000000406311606051250014744 0ustar svensven#!/usr/bin/env perl ################################################## use strict; use Test::More; use Data::Dumper; use FindBin qw($Bin); use lib 't'; if($ENV{TEST_AUTHOR}) { eval "use HTTP::Server::Simple::CGI"; if($@) { plan skip_all => 'HTTP::Server::Simple::CGI required'; } else{ plan tests => 6; } } else{ plan skip_all => 'Author test. Set $ENV{TEST_AUTHOR} to a true value to run.'; } use_ok('Webinject'); my $webinject = Webinject->new(); isa_ok($webinject, "Webinject", 'Object is a Webinject'); require TestWebServer; TestWebServer->start_webserver(); ################################################## # start our test cases test_case_01(); ################################################## # SUBs ################################################## ################################################## # Test 01 sub test_case_01 { my $webinject = Webinject->new("httpauth" => 'localhost:58080:my_realm:user:pass'); my $case = { 'logresponse' => 'yes', 'logrequest' => 'yes', 'verifyresponsecode' => 200, 'url' => 'http://localhost:58080/auth', }; my $expected = { 'id' => 1, 'passedcount' => 1, 'failedcount' => 0, 'url' => $case->{'url'}, 'logresponse' => 'yes', 'logrequest' => 'yes', 'verifyresponsecode' => 200, 'iswarning' => 0, 'iscritical' => 0, }; my $result = $webinject->_run_test_case($case); is($result->{'latency'} < 1, 1, '01 - auth - latency'); delete $result->{'messages'}; delete $result->{'latency'}; delete $result->{'response'}; delete $result->{'request'}; is_deeply($result, $expected, '01 - auth - result') or BAIL_OUT("expected: \n".Dumper($expected)."\nresult: \n".Dumper($result)); is($webinject->{'result'}->{'iscritical'}, 0, '01 - auth - iscritical'); is($webinject->{'result'}->{'iswarning'}, 0, '01 - auth - iswarning'); } Webinject-1.94/Makefile.PL0000644000175000017500000000330313027034233014037 0ustar svensvenuse inc::Module::Install; name 'Webinject'; all_from 'lib/Webinject.pm'; license 'gpl2'; resources( 'homepage', => 'http://www.webinject.org', 'bugtracker' => 'http://github.com/sni/Webinject/issues', 'repository', => 'http://github.com/sni/Webinject', ); requires 'LWP' => 0; requires 'XML::Simple' => 0; requires 'HTTP::Request::Common' => 0; requires 'HTTP::Cookies' => 0; requires 'Time::HiRes' => 0; requires 'Getopt::Long' => 0; requires 'Crypt::SSLeay' => 0; requires 'XML::Parser' => 0; requires 'Error' => 0; requires 'File::Temp' => 0; requires 'URI' => 0; install_script 'bin/webinject.pl'; if (!-f "README" || -M "lib/Webinject" < -M "README") { readme_from('lib/Webinject.pm'); } auto_install; WriteAll; open(my $fh, '>>', 'Makefile') or die('cannot write to Makefile'); print $fh < ./check_webinject echo '# nagios: +epn' >> ./check_webinject echo '' >> ./check_webinject cat ./lib/Webinject.pm ./bin/webinject.pl | grep -v '^use Webinject' | grep -v '__END__' | sed -e 's/my \$\$webinject = Webinject->new\(\);/my \$\$webinject = Webinject->new(reporttype => \\"nagios\\", timeout => 30, break_on_errors => 1);/' >> ./check_webinject chmod 755 ./check_webinject webinject.pl :: echo '#!/usr/bin/perl' > ./webinject.pl echo '# nagios: +epn' >> ./webinject.pl echo '' >> ./webinject.pl cat ./lib/Webinject.pm ./bin/webinject.pl | grep -v '^use Webinject' | grep -v '__END__' >> ./webinject.pl chmod 755 ./webinject.pl EOT close($fh); Webinject-1.94/META.yml0000644000175000017500000000155513135607421013352 0ustar svensven--- abstract: 'Perl Module for testing web services' author: - 'Corey Goldberg, ' build_requires: ExtUtils::MakeMaker: 6.59 configure_requires: ExtUtils::MakeMaker: 6.59 distribution_type: module dynamic_config: 1 generated_by: 'Module::Install version 1.14' license: gpl2 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Webinject no_index: directory: - examples - inc - t requires: Crypt::SSLeay: 0 Error: 0 File::Temp: 0 Getopt::Long: 0 HTTP::Cookies: 0 HTTP::Request::Common: 0 LWP: 0 Time::HiRes: 0 URI: 0 XML::Parser: 0 XML::Simple: 0 perl: 5.6.0 resources: bugtracker: http://github.com/sni/Webinject/issues homepage: http://www.webinject.org license: http://opensource.org/licenses/gpl-2.0.php repository: http://github.com/sni/Webinject version: '1.94' Webinject-1.94/bin/0000755000175000017500000000000013135607424012646 5ustar svensvenWebinject-1.94/bin/webinject.pl0000755000175000017500000000144311424035252015153 0ustar svensven#!/usr/bin/env perl # Copyright 2010 Sven Nierlein (nierlein@cpan.org) # Copyright 2004-2006 Corey Goldberg (corey@goldb.org) # # This file is part of WebInject. # # WebInject is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # WebInject is distributed in the hope that it will be useful, # but without any warranty; without even the implied warranty of # merchantability or fitness for a particular purpose. See the # GNU General Public License for more details. use warnings; use strict; use Webinject; my $webinject = Webinject->new(); my $rc = $webinject->engine(); exit $rc; Webinject-1.94/examples/0000755000175000017500000000000013135607424013714 5ustar svensvenWebinject-1.94/examples/config.xml0000644000175000017500000000012111422525466015677 0ustar svensventestcases.xml onfail Webinject-1.94/examples/testcases.xml0000644000175000017500000000271611424042051016426 0ustar svensven Webinject-1.94/lib/0000755000175000017500000000000013135607424012644 5ustar svensvenWebinject-1.94/lib/Webinject.pm0000755000175000017500000024054113135607256015130 0ustar svensvenpackage Webinject; # Copyright 2010-2012 Sven Nierlein (nierlein@cpan.org) # Copyright 2004-2006 Corey Goldberg (corey@goldb.org) # # This file is part of WebInject. # # WebInject is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # WebInject is distributed in the hope that it will be useful, # but without any warranty; without even the implied warranty of # merchantability or fitness for a particular purpose. See the # GNU General Public License for more details. use 5.006; use strict; use warnings; use Carp; use LWP; use HTML::Entities; use URI; use HTTP::Request::Common; use HTTP::Cookies; use XML::Simple; use Time::HiRes 'time', 'sleep'; use Getopt::Long; use Crypt::SSLeay; # for SSL/HTTPS (you may comment this out if you don't need it) use XML::Parser; # for web services verification (you may comment this out if aren't doing XML verifications for web services) use Error qw(:try); # for web services verification (you may comment this out if aren't doing XML verifications for web services) use Data::Dumper; # dump hashes for debugging use File::Temp qw/ tempfile /; # create temp files use File::Basename; use File::Spec; our $VERSION = '1.94'; =head1 NAME Webinject - Perl Module for testing web services =head1 SYNOPSIS use Webinject; my $webinject = Webinject->new(); $webinject->engine(); =head1 DESCRIPTION WebInject is a free tool for automated testing of web applications and web services. It can be used to test individual system components that have HTTP interfaces (JSP, ASP, CGI, PHP, AJAX, Servlets, HTML Forms, XML/SOAP Web Services, REST, etc), and can be used as a test harness to create a suite of [HTTP level] automated functional, acceptance, and regression tests. A test harness allows you to run many test cases and collect/report your results. WebInject offers real-time results display and may also be used for monitoring system response times. =head1 CONSTRUCTOR =head2 new ( [ARGS] ) Creates an C object. =over 4 =item reporttype possible values are 'standard', 'nagios', 'nagios2', 'mrtg' or 'external:' =item nooutput suppress all output to STDOUT, create only logfiles =item break_on_errors stop after the first testcase fails, otherwise Webinject would go on and execute all tests regardless of the previous case. =item timeout Default timeout is 180seconds. Timeout starts again for every testcase. =item useragent Set the useragent used in HTTP requests. Default is 'Webinject'. =item max_redirect Set maximum number of HTTP redirects. Default is 0. =item proxy Sets a proxy which is then used for http and https requests. ex.: http://proxy.company.net:3128 with authentication: ex.: http://user:password@proxy.company.net:3128 =item output_dir Output directory where all logfiles will go to. Defaults to current directory. =item globalhttplog Can be 'yes' or 'onfail'. Will log the http request and response to a http.log file. =item httpauth Provides credentials for webserver authentications. The format is: ['servername', 'portnumber', 'realm-name', 'username', 'password'] =item baseurl the value can be used as {BASEURL} in the test cases =item baseurl1 the value can be used as {BASEURL1} in the test cases =item baseurl2 the value can be used as {BASEURL2} in the test cases =item standaloneplot can be "on" or "off". Default is off. Create gnuplot graphs when enabled. =item graphtype Defaults to 'lines' =item gnuplot Defines the path to your gnuplot binary. =item postbodybasedir Path to a directory from which all relative test case postbody directives are based. When test cases include a "postbody" directive with a "file=>..." value, and that value is a relative location, Webinject will prepend this directory path. If not supplied, the directory containing the current test case file is prepended to any relative "file=>" values. =back =cut sub new { my $class = shift; my (%options) = @_; $| = 1; # don't buffer output to STDOUT my $self = {}; bless $self, $class; # set default config options $self->_set_defaults(); for my $opt_key ( keys %options ) { if( exists $self->{'config'}->{$opt_key} ) { if($opt_key eq 'httpauth') { $self->_set_http_auth($options{$opt_key}); } else { $self->{'config'}->{$opt_key} = $options{$opt_key}; } } else { $self->_usage("ERROR: unknown option: ".$opt_key); } } # get command line options $self->_getoptions(); return $self; } ######################################## =head1 METHODS =head2 engine start the engine of webinject =cut sub engine { #wrap the whole engine in a subroutine so it can be integrated with the gui my $self = shift; if($self->{'gui'}) { $self->_gui_initial(); } else { # delete files leftover from previous run (do this here so they are whacked each run) $self->_whackoldfiles(); } $self->_processcasefile(); # write opening tags for STDOUT. $self->_writeinitialstdout(); # create the gnuplot config file $self->_plotcfg(); # timer for entire test run my $startruntimer = time(); # process test case files named in config for my $currentcasefile ( @{ $self->{'casefilelist'} } ) { #print "\n$currentcasefile\n\n"; my $configpostbodybasedir = $self->{'config'}->{'postbodybasedir'}; my $currentcasefilebasedir = (defined($configpostbodybasedir) ? File::Spec->canonpath($configpostbodybasedir) : undef) // File::Spec->rel2abs(dirname($currentcasefile)) // File::Spec->rel2abs(dirname($0)) // File::Spec->rel2abs(dirname(__FILE__)); my $resultfile = { 'name' => $currentcasefile, 'cases' => [], }; if($self->{'gui'}) { $self->_gui_processing_msg($currentcasefile); } my $tempfile = $self->_convtestcases($currentcasefile); my $xmltestcases; eval { $xmltestcases = XMLin( $tempfile, varattr => 'varname', variables => $self->{'config'} ); # slurp test case file to parse (and specify variables tag) }; if($@) { my $error = $@; $error =~ s/^\s*//mx; $self->_usage("ERROR: reading xml test case ".$currentcasefile." failed: ".$error); } unless( defined $xmltestcases->{case} ) { $self->_usage("ERROR: no test cases defined!"); } # fix case if there is only one case if( defined $xmltestcases->{'case'}->{'id'} ) { my $tmpcase = $xmltestcases->{'case'}; $xmltestcases->{'case'} = { $tmpcase->{'id'} => $tmpcase }; } #delete the temp file as soon as we are done reading it if ( -e $tempfile ) { unlink $tempfile; } my $repeat = 1; if(defined $xmltestcases->{repeat} and $xmltestcases->{repeat} > 0) { $repeat = $xmltestcases->{repeat}; } my $useragent = $self->_get_useragent($xmltestcases->{case}); for my $run_nr (1 .. $repeat) { # process cases in sorted order for my $testnum ( sort { $a <=> $b } keys %{ $xmltestcases->{case} } ) { # if an XPath Node is defined, only process the single Node if( $self->{'xnode'} ) { $testnum = $self->{'xnode'}; } # create testcase my $case = { 'id' => $testnum, 'testdir' => $currentcasefilebasedir }; # populate variables with values from testcase file, do substitutions, and revert converted values back for my $key (keys %{$xmltestcases->{'case'}->{$testnum}}) { $case->{$key} = $xmltestcases->{'case'}->{$testnum}->{$key}; } my $label = ''; if(defined $case->{'label'}) { $label = $case->{'label'}." - "; } $self->_out(qq|Test: $label$currentcasefile - $testnum \n|); $case = $self->_run_test_case($case, $useragent); push @{$resultfile->{'cases'}}, $case; # break from sub if user presses stop button in gui if( $self->{'switches'}->{'stop'} eq 'yes' ) { my $rc = $self->_finaltasks(); $self->{'switches'}->{'stop'} = 'no'; return $rc; # break from sub } # break here if the last result was an error if($self->{'config'}->{'break_on_errors'} and $self->{'result'}->{'iscritical'}) { last; } # if an XPath Node is defined, only process the single Node if( $self->{'xnode'} ) { last; } } } push @{$self->{'result'}->{'files'}}, $resultfile; } my $endruntimer = time(); $self->{'result'}->{'totalruntime'} = ( int( 1000 * ( $endruntimer - $startruntimer ) ) / 1000 ); #elapsed time rounded to thousandths # do return/cleanup tasks return $self->_finaltasks(); } ################################################################################ # runs a single test case sub _run_test_case { my($self,$case,$useragent) =@_; confess("no testcase!") unless defined $case; # set some defaults $case->{'id'} = 1 unless defined $case->{'id'}; $case->{'passedcount'} = 0; $case->{'failedcount'} = 0; $case->{'iswarning'} = 0; $case->{'iscritical'} = 0; $case->{'messages'} = []; $useragent = $self->_get_useragent({1 => $case}) unless defined $useragent; # don't do this if monitor is disabled in gui if($self->{'gui'} and $self->{'monitorenabledchkbx'} ne 'monitor_off') { my $curgraphtype = $self->{'config'}->{'graphtype'}; } # used to replace parsed {timestamp} with real timestamp value my $timestamp = time(); for my $key (keys %{$case}) { $case->{$key} = $self->_convertbackxml($case->{$key}, $timestamp); next if $key eq 'errormessage'; $case->{$key} = $self->_convertbackxmlresult($case->{$key}); } # replace host with realserverip in url and add http host header to useragent if($self->{'config'}->{'realserverip'}) { my($uri)=URI->new($case->{url}); my($host)=$uri->host(); $useragent->default_header('Host' => $uri->host()); $case->{url}=~s/\Q$host\E/$self->{'config'}->{'realserverip'}/mx; } if( $self->{'gui'} ) { $self->_gui_tc_descript($case); } push @{$case->{'messages'}}, { 'html' => "" }; # HTML: open table column for(qw/description1 description2/) { next unless defined $case->{$_}; $self->_out(qq|Desc: $case->{$_}\n|); push @{$case->{'messages'}}, {'key' => $_, 'value' => $case->{$_}, 'html' => "$case->{$_}
" }; } my $method; if (defined $case->{method}) { $method = uc($case->{method}); } else { $method = "GET"; } push @{$case->{'messages'}}, { 'html' => qq|$method $case->{url}
\n| }; push @{$case->{'messages'}}, { 'html' => "" }; # HTML: next column my($latency,$request,$response); alarm($self->{'config'}->{'timeout'}+1); # timeout should be handled by LWP, but just in case... eval { local $SIG{ALRM} = sub { die("alarm") }; if($case->{method}){ if(lc $case->{method} eq "get") { ($latency,$request,$response) = $self->_httpget($useragent, $case); } elsif(lc $case->{method} eq "delete") { ($latency,$request,$response) = $self->_httpdelete($useragent, $case); } elsif(lc $case->{method} eq "post") { ($latency,$request,$response) = $self->_httppost($useragent, $case); } else { $self->_usage('ERROR: bad HTTP Request Method Type, you must use "get", "delete" or "post"'); } } else { ($latency,$request,$response) = $self->_httpget($useragent, $case); # use "get" if no method is specified } }; alarm(0); if($@) { $case->{'iscritical'} = 1; } else { $case->{'latency'} = $latency; $case->{'request'} = $request->as_string(); $case->{'response'} = $response->as_string(); # verify result from http response $self->_verify($response, $case); if($case->{verifypositivenext}) { $self->{'verifylater'} = $case->{'verifypositivenext'}; $self->_out("Verify On Next Case: '".$case->{verifypositivenext}."' \n"); push @{$case->{'messages'}}, {'key' => 'verifypositivenext', 'value' => $case->{verifypositivenext}, 'html' => "Verify On Next Case: ".$case->{verifypositivenext}."
" }; } if($case->{verifynegativenext}) { $self->{'verifylaterneg'} = $case->{'verifynegativenext'}; $self->_out("Verify Negative On Next Case: '".$case->{verifynegativenext}."' \n"); push @{$case->{'messages'}}, {'key' => 'verifynegativenext', 'value' => $case->{verifynegativenext}, 'html' => "Verify Negative On Next Case: ".$case->{verifynegativenext}."
" }; } # write to http.log file $self->_httplog($request, $response, $case); # send perf data to log file for plotting $self->_plotlog($latency); # call the external plotter to create a graph $self->_plotit(); if( $self->{'gui'} ) { $self->_gui_updatemontab(); # update monitor with the newly rendered plot graph } $self->_parseresponse($response, $case); # grab string from response to send later # make parsed results available in the errormessage for my $key (keys %{$case}) { next unless $key eq 'errormessage'; $case->{$key} = $self->_convertbackxmlresult($case->{$key}); } } push @{$case->{'messages'}}, { 'html' => "\n" }; # HTML: next column # if any verification fails, test case is considered a failure if($case->{'iscritical'}) { # end result will be also critical $self->{'result'}->{'iscritical'} = 1; push @{$case->{'messages'}}, {'key' => 'success', 'value' => 'false' }; if( $self->{'result'}->{'returnmessage'} ) { # Add returnmessage to the output my $prefix = "case #".$case->{'id'}.": "; if(defined $case->{'label'}) { $prefix = $case->{'label'}." (case #".$case->{'id'}."): "; } $self->{'result'}->{'returnmessage'} = $prefix.$self->{'result'}->{'returnmessage'}; my $message = $self->{'result'}->{'returnmessage'}; $message = $message.' - '.$case->{errormessage} if defined $case->{errormessage}; push @{$case->{'messages'}}, { 'key' => 'result-message', 'value' => $message, 'html' => "FAILED : ".$message."" }; $self->_out("TEST CASE FAILED : ".$message."\n"); } # print regular error output elsif ( $case->{errormessage} ) { # Add defined error message to the output push @{$case->{'messages'}}, { 'key' => 'result-message', 'value' => $case->{errormessage}, 'html' => "FAILED : ".$case->{errormessage}."" }; $self->_out(qq|TEST CASE FAILED : $case->{errormessage}\n|); } else { push @{$case->{'messages'}}, { 'key' => 'result-message', 'value' => 'TEST CASE FAILED', 'html' => "FAILED" }; $self->_out(qq|TEST CASE FAILED\n|); } unless( $self->{'result'}->{'returnmessage'} ) { #(used for plugin compatibility) if it's the first error message, set it to variable if( $case->{errormessage} ) { $self->{'result'}->{'returnmessage'} = $case->{errormessage}; } else { $self->{'result'}->{'returnmessage'} = "Test case number ".$case->{'id'}." failed"; if(defined $case->{'label'}) { $self->{'result'}->{'returnmessage'} = "Test case ".$case->{'label'}." (#".$case->{'id'}.") failed"; } } } if( $self->{'gui'} ) { $self->_gui_status_failed(); } } elsif($case->{'iswarning'}) { # end result will be also warning $self->{'result'}->{'iswarning'} = 1; push @{$case->{'messages'}}, {'key' => 'success', 'value' => 'false' }; if( $case->{errormessage} ) { # Add defined error message to the output push @{$case->{'messages'}}, {'key' => 'result-message', 'value' => $case->{errormessage}, 'html' => "WARNED : ".$case->{errormessage}."" }; $self->_out(qq|TEST CASE WARNED : $case->{errormessage}\n|); } # print regular error output else { # we suppress most logging when running in a plugin mode push @{$case->{'messages'}}, {'key' => 'result-message', 'value' => 'TEST CASE WARNED', 'html' => "WARNED" }; $self->_out(qq|TEST CASE WARNED\n|); } unless( $self->{'result'}->{'returnmessage'} ) { #(used for plugin compatibility) if it's the first error message, set it to variable if( $case->{errormessage} ) { $self->{'result'}->{'returnmessage'} = $case->{errormessage}; } else { $self->{'result'}->{'returnmessage'} = "Test case number ".$case->{'id'}." warned"; if(defined $case->{'label'}) { $self->{'result'}->{'returnmessage'} = "Test case ".$case->{'label'}." (#".$case->{'id'}.") warned"; } } } if( $self->{'gui'} ) { $self->_gui_status_failed(); } } else { $self->_out(qq|TEST CASE PASSED\n|); push @{$case->{'messages'}}, {'key' => 'success', 'value' => 'true' }; push @{$case->{'messages'}}, { 'key' => 'result-message', 'value' => 'TEST CASE PASSED', 'html' => "PASSED" }; if( $self->{'gui'} ) { $self->_gui_status_passed(); } } if( $self->{'gui'} ) { $self->_gui_timer_output($latency); } $self->_out(qq|Response Time = $latency sec \n|); $self->_out(qq|------------------------------------------------------- \n|); push @{$case->{'messages'}}, { 'key' => 'responsetime', 'value' => $latency, 'html' => "
".$latency." sec \n" }; $self->{'result'}->{'runcount'}++; $self->{'result'}->{'totalruncount'}++; if( $self->{'gui'} ) { # update the statusbar $self->_gui_statusbar(); } if( $latency > $self->{'result'}->{'maxresponse'} ) { # set max response time $self->{'result'}->{'maxresponse'} = $latency; } if(!defined $self->{'result'}->{'minresponse'} or $latency < $self->{'result'}->{'minresponse'} ) { # set min response time $self->{'result'}->{'minresponse'} = $latency; } # keep total of response times for calculating avg $self->{'result'}->{'totalresponse'} = ( $self->{'result'}->{'totalresponse'} + $latency ); # avg response rounded to thousands $self->{'result'}->{'avgresponse'} = ( int( 1000 * ( $self->{'result'}->{'totalresponse'} / $self->{'result'}->{'totalruncount'} ) ) / 1000 ); if( $self->{'gui'} ) { # update timers and counts in monitor tab $self->_gui_updatemonstats(); } # if a sleep value is set in the test case, sleep that amount if( $case->{sleep} ) { sleep( $case->{sleep} ); } $self->{'result'}->{'totalpassedcount'} += $case->{'passedcount'}; $self->{'result'}->{'totalfailedcount'} += $case->{'failedcount'}; if($case->{'iscritical'} or $case->{'iswarning'}) { $self->{'result'}->{'totalcasesfailedcount'}++; } else { $self->{'result'}->{'totalcasespassedcount'}++; } return $case; } ################################################################################ sub _get_useragent { my($self, $testcases) = @_; # keepalive is required for ntml authentication but breaks # https proxy support, so try determince which one we need my $keepalive = 1; if($testcases and $self->{'config'}->{'proxy'}) { for my $nr (keys %{$testcases}) { if($testcases->{$nr}->{'url'} =~ m/^https/gmx) { $keepalive = 0; } } } my $useragent = LWP::UserAgent->new(keep_alive=>$keepalive); # store cookies in our LWP object my($fh, $cookietempfilename) = tempfile(); unlink ($cookietempfilename); $useragent->cookie_jar(HTTP::Cookies->new( file => $cookietempfilename, autosave => 1, )); push @{$self->{'tmpfiles'}}, $cookietempfilename; # http useragent that will show up in webserver logs unless(defined $self->{'config'}->{'useragent'}) { $useragent->agent('WebInject'); } else { $useragent->agent($self->{'config'}->{'useragent'}); } # add proxy support if it is set in config.xml if( $self->{'config'}->{'proxy'} ) { # try IO::Socket::SSL first eval { require IO::Socket::SSL; IO::Socket::SSL->import(); }; my $proxy = $self->{'config'}->{'proxy'}; $proxy =~ s/^http(s|):\/\///mx; # http just works $useragent->proxy('http', 'http://'.$proxy); # authentication? my $proxyuser = ''; my $proxypass = ''; if($proxy =~ s/^(.*?):(.*?)@(.*)$/$3/gmx) { $proxyuser = $1; $proxypass = $2; } # ssl depends on which class we have if($INC{'IO/Socket/SSL.pm'}) { $ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS} = "IO::Socket::SSL"; if($proxypass) { $proxy = $proxyuser.':'.$proxypass.'@'.$proxy; } my $con_proxy = 'connect://'.$proxy; $useragent->proxy('https', $con_proxy); } else { # ssl proxy only works this way, see http://community.activestate.com/forum-topic/lwp-https-requests-proxy $ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS} = "Net::SSL"; $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0; $ENV{HTTPS_PROXY} = $proxy; $ENV{HTTPS_PROXY_USERNAME} = $proxyuser; $ENV{HTTPS_PROXY_PASSWORD} = $proxypass; # env proxy breaks the ssl proxy above #$useragent->env_proxy(); } } # don't follow redirects unless set by config push @{$useragent->requests_redirectable}, 'POST'; $useragent->max_redirect($self->{'config'}->{'max_redirect'}); # add http basic authentication support # corresponds to: # $useragent->credentials('servername:portnumber', 'realm-name', 'username' => 'password'); if(scalar @{$self->{'config'}->{'httpauth'}}) { # add the credentials to the user agent here. The foreach gives the reference to the tuple ($elem), and we # deref $elem to get the array elements. for my $elem ( @{ $self->{'config'}->{'httpauth'} } ) { #print "adding credential: $elem->[0]:$elem->[1], $elem->[2], $elem->[3] => $elem->[4]\n"; $useragent->credentials( $elem->[0].":".$elem->[1], $elem->[2], $elem->[3] => $elem->[4] ); } } # change response delay timeout in seconds if it is set in config.xml if($self->{'config'}->{'timeout'}) { $useragent->timeout($self->{'config'}->{'timeout'}); # default LWP timeout is 180 secs. } return $useragent; } ################################################################################ # set defaults sub _set_defaults { my $self = shift; $self->{'config'} = { 'currentdatetime' => scalar localtime time, #get current date and time for results report 'standaloneplot' => 'off', 'graphtype' => 'lines', 'httpauth' => [], 'reporttype' => 'standard', 'output_dir' => './', 'nooutput' => undef, 'realserverip' => '', 'baseurl' => '', 'baseurl1' => '', 'baseurl2' => '', 'break_on_errors' => 0, 'max_redirect' => 0, 'globalhttplog' => 'no', 'proxy' => '', 'timeout' => 180, 'tmpfiles' => [], 'postbodybasedir' => undef }; $self->{'exit_codes'} = { 'UNKNOWN' => 3, 'OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, }; $self->{'switches'} = { 'stop' => 'no', 'plotclear' => 'no', }; $self->{'out'} = ''; $self->_reset_result(); return; } ################################################################################ # reset result sub _reset_result { my $self = shift; $self->{'result'} = { 'cases' => [], 'returnmessage' => undef, 'totalcasesfailedcount' => 0, 'totalcasespassedcount' => 0, 'totalfailedcount' => 0, 'totalpassedcount' => 0, 'totalresponse' => 0, 'totalruncount' => 0, 'totalruntime' => 0, 'casecount' => 0, 'avgresponse' => 0, 'iscritical' => 0, 'iswarning' => 0, 'maxresponse' => 0, 'minresponse' => undef, 'runcount' => 0, }; return; } ################################################################################ # write initial text for STDOUT sub _writeinitialstdout { my $self = shift; if($self->{'config'}->{'reporttype'} !~ /^nagios/mx) { $self->_out(qq| Starting WebInject Engine (v$Webinject::VERSION)... |); } $self->_out("-------------------------------------------------------\n"); return; } ################################################################################ # write summary and closing tags for results file sub _write_result_html { my $self = shift; my $file = $self->{'config'}->{'output_dir'}."results.html"; open( my $resultshtml, ">", $file ) or $self->_usage("ERROR: Failed to write ".$file.": ".$!); print $resultshtml qq| WebInject Test Results |; for my $file (@{$self->{'result'}->{'files'}}) { for my $case (@{$file->{'cases'}}) { print $resultshtml qq|\n|; for my $message (@{$case->{'messages'}}) { next unless defined $message->{'html'}; print $resultshtml $message->{'html'} . "\n"; } print $resultshtml "\n"; } } print $resultshtml qq|
Test Description
Request URL
Results Summary
Response Time
$file->{'name'}
$case->{'id'}
Start Time: $self->{'config'}->{'currentdatetime'}
Total Run Time: $self->{'result'}->{'totalruntime'} seconds

Test Cases Run: $self->{'result'}->{'totalruncount'}
Test Cases Passed: $self->{'result'}->{'totalcasespassedcount'}
Test Cases Failed: $self->{'result'}->{'totalcasesfailedcount'}
Verifications Passed: $self->{'result'}->{'totalpassedcount'}
Verifications Failed: $self->{'result'}->{'totalfailedcount'}

Average Response Time: $self->{'result'}->{'avgresponse'} seconds
Max Response Time: $self->{'result'}->{'maxresponse'} seconds
Min Response Time: $self->{'result'}->{'minresponse'} seconds

|; close($resultshtml); return; } ################################################################################ # write summary and closing tags for XML results file sub _write_result_xml { my $self = shift; my $file = $self->{'config'}->{'output_dir'}."results.xml"; open( my $resultsxml, ">", $file ) or $self->_usage("ERROR: Failed to write ".$file.": ".$!); print $resultsxml "\n\n"; for my $file (@{$self->{'result'}->{'files'}}) { print $resultsxml " {'name'}."\">\n\n"; for my $case (@{$file->{'cases'}}) { print $resultsxml " {'id'}."\">\n"; for my $message (@{$case->{'messages'}}) { next unless defined $message->{'key'}; print $resultsxml " <".$message->{'key'}.">".$message->{'value'}."{'key'}.">\n"; } print $resultsxml " \n\n"; } print $resultsxml " \n"; } print $resultsxml qq| $self->{'config'}->{'currentdatetime'} $self->{'result'}->{'totalruntime'} $self->{'result'}->{'totalruncount'} $self->{'result'}->{'totalcasespassedcount'} $self->{'result'}->{'totalcasesfailedcount'} $self->{'result'}->{'totalpassedcount'} $self->{'result'}->{'totalfailedcount'} $self->{'result'}->{'avgresponse'} $self->{'result'}->{'maxresponse'} $self->{'result'}->{'minresponse'} |; close($resultsxml); return; } ################################################################################ # write summary and closing text for STDOUT sub _writefinalstdout { my $self = shift; if($self->{'config'}->{'reporttype'} !~ /^nagios/mx) { $self->_out(qq| Start Time: $self->{'config'}->{'currentdatetime'} Total Run Time: $self->{'result'}->{'totalruntime'} seconds |); } $self->_out(qq| Test Cases Run: $self->{'result'}->{'totalruncount'} Test Cases Passed: $self->{'result'}->{'totalcasespassedcount'} Test Cases Failed: $self->{'result'}->{'totalcasesfailedcount'} Verifications Passed: $self->{'result'}->{'totalpassedcount'} Verifications Failed: $self->{'result'}->{'totalfailedcount'} |); return; } ################################################################################ sub _http_defaults { my $self = shift; my $request = shift; my $useragent = shift; my $case = shift; # Add additional cookies to the cookie jar if specified if($case->{'addcookie'}) { my $cookie_jar = $useragent->cookie_jar(); # add cookies to the cookie jar # can add multiple cookies with a pipe delimiter for my $addcookie (split /\|/mx, $case->{'addcookie'}) { my ($ck_version, $ck_key, $ck_val, $ck_path, $ck_domain, $ck_port, $ck_path_spec, $ck_secure, $ck_maxage, $ck_discard) = split(/,/mx, $addcookie); $cookie_jar->set_cookie( $ck_version, $ck_key, $ck_val, $ck_path, $ck_domain, $ck_port, $ck_path_spec, $ck_secure, $ck_maxage, $ck_discard); } $cookie_jar->save(); $cookie_jar->add_cookie_header($request); } # add an additional HTTP Header if specified if($case->{'addheader'}) { # can add multiple headers with a pipe delimiter for my $addheader (split /\|/mx, $case->{'addheader'}) { $addheader =~ m~(.*):\ (.*)~mx; $request->header( $1 => $2 ); # using HTTP::Headers Class } } # print $self->{'request'}->as_string; print "\n\n"; my $starttimer = time(); my $response = $useragent->request($request); my $endtimer = time(); my $latency = ( int( 1000 * ( $endtimer - $starttimer ) ) / 1000 ); # elapsed time rounded to thousandths # print $response->as_string; print "\n\n"; return($latency,$request,$response); } ################################################################################ # send http request and read response sub _httpget { my $self = shift; my $useragent = shift; my $case = shift; $self->_out("GET Request: ".$case->{url}."\n"); my $request = new HTTP::Request( 'GET', $case->{url} ); return $self->_http_defaults($request, $useragent, $case); } ################################################################################ # send http request and read response sub _httpdelete { my $self = shift; my $useragent = shift; my $case = shift; $self->_out("DELETE Request: ".$case->{url}."\n"); my $request = new HTTP::Request( 'DELETE', $case->{url} ); return $self->_http_defaults($request, $useragent, $case); } ################################################################################ # post request based on specified encoding sub _httppost { my $self = shift; my $useragent = shift; my $case = shift; if($case->{posttype} ) { if( ($case->{posttype} =~ m~application/x\-www\-form\-urlencoded~mx) or ($case->{posttype} =~ m~application/json~mx) ) { return $self->_httppost_form_urlencoded($useragent, $case); } elsif($case->{posttype} =~ m~multipart/form\-data~mx) { return $self->_httppost_form_data($useragent, $case); } elsif( ($case->{posttype} =~ m~text/xml~mx) or ($case->{posttype} =~ m~application/soap\+xml~mx) ) { return $self->_httppost_xml($useragent, $case); } else { $self->_usage('ERROR: Bad Form Encoding Type, I only accept "application/x-www-form-urlencoded", "multipart/form-data", "text/xml", "application/soap+xml"'); } } else { # use "x-www-form-urlencoded" if no encoding is specified $case->{posttype} = 'application/x-www-form-urlencoded'; return $self->_httppost_form_urlencoded($useragent, $case); } return; } ################################################################################ # send application/x-www-form-urlencoded HTTP request and read response sub _httppost_form_urlencoded { my $self = shift; my $useragent = shift; my $case = shift; $self->_out("POST Request: ".$case->{url}."\n"); my $request = new HTTP::Request('POST', $case->{url} ); $request->content_type($case->{posttype}); $request->content($case->{postbody}); return $self->_http_defaults($request,$useragent, $case); } ################################################################################ # send text/xml HTTP request and read response sub _httppost_xml { my $self = shift; my $useragent = shift; my $case = shift; my($latency,$request,$response); # read the xml file specified in the testcase $case->{postbody} =~ m~file=>(.*)~imx; my $postbodyfile = $1; if (!(File::Spec->file_name_is_absolute($postbodyfile)) && length $case->{'testdir'}) { $postbodyfile = File::Spec->rel2abs($postbodyfile, $case->{'testdir'}); } open( my $xmlbody, "<", $postbodyfile ) or $self->_usage("ERROR: Failed to open text/xml file $1 (resolved to $postbodyfile): $!"); # open file handle my @xmlbody = <$xmlbody>; # read the file into an array close($xmlbody); # Get the XML input file to use PARSEDRESULT and substitute the contents my $content = $self->_convertbackxmlresult(join( " ", @xmlbody )); $self->_out("POST Request: ".$case->{url}."\n"); $request = new HTTP::Request( 'POST', $case->{url} ); $request->content_type($case->{posttype}); $request->content( $content ); # load the contents of the file into the request body ($latency,$request,$response) = $self->_http_defaults($request, $useragent, $case); my $xmlparser = new XML::Parser; # see if the XML parses properly try { $xmlparser->parse($response->decoded_content); # print "good xml\n"; push @{$case->{'messages'}}, {'key' => 'verifyxml-success', 'value' => 'true', 'html' => 'Passed XML Parser (content is well-formed)' }; $self->_out("Passed XML Parser (content is well-formed) \n"); $case->{'passedcount'}++; # exit try block return; } catch Error with { # get the exception object my $ex = shift; # print "bad xml\n"; # we suppress most logging when running in a plugin mode if($self->{'config'}->{'reporttype'} eq 'standard') { push @{$case->{'messages'}}, {'key' => 'verifyxml-success', 'value' => 'false', 'html' => "Failed XML parser on response: ".$ex }; } $self->_out("Failed XML parser on response: $ex \n"); $case->{'failedcount'}++; $case->{'iscritical'} = 1; }; # <-- remember the semicolon return($latency,$request,$response); } ################################################################################ # send multipart/form-data HTTP request and read response sub _httppost_form_data { my $self = shift; my $useragent = shift; my $case = shift; my %myContent_; ## no critic eval "\%myContent_ = $case->{postbody}"; ## use critic $self->_out("POST Request: ".$case->{url}."\n"); my $request = POST($case->{url}, Content_Type => $case->{posttype}, Content => \%myContent_); return $self->_http_defaults($request, $useragent, $case); } ################################################################################ # do verification of http response and print status to HTML/XML/STDOUT/UI sub _verify { my $self = shift; my $response = shift; my $case = shift; confess("no response") unless defined $response; confess("no case") unless defined $case; if( $case->{verifyresponsecode} ) { $self->_out(qq|Verify Response Code: "$case->{verifyresponsecode}" \n|); push @{$case->{'messages'}}, {'key' => 'verifyresponsecode', 'value' => $case->{verifyresponsecode} }; # verify returned HTTP response code matches verifyresponsecode set in test case if ( $case->{verifyresponsecode} == $response->code() ) { push @{$case->{'messages'}}, {'key' => 'verifyresponsecode-success', 'value' => 'true', 'html' => 'Passed HTTP Response Code: '.$case->{verifyresponsecode} }; push @{$case->{'messages'}}, {'key' => 'verifyresponsecode-messages', 'value' => 'Passed HTTP Response Code Verification' }; $self->_out(qq|Passed HTTP Response Code Verification \n|); $case->{'passedcount'}++; } else { push @{$case->{'messages'}}, {'key' => 'verifyresponsecode-success', 'value' => 'false', 'html' => 'Failed HTTP Response Code: received '.$response->code().', expecting '.$case->{verifyresponsecode} }; push @{$case->{'messages'}}, {'key' => 'verifyresponsecode-messages', 'value' => 'Failed HTTP Response Code Verification (received '.$response->code().', expecting '.$case->{verifyresponsecode}.')' }; $self->_out(qq|Failed HTTP Response Code Verification (received |.$response->code().qq|, expecting $case->{verifyresponsecode}) \n|); $case->{'failedcount'}++; $case->{'iscritical'} = 1; if($self->{'config'}->{'break_on_errors'}) { $self->{'result'}->{'returnmessage'} = 'Failed HTTP Response Code Verification (received '.$response->code().', expecting '.$case->{verifyresponsecode}.')'; return; } } } else { # verify http response code is in the 100-399 range if($response->as_string() =~ /HTTP\/1.(0|1)\ (1|2|3)/imx ) { # verify existance of string in response push @{$case->{'messages'}}, {'key' => 'verifyresponsecode-success', 'value' => 'true', 'html' => 'Passed HTTP Response Code Verification (not in error range)' }; push @{$case->{'messages'}}, {'key' => 'verifyresponsecode-messages', 'value' => 'Passed HTTP Response Code Verification (not in error range)' }; $self->_out(qq|Passed HTTP Response Code Verification (not in error range) \n|); # succesful response codes: 100-399 $case->{'passedcount'}++; } else { $response->as_string() =~ /(HTTP\/1.)(.*)/mxi; if($1) { #this is true if an HTTP response returned push @{$case->{'messages'}}, {'key' => 'verifyresponsecode-success', 'value' => 'false', 'html' => 'Failed HTTP Response Code Verification ('.$1.$2.')' }; push @{$case->{'messages'}}, {'key' => 'verifyresponsecode-messages', 'value' => 'Failed HTTP Response Code Verification ('.$1.$2.')' }; $self->_out("Failed HTTP Response Code Verification ($1$2) \n"); #($1$2) is HTTP response code $case->{'failedcount'}++; $case->{'iscritical'} = 1; if($self->{'config'}->{'break_on_errors'}) { $self->{'result'}->{'returnmessage'} = 'Failed HTTP Response Code Verification ('.$1.$2.')'; return; } } #no HTTP response returned.. could be error in connection, bad hostname/address, or can not connect to web server else { push @{$case->{'messages'}}, {'key' => 'verifyresponsecode-success', 'value' => 'false', 'html' => 'Failed - No Response' }; push @{$case->{'messages'}}, {'key' => 'verifyresponsecode-messages', 'value' => 'Failed - No Response' }; $self->_out("Failed - No valid HTTP response:\n".$response->as_string()); $case->{'failedcount'}++; $case->{'iscritical'} = 1; if($self->{'config'}->{'break_on_errors'}) { $self->{'result'}->{'returnmessage'} = 'Failed - No valid HTTP response: '.$response->as_string(); return; } } } } push @{$case->{'messages'}}, { 'html' => '
' }; for my $nr ('', 1..1000) { my $key = "verifypositive".$nr; if( $case->{$key} ) { $self->_out("Verify: '".$case->{$key}."' \n"); push @{$case->{'messages'}}, {'key' => $key, 'value' => $case->{$key} }; my $regex = $self->_fix_regex($case->{$key}); # verify existence of string in response if( $response->as_string() =~ m~$regex~simx ) { push @{$case->{'messages'}}, {'key' => $key.'-success', 'value' => 'true', 'html' => "Passed: ".$case->{$key} }; $self->_out("Passed Positive Verification \n"); $case->{'passedcount'}++; } else { push @{$case->{'messages'}}, {'key' => $key.'-success', 'value' => 'false', 'html' => "Failed: ".$case->{$key} }; $self->_out("Failed Positive Verification \n"); $case->{'failedcount'}++; $case->{'iscritical'} = 1; if($self->{'config'}->{'break_on_errors'}) { $self->{'result'}->{'returnmessage'} = 'Failed Positive Verification, can not find a string matching regex: '.$regex; return; } } push @{$case->{'messages'}}, { 'html' => '
' }; } elsif($nr ne '' and $nr > 5) { last; } } for my $nr ('', 1..1000) { my $key = "verifynegative".$nr; if( $case->{$key} ) { $self->_out("Verify Negative: '".$case->{$key}."' \n"); push @{$case->{'messages'}}, {'key' => $key, 'value' => $case->{$key} }; my $regex = $self->_fix_regex($case->{$key}); # verify existence of string in response if( $response->as_string() =~ m~$regex~simx ) { push @{$case->{'messages'}}, {'key' => $key.'-success', 'value' => 'false', 'html' => 'Failed Negative: '.$case->{$key} }; $self->_out("Failed Negative Verification \n"); $case->{'failedcount'}++; $case->{'iscritical'} = 1; if($self->{'config'}->{'break_on_errors'}) { $self->{'result'}->{'returnmessage'} = 'Failed Negative Verification, found regex matched string: '.$regex; return; } } else { push @{$case->{'messages'}}, {'key' => $key.'-success', 'value' => 'true', 'html' => 'Passed Negative: '.$case->{$key} }; $self->_out("Passed Negative Verification \n"); $case->{'passedcount'}++; } push @{$case->{'messages'}}, { 'html' => '
' }; } elsif($nr ne '' and $nr > 5) { last; } } if($self->{'verifylater'}) { my $regex = $self->_fix_regex($self->{'verifylater'}); # verify existence of string in response if($response->as_string() =~ m~$regex~simx ) { push @{$case->{'messages'}}, {'key' => 'verifypositivenext-success', 'value' => 'true', 'html' => 'Passed Positive Verification (verification set in previous test case)' }; $self->_out("Passed Positive Verification (verification set in previous test case) \n"); $case->{'passedcount'}++; } else { push @{$case->{'messages'}}, {'key' => 'verifypositivenext-success', 'value' => 'false', 'html' => 'Failed Positive Verification (verification set in previous test case)' }; $self->_out("Failed Positive Verification (verification set in previous test case) \n"); $case->{'failedcount'}++; $case->{'iscritical'} = 1; if($self->{'config'}->{'break_on_errors'}) { $self->{'result'}->{'returnmessage'} = 'Failed Positive Verification (verification set in previous test case), can not find a string matching regex: '.$regex; return; } } push @{$case->{'messages'}}, { 'html' => '
' }; # set to null after verification delete $self->{'verifylater'}; } if($self->{'verifylaterneg'}) { my $regex = $self->_fix_regex($self->{'verifylaterneg'}); # verify existence of string in response if($response->as_string() =~ m~$regex~simx) { push @{$case->{'messages'}}, {'key' => 'verifynegativenext-success', 'value' => 'false', 'html' => 'Failed Negative Verification (negative verification set in previous test case)' }; $self->_out("Failed Negative Verification (negative verification set in previous test case) \n"); $case->{'failedcount'}++; $case->{'iscritical'} = 1; if($self->{'config'}->{'break_on_errors'}) { $self->{'result'}->{'returnmessage'} = 'Failed Negative Verification (negative verification set in previous test case), found regex matched string: '.$regex; return; } } else { push @{$case->{'messages'}}, {'key' => 'verifynegativenext-success', 'value' => 'true', 'html' => 'Passed Negative Verification (negative verification set in previous test case)' }; $self->_out("Passed Negative Verification (negative verification set in previous test case) \n"); $case->{'passedcount'}++; } push @{$case->{'messages'}}, { 'html' => '
' }; # set to null after verification delete $self->{'verifylaterneg'}; } if($case->{'warning'}) { $self->_out("Verify Warning Threshold: ".$case->{'warning'}."\n"); push @{$case->{'messages'}}, {'key' => "Warning Threshold", 'value' => $case->{''} }; if($case->{'latency'} > $case->{'warning'}) { push @{$case->{'messages'}}, {'key' => 'warning-success', 'value' => 'false', 'html' => "Failed Warning Threshold: ".$case->{'warning'} }; $self->_out("Failed Warning Threshold \n"); $case->{'failedcount'}++; $case->{'iswarning'} = 1; } else { $self->_out("Passed Warning Threshold \n"); push @{$case->{'messages'}}, {'key' => 'warning-success', 'value' => 'true', 'html' => "Passed Warning Threshold: ".$case->{'warning'} }; $case->{'passedcount'}++; } push @{$case->{'messages'}}, { 'html' => '
' }; } if($case->{'critical'}) { $self->_out("Verify Critical Threshold: ".$case->{'critical'}."\n"); push @{$case->{'messages'}}, {'key' => "Critical Threshold", 'value' => $case->{''} }; if($case->{'latency'} > $case->{'critical'}) { push @{$case->{'messages'}}, {'key' => 'critical-success', 'value' => 'false', 'html' => "Failed Critical Threshold: ".$case->{'critical'} }; $self->_out("Failed Critical Threshold \n"); $case->{'failedcount'}++; $case->{'iscritical'} = 1; } else { $self->_out("Passed Critical Threshold \n"); push @{$case->{'messages'}}, {'key' => 'critical-success', 'value' => 'true', 'html' => "Passed Critical Threshold: ".$case->{'critical'} }; $case->{'passedcount'}++; } } return; } ################################################################################ # parse values from responses for use in future request (for session id's, dynamic URL rewriting, etc) sub _parseresponse { my $self = shift; my $response = shift; my $case = shift; my ( $resptoparse, @parseargs ); my ( $leftboundary, $rightboundary, $escape ); for my $type ( qw/parseresponse parseresponse1 parseresponse2 parseresponse3 parseresponse4 parseresponse5/ ) { next unless $case->{$type}; @parseargs = split( /\|/mx, $case->{$type} ); $leftboundary = $parseargs[0]; $rightboundary = $parseargs[1]; $escape = $parseargs[2]; $resptoparse = $response->as_string; ## no critic if ( $resptoparse =~ m~$leftboundary(.*?)$rightboundary~s ) { $self->{'parsedresult'}->{$type} = $1; } ## use critic elsif(!defined $case->{'parsewarning'} or $case->{'parsewarning'}) { push @{$case->{'messages'}}, {'key' => $type.'-success', 'value' => 'false', 'html' => "Failed Parseresult, cannot find $leftboundary(.*?)$rightboundary" }; $self->_out("Failed Parseresult, cannot find $leftboundary(*)$rightboundary\n"); $case->{'iswarning'} = 1; } if ($escape) { if ( $escape eq 'escape' ) { $self->{'parsedresult'}->{$type} = $self->_url_escape( $self->{'parsedresult'}->{$type} ); } if ( $escape eq 'decode' ) { $self->{'parsedresult'}->{$type} = decode_entities( $self->{'parsedresult'}->{$type} ); } } #print "\n\nParsed String: $self->{'parsedresult'}->{$type}\n\n"; } return; } ################################################################################ # read config.xml sub _read_config_xml { my $self = shift; my $config_file = shift; my($config, $comment_mode,@configlines); # process the config file # if -c option was set on command line, use specified config file if(defined $config_file) { open( $config, '<', $config_file ) or $self->_usage("ERROR: Failed to open ".$config_file." file: ".$!); $self->{'config'}->{'exists'} = 1; # flag we are going to use a config file } # if config.xml exists in current working directory, read it elsif( -e "config.xml" ) { open( $config, '<', "config.xml" ) or $self->_usage("ERROR: Failed to open config.xml file: ".$!); $self->{'config'}->{'exists'} = 1; # flag we are going to use a config file } else { # if config.xml exists in same location as binary, read it my $scriptdir = File::Spec->rel2abs(dirname($0)) // File::Spec->rel2abs(dirname(__FILE__)); my $confpath = File::Spec->rel2abs('config.xml', $scriptdir); if ( -e $confpath ) { open( $config, '<', $confpath ) or $self->_usage("ERROR: Failed to open config.xml file: ".$!); $self->{'config'}->{'exists'} = 1; # flag we are going to use a config file } } if( $self->{'config'}->{'exists'} ) { #if we have a config file, use it my @precomment = <$config>; #read the config file into an array #remove any commented blocks from config file foreach (@precomment) { unless (m~.*~mx) { # single line comment # multi-line comments if (//mx) { $comment_mode = 1; } elsif (m~~mx) { $comment_mode = 0; } elsif ( !$comment_mode ) { push( @configlines, $_ ); } } } close($config); } #grab values for constants in config file: foreach (@configlines) { for my $key ( qw/realserverip baseurl baseurl1 baseurl2 gnuplot proxy timeout output_dir globaltimeout globalhttplog standaloneplot max_redirect break_on_errors useragent postbodybasedir/ ) { if (/<$key>/mx) { $_ =~ m~<$key>(.*)~mx; $self->{'config'}->{$key} = $1; #print "\n$_ : $self->{'config'}->{$_} \n\n"; } } if (//mx) { $_ =~ m~(.*)~mx; if ( $1 ne "standard" ) { $self->{'config'}->{'reporttype'} = $1; $self->{'config'}->{'nooutput'} = "set"; } #print "\nreporttype : $self->{'config'}->{'reporttype'} \n\n"; } if (//mx) { $_ =~ m~(.*)~mx; $self->_set_http_auth($1); #print "\nhttpauth : @{$self->{'config'}->{'httpauth'}} \n\n"; } if(//mx) { my $firstparse = $'; #print "$' \n\n"; $firstparse =~ m~~mx; my $filename = $`; #string between tags will be in $filename #print "\n$filename \n\n"; push @{ $self->{'casefilelist'} }, $filename; #add next filename we grab to end of array } } return; } ################################################################################ # parse and set http auth config sub _set_http_auth { my $self = shift; my $confstring = shift; #each time we see an , we set @authentry to be the #array of values, then we use [] to get a reference to that array #and push that reference onto @httpauth. my @authentry = split( /:/mx, $confstring ); if( scalar @authentry != 5 ) { $self->_usage("ERROR: httpauth should have 5 fields delimited by colons, got: ".$confstring); } else { push( @{ $self->{'config'}->{'httpauth'} }, [@authentry] ); } # basic authentication only works with redirects enabled if($self->{'config'}->{'max_redirect'} == 0) { $self->{'config'}->{'max_redirect'}++; } return; } ################################################################################ # get test case files to run (from command line or config file) and evaluate constants sub _processcasefile { # parse config file and grab values it sets my $self = shift; if( ( $#ARGV + 1 ) < 1 ) { #no command line args were passed unless( $self->{'casefilelist'}->[0] ) { if ( -e "testcases.xml" ) { # if no files are specified in config.xml, default to testcases.xml push @{ $self->{'casefilelist'} }, "testcases.xml"; } else { $self->_usage("ERROR: I can't find any test case files to run.\nYou must either use a config file or pass a filename " . "on the command line if you are not using the default testcase file (testcases.xml)."); } } } elsif( ( $#ARGV + 1 ) == 1 ) { # one command line arg was passed # use testcase filename passed on command line (config.xml is only used for other options) push @{ $self->{'casefilelist'} }, $ARGV[0]; # first commandline argument is the test case file, put this on the array for processing } elsif( ( $#ARGV + 1 ) == 2 ) { # two command line args were passed my $xpath = $ARGV[1]; if ( $xpath =~ /\/(.*)\[/mx ) { # if the argument contains a "/" and "[", it is really an XPath $xpath =~ /(.*)\/(.*)\[(.*?)\]/mx; #if it contains XPath info, just grab the file name $self->{'xnode'} = $3; # grab the XPath Node value.. (from inside the "[]") # print "\nXPath Node is: $self->{'xnode'} \n"; } else { $self->_usage("ERROR: Sorry, $xpath is not in the XPath format I was expecting, I'm ignoring it..."); } # use testcase filename passed on command line (config.xml is only used for other options) push @{ $self->{'casefilelist'} }, $ARGV[0]; # first command line argument is the test case file, put this on the array for processing } elsif ( ( $#ARGV + 1 ) > 2 ) { #too many command line args were passed $self->_usage("ERROR: Too many arguments."); } #print "\ntestcase file list: @{$self->{'casefilelist'}}\n\n"; return; } ################################################################################ # here we do some pre-processing of the test case file and write it out to a temp file. # we convert certain chars so xml parser doesn't puke. sub _convtestcases { my $self = shift; my $currentcasefile = shift; my @xmltoconvert; my ( $fh, $tempfilename ) = tempfile(); push @{$self->{'tmpfiles'}}, $tempfilename; my $filename = $currentcasefile; open( my $xmltoconvert, '<', $filename ) or $self->_usage("ERROR: Failed to read test case file: ".$filename.": ".$!); # read the file into an array @xmltoconvert = <$xmltoconvert>; my $ids = {}; for my $line (@xmltoconvert) { # convert escaped chars and certain reserved chars to temporary values that the parser can handle # these are converted back later in processing $line =~ s/&/{AMPERSAND}/gmx; $line =~ s/\\{'result'}->{'casecount'}++; } # verify id is only use once per file if ( $line =~ /^\s*id\s*=\s*\"*(\d+)\"*/mx ) { if(defined $ids->{$1}) { $self->{'result'}->{'iswarning'} = 1; $self->_out("Warning: case id $1 is used more than once!\n"); } $ids->{$1} = 1; } } close($xmltoconvert); # open file handle to temp file open( $xmltoconvert, '>', $tempfilename ) or $self->_usage("ERROR: Failed to write ".$tempfilename.": ".$!); print $xmltoconvert @xmltoconvert; # overwrite file with converted array close($xmltoconvert); return $tempfilename; } ################################################################################ # converts replaced xml with substitutions sub _convertbackxml { my ( $self, $string, $timestamp ) = @_; return unless defined $string; $string =~ s~{AMPERSAND}~&~gmx; $string =~ s~{LESSTHAN}~<~gmx; $string =~ s~{TIMESTAMP}~$timestamp~gmx; $string =~ s~{REALSERVERIP}~$self->{'config'}->{realserverip}~gmx; $string =~ s~{BASEURL}~$self->{'config'}->{baseurl}~gmx; $string =~ s~{BASEURL1}~$self->{'config'}->{baseurl1}~gmx; $string =~ s~{BASEURL2}~$self->{'config'}->{baseurl2}~gmx; return $string; } ################################################################################ # converts replaced xml with parsed result sub _convertbackxmlresult { my ( $self, $string) = @_; return unless defined $string; $string =~ s~\{PARSEDRESULT\}~$self->{'parsedresult'}->{'parseresponse'}~gmx if defined $self->{'parsedresult'}->{'parseresponse'}; for my $x (1..5) { $string =~ s~\{PARSEDRESULT$x\}~$self->{'parsedresult'}->{"parseresponse$x"}~gmx if defined $self->{'parsedresult'}->{"parseresponse$x"}; } return $string; } ################################################################################ # escapes difficult characters with %hexvalue sub _url_escape { my ( $self, @values ) = @_; # LWP handles url encoding already, but use this to escape valid chars that LWP won't convert (like +) my @return; for my $val (@values) { $val =~ s/[^-\w.,!~'()\/\ ]/uc sprintf "%%%02x", ord $&/egmx if defined $val; push @return, $val; } return wantarray ? @return : $return[0]; } ################################################################################ # write requests and responses to http.log file sub _httplog { my $self = shift; my $request = shift; my $response = shift; my $case = shift; my $output = ''; # http request - log setting per test case if($case->{'logrequest'} && $case->{'logrequest'} =~ /yes/mxi ) { $output .= $request->as_string."\n\n"; } # http response - log setting per test case if($case->{'logresponse'} && $case->{'logresponse'} =~ /yes/mxi ) { $output .= $response->as_string."\n\n"; } # global http log setting if($self->{'config'}->{'globalhttplog'} && $self->{'config'}->{'globalhttplog'} =~ /yes/mxi ) { $output .= $request->as_string."\n\n"; $output .= $response->as_string."\n\n"; } # global http log setting - onfail mode if($self->{'config'}->{'globalhttplog'} && $self->{'config'}->{'globalhttplog'} =~ /onfail/mxi && $case->{'iscritical'}) { $output .= $request->as_string."\n\n"; $output .= $response->as_string."\n\n"; } if($output ne '') { my $file = $self->{'config'}->{'output_dir'}."http.log"; open( my $httplogfile, ">>", $file ) or $self->_usage("ERROR: Failed to write ".$file.": ".$!); print $httplogfile $output; print $httplogfile "\n************************* LOG SEPARATOR *************************\n\n\n"; close($httplogfile); } return; } ################################################################################ # write performance results to plot.log in the format gnuplot can use sub _plotlog { my ( $self, $value ) = @_; my ( %months, $date, $time, $mon, $mday, $hours, $min, $sec, $year ); # do this unless: monitor is disabled in gui, or running standalone mode without config setting to turn on plotting if( ( $self->{'gui'} and $self->{'monitorenabledchkbx'} ne 'monitor_off') or (!$self->{'gui'} and $self->{'config'}->{'standaloneplot'} eq 'on') ) { %months = ( "Jan" => 1, "Feb" => 2, "Mar" => 3, "Apr" => 4, "May" => 5, "Jun" => 6, "Jul" => 7, "Aug" => 8, "Sep" => 9, "Oct" => 10, "Nov" => 11, "Dec" => 12 ); $date = scalar localtime; ($mon, $mday, $hours, $min, $sec, $year) = $date =~ /\w+\ (\w+)\ +(\d+)\ (\d\d):(\d\d):(\d\d)\ (\d\d\d\d)/mx; $time = "$months{$mon} $mday $hours $min $sec $year"; my $plotlog; # used to clear the graph when requested if( $self->{'switches'}->{'plotclear'} eq 'yes' ) { # open in clobber mode so log gets truncated my $file = $self->{'config'}->{'output_dir'}."plot.log"; open( $plotlog, '>', $file ) or $self->_usage("ERROR: Failed to write ".$file.": ".$!); $self->{'switches'}->{'plotclear'} = 'no'; # reset the value } else { my $file = $self->{'config'}->{'output_dir'}."plot.log"; open( $plotlog, '>>', $file ) or $self->_usage("ERROR: Failed to write ".$file.": ".$!); #open in append mode } printf $plotlog "%s %2.4f\n", $time, $value; close($plotlog); } return; } ################################################################################ # create gnuplot config file sub _plotcfg { my $self = shift; # do this unless: monitor is disabled in gui, or running standalone mode without config setting to turn on plotting if( ( $self->{'gui'} and $self->{'monitorenabledchkbx'} ne 'monitor_off') or (!$self->{'gui'} and $self->{'config'}->{'standaloneplot'} eq 'on') ) { my $file = $self->{'config'}->{'output_dir'}."plot.plt"; open( my $gnuplotplt, ">", $file ) or _usage("ERROR: Could not open ".$file.": ".$!); print $gnuplotplt qq| set term png set output \"$self->{'config'}->{'output_dir'}plot.png\" set size 1.1,0.5 set pointsize .5 set xdata time set ylabel \"Response Time (seconds)\" set yrange [0:] set bmargin 2 set tmargin 2 set timefmt \"%m %d %H %M %S %Y\" plot \"$self->{'config'}->{'output_dir'}plot.log\" using 1:7 title \"Response Times" w $self->{'config'}->{'graphtype'} |; close($gnuplotplt); } return; } ################################################################################ # do ending tasks sub _finaltasks { my $self = shift; $self->_clean_tmp_files(); if ( $self->{'gui'} ) { $self->_gui_stop(); } # we suppress most logging when running in a plugin mode if($self->{'config'}->{'reporttype'} eq 'standard') { # write summary and closing tags for results file $self->_write_result_html(); #write summary and closing tags for XML results file $self->_write_result_xml(); } # write summary and closing tags for STDOUT $self->_writefinalstdout(); #plugin modes if($self->{'config'}->{'reporttype'} ne 'standard') { # return value is set which corresponds to a monitoring program # Nagios plugin compatibility if($self->{'config'}->{'reporttype'} =~ /^nagios/mx) { # nagios perf data has following format # 'label'=value[UOM];[warn];[crit];[min];[max] my $crit = 0; if(defined $self->{'config'}->{globaltimeout}) { $crit = $self->{'config'}->{globaltimeout}; } my $lastid = 0; my $perfdata = '|time='.$self->{'result'}->{'totalruntime'}.'s;0;'.$crit.';0;0'; for my $file (@{$self->{'result'}->{'files'}}) { for my $case (@{$file->{'cases'}}) { my $warn = $case->{'warning'} || 0; my $crit = $case->{'critical'} || 0; my $label = $case->{'label'} || 'case'.$case->{'id'}; $perfdata .= ' '.$label.'='.$case->{'latency'}.'s;'.$warn.';'.$crit.';0;0'; $lastid = $case->{'id'}; } } # report performance data for missed cases too for my $nr (1..($self->{'result'}->{'casecount'} - $self->{'result'}->{'totalruncount'})) { $lastid++; my $label = 'case'.$lastid; $perfdata .= ' '.$label.'=0s;0;0;0;0'; } my($rc,$message); if($self->{'result'}->{'iscritical'}) { $message = "WebInject CRITICAL - ".$self->{'result'}->{'returnmessage'}; $rc = $self->{'exit_codes'}->{'CRITICAL'}; } elsif($self->{'result'}->{'iswarning'}) { $message = "WebInject WARNING - ".$self->{'result'}->{'returnmessage'}; $rc = $self->{'exit_codes'}->{'WARNING'}; } elsif( $self->{'config'}->{globaltimeout} && $self->{'result'}->{'totalruntime'} > $self->{'config'}->{globaltimeout} ) { $message = "WebInject WARNING - All tests passed successfully but global timeout (".$self->{'config'}->{globaltimeout}." seconds) has been reached"; $rc = $self->{'exit_codes'}->{'WARNING'}; } else { $message = "WebInject OK - All tests passed successfully in ".$self->{'result'}->{'totalruntime'}." seconds"; $rc = $self->{'exit_codes'}->{'OK'}; } if($self->{'result'}->{'iscritical'} or $self->{'result'}->{'iswarning'}) { $message .= "\n".$self->{'out'}; $message =~ s/^\-+$//mx; } if($self->{'config'}->{'reporttype'} eq 'nagios2') { $message =~ s/\n/
/mxg; } print $message.$perfdata."\n"; $self->{'result'}->{'perfdata'} = $perfdata; return $rc; } #MRTG plugin compatibility elsif( $self->{'config'}->{'reporttype'} eq 'mrtg' ) { #report results in MRTG format if( $self->{'result'}->{'totalcasesfailedcount'} > 0 ) { print "$self->{'result'}->{'totalruntime'}\n$self->{'result'}->{'totalruntime'}\n\nWebInject CRITICAL - $self->{'result'}->{'returnmessage'} \n"; } else { print "$self->{'result'}->{'totalruntime'}\n$self->{'result'}->{'totalruntime'}\n\nWebInject OK - All tests passed successfully in $self->{'result'}->{'totalruntime'} seconds \n"; } } #External plugin. To use it, add something like that in the config file: # external:/home/webinject/Plugin.pm elsif ( $self->{'config'}->{'reporttype'} =~ /^external:(.*)/mx ) { our $webinject = $self; # set scope of $self to global, so it can be access in the external module unless( my $return = do $1 ) { croak "couldn't parse $1: $@\n" if $@; croak "couldn't do $1: $!\n" unless defined $return; croak "couldn't run $1\n" unless $return; } } else { $self->_usage("ERROR: only 'nagios', 'nagios2', 'mrtg', 'external', or 'standard' are supported reporttype values"); } } return 1 if $self->{'result'}->{'totalcasesfailedcount'} > 0; return 0; } ################################################################################ # delete any files leftover from previous run if they exist sub _whackoldfiles { my $self = shift; for my $file (qw/plot.log plot.plt plot.png/) { unlink $self->{'config'}->{'output_dir'}.$file if -e $self->{'config'}->{'output_dir'}.$file; } # verify files are deleted, if not give the filesystem time to delete them before continuing while (-e $self->{'config'}->{'output_dir'}."plot.log" or -e $self->{'config'}->{'output_dir'}."plot.plt" or -e $self->{'config'}->{'output_dir'}."plot.png" ) { sleep .5; } return; } ################################################################################ # call the external plotter to create a graph (if we are in the appropriate mode) sub _plotit { my $self = shift; # do this unless: monitor is disabled in gui, or running standalone mode without config setting to turn on plotting if( ( $self->{'gui'} and $self->{'monitorenabledchkbx'} ne 'monitor_off') or (!$self->{'gui'} and $self->{'config'}->{'standaloneplot'} eq 'on') ) { # do this unless its being called from the gui with No Graph set unless ( $self->{'config'}->{'graphtype'} eq 'nograph' ) { my $gnuplot; if(defined $self->{'config'}->{gnuplot}) { $gnuplot = $self->{'config'}->{gnuplot} } elsif($^O eq 'MSWin32') { $gnuplot = "./wgnupl32.exe"; } else { $gnuplot = "/usr/bin/gnuplot"; } # if gnuplot exists if( -e $gnuplot ) { system $gnuplot, $self->{'config'}->{output_dir}."plot.plt"; # plot it } elsif( $self->{'gui'} ) { # if gnuplot not specified, notify on gui $self->_gui_no_plotter_found(); } } } return; } ################################################################################ # fix a user supplied regex to make it compliant with mx options sub _fix_regex { my $self = shift; my $regex = shift; $regex =~ s/\\\ / /mx; $regex =~ s/\ /\\ /gmx; return $regex; } ################################################################################ # command line options sub _getoptions { my $self = shift; my( @sets, $opt_version, $opt_help, $opt_configfile ); Getopt::Long::Configure('bundling'); my $opt_rc = GetOptions( 'h|help' => \$opt_help, 'v|V|version' => \$opt_version, 'c|config=s' => \$opt_configfile, 'o|output=s' => \$self->{'config'}->{'output_dir'}, 'n|no-output' => \$self->{'config'}->{'nooutput'}, 'r|report-type=s' => \$self->{'config'}->{'reporttype'}, 't|timeout=i' => \$self->{'config'}->{'timeout'}, 's=s' => \@sets, ); if(!$opt_rc or $opt_help) { $self->_usage(); } if($opt_version) { print "WebInject version $Webinject::VERSION\nFor more info: http://www.webinject.org\n"; exit 3; } $self->_read_config_xml($opt_configfile); for my $set (@sets) { my ( $key, $val ) = split /=/mx, $set, 2; if($key eq 'httpauth') { $self->_set_http_auth($val); } else { $self->{'config'}->{ lc $key } = $val; } } return; } ################################################################################ # _out - print text to STDOUT and save it for later retrieval sub _out { my $self = shift; my $text = shift; if($self->{'config'}->{'reporttype'} !~ /^nagios/mx and !$self->{'config'}->{'nooutput'}) { print $text; } $self->{'out'} .= $text; return; } ################################################################################ # print usage sub _usage { my $self = shift; my $text = shift; print $text."\n\n" if defined $text; print <{'tmpfiles'}}) { unlink($tmpfile); } return; } =head1 TEST CASES =head2 Parameters =over =item addcookie When added to a test case, this adds a cookie to the cookie jar prior to the test case request being sent (i.e. the test case this is attached to will include any cookies specified in this parameter). This is useful for cases where a cookie is set outside of a Set-Cookie directive in the response header. This parameter takes a comma-delimited list of fields that configure the cookie; the fields for this parameter are a direct one-to-one correllation with the parameters to the HTTP::Cookies::set_cookie method. As well, multiple cookies can be defined by separating with a '|' character as with the addheader parameter. The comma-delimited list of fields are as follows. addcookie="version,name,value,path,domain,port,path_spec,secure,maxage,discard" version - Cookie-spec version number name - Cookie name. value - Cookie value. path - The URL path where the cookie is set. domain - The domain under which the cookie is set. port - The port on which the cookie is set. path_spec - Boolean. Set if the cookie is valid only under 'path' or the entire domain. secure - Boolean. If true (1), the cookie is only sent over secure connections maxage - The time in seconds the cookie is valid for. discard - Boolean. Do not send in future requests and destroy upon the next cookie jar save. =item parseresponse Parse a string from the HTTP response for use in subsequent requests. This is mostly used for passing Session ID's, but can be applied to any case where you need to pass a dynamically generated value. It takes the arguments in the format "leftboundary|rightboundary", and an optional third argument "leftboundary|rightboundary|escape|decode" when you want to force escaping of all non-alphanumeric characters (in case there is a wrong configuration of Apache server it will push encoded HTML characters (/ = /, : = :, ... ) to the Webinject and decode serve to translate them into normal characters. See the "Session Handling and State Management - Parsing Response Data & Embedded Session ID's" section of this manual for details and examples on how to use this parameter. Note: You may need to prepend a backslash before certain reserved characters when parsing (sorry that is rather vague). Note: Newlines (\n) are also valid boundaries and are useful when you need to use the end of the line as a boundary. parseresponse1 Additional parameter for response parsing. parseresponse2 Additional parameter for response parsing. parseresponse3 Additional parameter for response parsing. parseresponse4 Additional parameter for response parsing. parseresponse5 Additional parameter for response parsing. =back =head1 EXAMPLE TEST CASE detailed description about the syntax of testcases can be found on the Webinject homepage. =head1 SEE ALSO For more information about webinject visit http://www.webinject.org =head1 AUTHOR Corey Goldberg, Ecorey@goldb.orgE Sven Nierlein, Enierlein@cpan.orgE =head1 COPYRIGHT AND LICENSE Copyright (C) 2010 by Sven Nierlein Copyright (C) 2004-2006 by Corey Goldberg This library is free software; you can redistribute it under the GPL2 license. =cut 1; __END__ Webinject-1.94/MANIFEST0000644000175000017500000000223212653701170013223 0ustar svensvenbin/webinject.pl Changes examples/config.xml examples/testcases.xml inc/Module/AutoInstall.pm inc/Module/Install.pm inc/Module/Install/AutoInstall.pm inc/Module/Install/Base.pm inc/Module/Install/Can.pm inc/Module/Install/Fetch.pm inc/Module/Install/Include.pm inc/Module/Install/Makefile.pm inc/Module/Install/Metadata.pm inc/Module/Install/ReadmeFromPod.pm inc/Module/Install/Scripts.pm inc/Module/Install/Win32.pm inc/Module/Install/WriteAll.pm lib/Webinject.pm LICENSE Makefile.PL MANIFEST This list of files MANIFEST.SKIP META.yml README t/01-Webinject.t t/02-Test_Cases.t t/03-Report_Type_Nagios.t t/04-Timeouts.t t/05-Basic_Auth.t t/06-Proxy.t t/20-Full_Test_Case.t t/30-Nagios_Perf_Data.t t/97-Pod.t t/98-Pod-Coverage.t t/99-Perl-Critic.t t/data/01-response_codes.xml t/data/02-string_verification.xml t/data/03-parse_response.xml t/data/03-parse_response2.xml t/data/03-parse_response3.xml t/data/04-repeated_tests.xml t/data/05-report_types.xml t/data/06-thresholds.xml t/data/08-custom_var.xml t/data/09-fileupload.xml t/data/20-full_test.xml t/data/30-nagios_perf_data.xml t/data/external.pm t/data/fileup1.txt t/data/fileup2.png t/perlcriticrc t/TestWebServer.pm Webinject-1.94/README0000644000175000017500000001544313135607421012762 0ustar svensvenNAME Webinject - Perl Module for testing web services SYNOPSIS use Webinject; my $webinject = Webinject->new(); $webinject->engine(); DESCRIPTION WebInject is a free tool for automated testing of web applications and web services. It can be used to test individual system components that have HTTP interfaces (JSP, ASP, CGI, PHP, AJAX, Servlets, HTML Forms, XML/SOAP Web Services, REST, etc), and can be used as a test harness to create a suite of [HTTP level] automated functional, acceptance, and regression tests. A test harness allows you to run many test cases and collect/report your results. WebInject offers real-time results display and may also be used for monitoring system response times. CONSTRUCTOR new ( [ARGS] ) Creates an "Webinject" object. reporttype possible values are 'standard', 'nagios', 'nagios2', 'mrtg' or 'external:' nooutput suppress all output to STDOUT, create only logfiles break_on_errors stop after the first testcase fails, otherwise Webinject would go on and execute all tests regardless of the previous case. timeout Default timeout is 180seconds. Timeout starts again for every testcase. useragent Set the useragent used in HTTP requests. Default is 'Webinject'. max_redirect Set maximum number of HTTP redirects. Default is 0. proxy Sets a proxy which is then used for http and https requests. ex.: http://proxy.company.net:3128 with authentication: ex.: http://user:password@proxy.company.net:3128 output_dir Output directory where all logfiles will go to. Defaults to current directory. globalhttplog Can be 'yes' or 'onfail'. Will log the http request and response to a http.log file. httpauth Provides credentials for webserver authentications. The format is: ['servername', 'portnumber', 'realm-name', 'username', 'password'] baseurl the value can be used as {BASEURL} in the test cases baseurl1 the value can be used as {BASEURL1} in the test cases baseurl2 the value can be used as {BASEURL2} in the test cases standaloneplot can be "on" or "off". Default is off. Create gnuplot graphs when enabled. graphtype Defaults to 'lines' gnuplot Defines the path to your gnuplot binary. postbodybasedir Path to a directory from which all relative test case postbody directives are based. When test cases include a "postbody" directive with a "file=>..." value, and that value is a relative location, Webinject will prepend this directory path. If not supplied, the directory containing the current test case file is prepended to any relative "file=>" values. METHODS engine start the engine of webinject TEST CASES Parameters addcookie When added to a test case, this adds a cookie to the cookie jar prior to the test case request being sent (i.e. the test case this is attached to will include any cookies specified in this parameter). This is useful for cases where a cookie is set outside of a Set-Cookie directive in the response header. This parameter takes a comma-delimited list of fields that configure the cookie; the fields for this parameter are a direct one-to-one correllation with the parameters to the HTTP::Cookies::set_cookie method. As well, multiple cookies can be defined by separating with a '|' character as with the addheader parameter. The comma-delimited list of fields are as follows. addcookie="version,name,value,path,domain,port,path_spec,secure,maxa ge,discard" version - Cookie-spec version number name - Cookie name. value - Cookie value. path - The URL path where the cookie is set. domain - The domain under which the cookie is set. port - The port on which the cookie is set. path_spec - Boolean. Set if the cookie is valid only under 'path' or the entire domain. secure - Boolean. If true (1), the cookie is only sent over secure connections maxage - The time in seconds the cookie is valid for. discard - Boolean. Do not send in future requests and destroy upon the next cookie jar save. parseresponse Parse a string from the HTTP response for use in subsequent requests. This is mostly used for passing Session ID's, but can be applied to any case where you need to pass a dynamically generated value. It takes the arguments in the format "leftboundary|rightboundary", and an optional third argument "leftboundary|rightboundary|escape|decode" when you want to force escaping of all non-alphanumeric characters (in case there is a wrong configuration of Apache server it will push encoded HTML characters (/ = /, : = :, ... ) to the Webinject and decode serve to translate them into normal characters. See the "Session Handling and State Management - Parsing Response Data & Embedded Session ID's" section of this manual for details and examples on how to use this parameter. Note: You may need to prepend a backslash before certain reserved characters when parsing (sorry that is rather vague). Note: Newlines (\n) are also valid boundaries and are useful when you need to use the end of the line as a boundary. parseresponse1 Additional parameter for response parsing. parseresponse2 Additional parameter for response parsing. parseresponse3 Additional parameter for response parsing. parseresponse4 Additional parameter for response parsing. parseresponse5 Additional parameter for response parsing. EXAMPLE TEST CASE detailed description about the syntax of testcases can be found on the Webinject homepage. SEE ALSO For more information about webinject visit http://www.webinject.org AUTHOR Corey Goldberg, Sven Nierlein, COPYRIGHT AND LICENSE Copyright (C) 2010 by Sven Nierlein Copyright (C) 2004-2006 by Corey Goldberg This library is free software; you can redistribute it under the GPL2 license. Webinject-1.94/Changes0000644000175000017500000002404013135607365013375 0ustar svensvenWebInject Copyright 2010 Sven Nierlein (nierlein@cpan.org) Copyright 2004-2006 Corey Goldberg (corey@goldb.org) For information and documentation, visit the website at http://www.webinject.org --------------------------------- Release History: Version 1.94 - Tue Jul 25 11:26:20 CEST 2017 - Use relative path handling for postbody files (#27) - Add support for DELETE (#23) Version 1.92 - Thu Dec 22 21:26:50 CET 2016 - Support application/json Content-Type (#22) - Fix for uninitialized value $val (#21) Version 1.90 - Mon Feb 1 17:04:24 CET 2016 - add new addcookie test case attribute - add readme file Version 1.88 - Wed Aug 19 23:13:41 CEST 2015 - fix problem with tempfile in perl 5.20 Version 1.86 - Mon Nov 18 16:57:42 CET 2013 - add support for ssl proxy and proxy auth Version 1.84 - Fri Nov 1 11:01:23 CET 2013 - add realserver support (Klapwijk) Version 1.82 - Fri Nov 1 11:04:23 CET 2013 - remove temporary files also in nagios ePN mode Version 1.80 - Fri Sep 13 11:10:40 CEST 2013 - remove temporary cookie file after test Version 1.78 - Thu Jan 3 22:49:56 CET 2013 - replace parsedresult in xml input file - added fallback timeout for test cases Version 1.76 - Tue Nov 13 12:46:14 CET 2012 - added new case option parsewarning Version 1.74 - Sat May 12 13:36:48 CEST 2012 - changed html output into tables (Karsten Sievert) - support gzipped content (Simone Tiraboschi) Version 1.72 - Thu Feb 2 19:15:50 CET 2012 - fixed using parsed results Version 1.71 - Tue Jan 3 09:38:27 CET 2012 - fixed nagios epn support or check_webinject Version 1.70 - Sat Dec 10 12:40:03 CET 2011 - variables with -s varname= are now case-insensitive Version 1.69 - Tue Jul 12 10:25:17 CEST 2011 - better error message when LWP::protocol::https is missing - read break_on_errors setting from config file too - added reportmode 'nagios2' - fixed display of passed testcases - cleaner output for nagios report type Version 1.68 - Tue May 31 14:25:35 CEST 2011 - add warning if parsed result does not match - made overwriting default options in check_webinject possible - fixed performance data for nagios report type Version 1.67 - Thu Apr 28 16:52:29 CEST 2011 - make parsed respones available in the errormessage Version 1.66 - Tue Mar 8 19:18:04 CET 2011 - fixed setting httpauth with -s Version 1.64 - Sun Feb 27 18:37:16 CET 2011 - fixed file upload - fixed some warnings Version 1.62 - Sat Feb 19 16:24:56 CET 2011 - fixed cpan package Version 1.60 - Sat Feb 12 15:10:09 CET 2011 - fixed ssl proxy support - added tests for proxy support Version 1.58 - Tue Jan 25 20:15:35 CET 2011 - really fixed problem with regular expression using whitespace (thanks Benoit Baron) Version 1.57 - Sat Jan 22 00:34:56 CET 2011 - fixed problem with regular expression using whitespace (thanks Olivier Legras) Version 1.56 - Thu Jan 20 18:31:06 CET 2011 - added support for verifypositive|negative1-9999 - added lable to test case output when supplied - fixed error message when trying to start with invalid test files - webinject now exits with rc = 1 in case of failed tests ( not in reportmode nagios ) Version 1.55 - Sun Dec 19 11:39:30 CET 2010 - fixed problem with xml post checks (thanks Frédéric Gicquel) - fixed problem with escaping form types Version 1.54 - Tue Sep 14 11:55:48 CEST 2010 - fixed problem with "Return code of 13 for check of service ... on host ... was out of bounds" - fixed problem with error output - fixed problem with specifying testcases in the config.xml Version 1.53 - Aug 24, 2010 - fixed package again Version 1.52 - Aug 23, 2010 - fixed package (Makefile.PL) was missing - added make target for webinject.pl Version 1.51 - Jul 30, 2010 - added EPN support for check_webinject - remove the long nagios output for non failed checks - fixed http authentication - fixed http.log with custom report types Version 1.50 - Jul 29, 2010 - changed layout to common cpan module style - seperated module into gui and core - added timeout option - added report-type option - added break_on_errors option - added warning / critical threshold option - added max_redirect option - added generic option to set config.xml options - added label setting for nagios perf data - fixed nagios performance data Version 1.41 - Jan 4, 2006 - Added ability to add multiple HTTP Headers within an 'addheader' testcase parameter - Added 'addheader' testcase parameter to GET requests (previously only supported POST) - Fixed GUI layout for high dpi displays - Bugfixes for 'verifyresponsecode' and 'errormessage' parameters Version 1.40 - Dec 6, 2005 - Support for Web Services (SOAP/XML) - Added XML parser for parsing and verification of XML responses (web services) - Support for 'text/xml' and 'application/soap+xml' Content-Type (web services) - Added new 'addheader' testcase parameter so you can specify an additional HTTP Header field for requests - Support for setting variables/constants within test case files - Added ability to call generic external Perl plugins for easier integration and post-processing - More detail added to XML output - Code refactoring Version 1.35 - April 4, 2005 - New command line option (-o) to specify location for writing output files (http.log, results.html, and results.xml) - Nagios plugin performance data support - Allows multiple 'httpauth' elements in config files to support multiple sets of HTTP Authentication credentials - New 'verifyresponsecode' test case parameter for HTTP Response Code verification - Additional 'baseurl' elements supported in the config file - Additional verification parameters supported in test cases - Added -V command line option (same as -v) to print version info (necessary for it to run with Moodss) - Code refactoring Version 1.34 - Feb 10, 2005 - MRTG External Monitoring Script (Plugin) compatibility - Bugfix for using comment tags in config files - Suppress logging when running in plugin mode - Changed default standalone plot mode to OFF Version 1.33 - Jan 26, 2005 - Nagios Plugin compatibility - Support for multipart/form-data encoded POSTs (file uploads) - Updated results.html output so it is valid XHTML Version 1.32 - Jan 14, 2005 - Bugfix for erroneous dummy test case printing in GUI status - Bugfix for warning that appeared when running GUI with Perl in -w mode Version 1.31 - Jan 11, 2005 - Bugfix for errors and broken status bar in GUI Version 1.30 - Jan 07, 2005 - HTTP Basic Authentication support - No longer forced to have test cases in strict incremental numbered order - Source code compiles with the "use strict" pragma - Ability to run engine from a different directory using alternate test case and config files - Comments allowed in config file using tags - Other config.xml options are still used when you pass a test case filename as a command line argument - New config option to change response delay timeout - New test case parameter to add a custom error message - Added separators to http.log for readability - Enhanced command line options/switches - Nagios Plugin compatibility (beta) - More verbose error handling when running from command line - Ability to handle reserved XML character "<" within test cases by escaping it with a backslash "<" - Changed output when using XPath notation from command line - Bugfix for proxy support - Bugfix for sending a parsed value in a POST body - Bugfix for erroneous errors when running from command line - Bugfix for warnings that appeared when running with Perl in -w mode - Code refactoring Version 1.20 - Sept 27, 2004 - Real-time response time monitoring (stats display and integration with gnuplot for plot/graph) - Added tabbed layout to GUI with 'Status' and 'Monitor' windows - Added 'Stop' button to GUI to halt execution - New testcase parameter 'sleep', to throttle execution - Added timer summary to HTML report - Removed HTML tags from STDOUT display and cleaned up formatting - GUI enhancements - Code refactoring Version 1.12 - July 28, 2004 - New test case file parameter 'repeat', to run a test case file multiple times - Added GUI options for Minimal Output and Response Timer Output - New config.xml parameter to define a custom User-Agent string to be sent in HTTP headers - Added XPath Node selection to optional command line parameters - Bugfix for GUI Restart button Version 1.10 - June 23, 2004 - Added XML formatted output (results.xml is created each run) - New config.xml parameter for HTTP logging - More detailed pass/fail status to HTML report - Redefined criteria for test case pass/pail - Results summary and additional formatting to STDOUT (for standalone mode) - Minor code refactoring Version 0.95 - May 17, 2004 - Added Restart button to GUI - Added 5 additional parsing parameters/variables to use in test cases - Fixes to GUI positioning Version 0.94 - April 29, 2004 - Bugfix for malformed HTTP Post - Added colors to status window text Version 0.93 - March 22, 2004 - Dynamic response parsing support cookieless session handling - Added version number to GUI window title bar Version 0.92 - March 05, 2004 - Minor bug fixes - Added status light to GUI - New config.xml parameter for HTTP proxy support - New config.xml parameter for Baseurl constant Version 0.91 - Feb 23, 2004 - Decoupled GUI (webinjectgui) from Test Engine (webinject) so engine can run standalone - Testcase name can be passed on command line as well as via config.xml - Code cleanup - Output sent to STDOUT as well as reports (for standalone mode) Version 0.90 - Feb 19, 2004 - Initial public beta release - Contains SSL/TLS support - Perl/Tk GUI - Automatic cookie handling ---------------------------------