Bugzilla – Attachment 99754 Details for
Bug 24756
Occasional failures for Koha/XSLT/Security.t
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24756: Fix failing tests by removing temporary filenames
Bug-24756-Fix-failing-tests-by-removing-temporary-.patch (text/plain), 3.89 KB, created by
Marcel de Rooy
on 2020-02-28 11:20:04 UTC
(
hide
)
Description:
Bug 24756: Fix failing tests by removing temporary filenames
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2020-02-28 11:20:04 UTC
Size:
3.89 KB
patch
obsolete
>From ad6440b3468bc49742e493234c8e2605b7fdd86d Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 28 Feb 2020 11:13:16 +0000 >Subject: [PATCH] Bug 24756: Fix failing tests by removing temporary filenames >Content-Type: text/plain; charset=utf-8 > >In order to resolve the random failure, that might be caused by reusing >filenames in File::Temp and caching xslt code, this patch replaces the >temporary file by using the code parameter. > >Note: Since XSLT uses a digest based on the passed code fragment, we will >exclude collisions here. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > t/db_dependent/Koha/XSLT/Security.t | 25 +++++++++---------------- > 1 file changed, 9 insertions(+), 16 deletions(-) > >diff --git a/t/db_dependent/Koha/XSLT/Security.t b/t/db_dependent/Koha/XSLT/Security.t >index 41b72aafb5..a61f654160 100644 >--- a/t/db_dependent/Koha/XSLT/Security.t >+++ b/t/db_dependent/Koha/XSLT/Security.t >@@ -39,14 +39,12 @@ my $xslt=<<"EOT"; > </xsl:template> > </xsl:stylesheet> > EOT >-my $xslt_file = mytempfile($xslt); >- >-my $output= $engine->transform( "<ignored/>", $xslt_file ); >+my $output= $engine->transform({ xml => "<ignored/>", code => $xslt }); > like($output, qr/Big secret/, 'external entity got through'); > > t::lib::Mocks::mock_config( 'koha_xslt_security', { expand_entities_unsafe => 0 } ); > $engine=Koha::XSLT::Base->new; >-$output= $engine->transform( "<ignored/>", $xslt_file ); >+$output= $engine->transform({ xml => "<ignored/>", code => $xslt }); > unlike($output, qr/Big secret/, 'external entity did not get through'); > > # Adding a document call to trigger callback for read_file >@@ -59,8 +57,7 @@ $xslt=<<"EOT"; > </xsl:template> > </xsl:stylesheet> > EOT >-$xslt_file = mytempfile($xslt); >-warnings_like { $output= $engine->transform( "<ignored/>", $xslt_file ); } >+warnings_like { $output= $engine->transform({ xml => "<ignored/>", code => $xslt }); } > [ qr/read_file called in XML::LibXSLT/, qr/runtime error/ ], > 'Triggered security callback for read_file'; > >@@ -73,8 +70,7 @@ $xslt=<<"EOT"; > </xsl:template> > </xsl:stylesheet> > EOT >-$xslt_file = mytempfile($xslt); >-warnings_like { $output= $engine->transform( "<ignored/>", $xslt_file ); } >+warnings_like { $output= $engine->transform({ xml => "<ignored/>", code => $xslt }); } > [ qr/write_file called in XML::LibXSLT/, qr/runtime error/ ], > 'Triggered security callback for write_file'; > >@@ -87,8 +83,7 @@ $xslt=<<"EOT"; > </xsl:template> > </xsl:stylesheet> > EOT >-$xslt_file = mytempfile($xslt); >-warnings_like { $output= $engine->transform( "<ignored/>", $xslt_file ); } >+warnings_like { $output= $engine->transform({ xml => "<ignored/>", code => $xslt }); } > [ qr/read_net called in XML::LibXSLT/, qr/runtime error/ ], > 'Triggered security callback for read_net'; > >@@ -103,8 +98,7 @@ $xslt=<<"EOT"; > </xsl:template> > </xsl:stylesheet> > EOT >-$xslt_file = mytempfile($xslt); >-warnings_like { $output= $engine->transform( "<ignored/>", $xslt_file ); } >+warnings_like { $output= $engine->transform({ xml => "<ignored/>", code => $xslt }); } > [ qr/write_net called in XML::LibXSLT/, qr/runtime error/ ], > 'Triggered security callback for write_net'; > >@@ -118,19 +112,18 @@ $xslt=<<"EOT"; > <xsl:template match="/"/> > </xsl:stylesheet> > EOT >-$xslt_file = mytempfile($xslt); > $engine->print_warns(1); > { > my @warn; > local $SIG{__WARN__} = sub { push @warn, $_[0]; }; >- $output= $engine->transform( "<ignored/>", $xslt_file ); >+ $output= $engine->transform({ xml => "<ignored/>", code => $xslt }); > is( ( grep { /failed to load external/ } @warn ), 1, 'Expected import error' ); > is( ( grep { /read_net/ } @warn ), 0, 'No read_net warn for remote import' ); > } > > sub mytempfile { >- my ( $fh, $fn ) = tempfile( SUFFIX => '.xsl', UNLINK => 1 ); >- print $fh $_[0]//''; >+ my ($fh, $fn) = tempfile( UNLINK => 1 ); >+ print $fh $_[0] if $_[0]; > close $fh; > return $fn; > } >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24756
:
99746
|
99753
| 99754 |
99858
|
99892
|
102270
|
102271