From 1133f8715884bed02e62f12e82ff456a02cf567a Mon Sep 17 00:00:00 2001 From: Chris Novakovic Date: Thu, 4 Apr 2024 01:48:20 +0100 Subject: [PATCH] Replace binary test file with ASCII text file t/data/binary-test.file is a binary blob of unknown provenance. To provide more reassurance that nothing malicious is hidden in binary blobs in the test suite, replace this file with the ASCII text file t/data/lorem-ipsum.txt, which contains the first two paragraphs of lorem ipsum generated by https://lipsum.com with lines wrapped at 80 characters. Closes #475. --- Changes | 3 +++ MANIFEST | 2 +- t/data/binary-test.file | Bin 5000 -> 0 bytes t/data/lorem-ipsum.txt | 24 ++++++++++++++++++++++++ t/local/10_rand.t | 37 ++++++++++++++++++++++++++++--------- t/local/50_digest.t | 27 ++++++++++++--------------- 6 files changed, 68 insertions(+), 25 deletions(-) delete mode 100644 t/data/binary-test.file create mode 100644 t/data/lorem-ipsum.txt diff --git a/Changes b/Changes index a22213b3..c51767ea 100644 --- a/Changes +++ b/Changes @@ -4,6 +4,9 @@ Revision history for Perl extension Net::SSLeay. - Skip NPN tests when NPN is disabled in OpenSSL instead o assuming NPN is always enabled. Reported by GitHub user dilyanpalauzov Дилян Палаузов. + - In the test suite, replace t/data/binary-test.file (a binary blob with + unknown provenance) with t/data/lorem-ipsum.txt (a text file containing + widely-known ASCII text). 1.94 2024-01-08 - New stable release incorporating all changes from developer releases 1.93_01 diff --git a/MANIFEST b/MANIFEST index 924e76dc..62b4c7bc 100644 --- a/MANIFEST +++ b/MANIFEST @@ -44,7 +44,7 @@ README.OSX README.VMS README.Win32 SSLeay.xs -t/data/binary-test.file +t/data/lorem-ipsum.txt t/data/openssl_init_test.conf t/data/extended-cert.cert.der t/data/extended-cert.cert.dump diff --git a/t/data/binary-test.file b/t/data/binary-test.file deleted file mode 100644 index 119cecc8c35b4e0aa8f44c0114775e497548b142..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5000 zcmV;36L;)lzdVHFl2v;NWRG#2)0sdYPEq2}GjZ(-kKJJ`Trn7J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!mY0tcL=x( z1o)o#5W0N}I{!ww-}_nxLlglWhGG~LR4cs83%hAS4Rz}gRA?0}ZxY32*Te7y@Vy2w zAJJKB4y01cANS)pQ_AO})Gp7Rvt`0zVtr5?JdoaK2?}FDM=GNW{a&Kdd5DZHo&m+4 z&aRv&Mog3cp&dweVu9@4SLA^r+*1a+C^vk03KPBBXH|rZ0WE|H<}<(5 z!!dH)n@v(>vW28NhUyP{AyO%5<8tU(oG~hK!DZ6SAWjhdJ}pj#6fD%QyH&7bI7-V_ z?j|sOT!9t&-=YQmsVDy&t2CC;`OlPswhW-5^KIprZAJ+%P*X~h5Z^`+Dg_tlc&@TQ zn$xe3zx912AMVMiuuvG*dq@w9hmke((l^&Eh6%k3F6Z=PB_dvEjHn+#PjS3a%Bidw z()hegJ3V0_$}uU7W9tLs61D>pC{H3h>ls@K4pFx55DDsS4xMy00UWM;a4AIqE#N2wgFE=1n^q3xiUC}+Rp{O4t$l?vyjk2QJho_>lQ zwyp4N2q)}jyz&k>1b;L9dDxi9qu;FlsDWDwbj;BzZh-VGWQ$21!U5(mE&IggteFte Sk=yc&QN-g4?jrd|I)?y=4Y<<) diff --git a/t/data/lorem-ipsum.txt b/t/data/lorem-ipsum.txt new file mode 100644 index 00000000..b0be5521 --- /dev/null +++ b/t/data/lorem-ipsum.txt @@ -0,0 +1,24 @@ +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin vitae nisl +porta, maximus orci a, varius risus. Integer nisl lectus, convallis non +convallis sit amet, maximus sodales magna. Donec cursus, diam non pellentesque +ornare, diam diam laoreet justo, auctor finibus sem justo non mi. Suspendisse +efficitur eget orci ut condimentum. Nunc tempor eleifend varius. Vestibulum at +sapien non lacus fermentum viverra. Maecenas faucibus libero vel molestie +finibus. Curabitur eu nisl arcu. Morbi egestas, libero pellentesque pharetra +bibendum, magna lorem efficitur nisl, id placerat nisi sem eget ex. Donec non +metus ultrices, lobortis arcu sit amet, sagittis felis. Proin molestie lectus +et nisi sollicitudin blandit. Quisque cursus imperdiet nisl, vitae consectetur +lacus ullamcorper nec. Donec pellentesque libero at dapibus ultricies. Nullam +ut lorem vitae mi dapibus hendrerit eget nec nisl. + +Etiam purus nulla, porta et fringilla sed, maximus id odio. Mauris mattis nibh +id consectetur finibus. Curabitur hendrerit augue nec magna malesuada +suscipit. Quisque dui dolor, volutpat ac iaculis et, cursus eu arcu. Cras ut +nisi ut risus laoreet eleifend. Nunc accumsan, leo in malesuada rhoncus, diam +tortor blandit odio, ac pretium nisl lacus commodo nisl. Nam et feugiat +libero. Praesent rutrum erat sit amet euismod venenatis. Integer dictum +tincidunt urna, sit amet facilisis nibh tristique et. Aliquam sed sapien in +ipsum lacinia viverra. Maecenas ante arcu, pretium volutpat varius ac, ornare +sed ante. Quisque eleifend, dui a molestie vestibulum, urna diam imperdiet ex, +eget eleifend nibh tortor vitae quam. Phasellus ac consequat arcu, a tempus +quam. Etiam ut rhoncus turpis. In id est magna. diff --git a/t/local/10_rand.t b/t/local/10_rand.t index fb0f0f3c..e70f49bf 100644 --- a/t/local/10_rand.t +++ b/t/local/10_rand.t @@ -18,17 +18,36 @@ is_libressl() ? test_rand_file_name_openssl(); # RAND_load_file -my $binary_file = data_file_path('binary-test.file'); -my $binary_file_size = -s $binary_file; - -cmp_ok($binary_file_size, '>=', 1000, "Have binary file with good size: $binary_file $binary_file_size"); -is(Net::SSLeay::RAND_load_file($binary_file, $binary_file_size), $binary_file_size, 'RAND_load with specific size'); -if (Net::SSLeay::constant("LIBRESSL_VERSION_NUMBER")) -{ +my $text_file = data_file_path('lorem-ipsum.txt'); +my $text_file_size = -s $text_file; + +cmp_ok( + $text_file_size, + '>=', + 1000, + "Have file with good size: $text_file $text_file_size" +); + +is( + Net::SSLeay::RAND_load_file($text_file, $text_file_size), + $text_file_size, + 'RAND_load with specific size' +); + +if ( Net::SSLeay::constant('LIBRESSL_VERSION_NUMBER') ) { # RAND_load_file does nothing on LibreSSL but should return something sane - cmp_ok(Net::SSLeay::RAND_load_file($binary_file, -1), '>', 0, 'RAND_load with -1 is positive with LibreSSL'); + cmp_ok( + Net::SSLeay::RAND_load_file($text_file, -1), + '>', + 0, + 'RAND_load with -1 is positive with LibreSSL' + ); } else { - is(Net::SSLeay::RAND_load_file($binary_file, -1), $binary_file_size, 'RAND_load with -1 returns file size'); + is( + Net::SSLeay::RAND_load_file($text_file, -1), + $text_file_size, + 'RAND_load with -1 returns file size' + ); } test_rand_bytes(); diff --git a/t/local/50_digest.t b/t/local/50_digest.t index 2aeb254e..1d208cb7 100644 --- a/t/local/50_digest.t +++ b/t/local/50_digest.t @@ -16,7 +16,6 @@ sub digest_chunked_f1 { Net::SSLeay::EVP_DigestInit($ctx, $md); open my $fh, "<", $file or BAIL_OUT "cannot open file '$file'"; - binmode $fh; while(my $len = sysread($fh, my $chunk, 500)) { Net::SSLeay::EVP_DigestUpdate($ctx,$chunk); } @@ -36,7 +35,6 @@ sub digest_chunked_f2 { Net::SSLeay::EVP_DigestInit_ex($ctx, $md, 0); #NULL ENGINE just to test whether the function exists open my $fh, "<", $file or BAIL_OUT "cannot open file '$file'"; - binmode $fh; while(my $len = sysread($fh, my $chunk, 5)) { Net::SSLeay::EVP_DigestUpdate($ctx,$chunk); } @@ -60,7 +58,6 @@ sub digest_file { } open my $f, "<", $file or BAIL_OUT "cannot open file '$file'"; - binmode $f; sysread($f, my $data, -s $file) or BAIL_OUT "sysread failed"; close $f; @@ -177,20 +174,20 @@ SKIP: { isnt(scalar(keys %all_digests), 0, 'non-empty digest list'); } -my $file = data_file_path('binary-test.file'); +my $file = data_file_path('lorem-ipsum.txt'); my $file_digests = { - md2 => '67ae6d821be6898101414c56b1fb4f46', - md4 => '480438696e7d9a6ab3ecc1e2a3419f78', - md5 => 'cc89b43c171818c347639fa5170aee16', - mdc2 => 'ee605fe3fc966a7b17185ebdbcd13ada', - ripemd160 => 'cb70ba43fc6d263f6d7816170c1a33f28c2000fe', - sha => 'c151c6f408cb94bc5c53b17852efbe8bfbeec2b9', - sha1 => '059404d1d0e952d0457a6c99b6e68b3b44c8ef13', - sha224 => '161c65efa1b9762f7e0448b5b369a3e2c236876b0b57a35add5106bb', - sha256 => 'e416730ddaa34729adb32ec6ddad4e50fca1fe97de313e800196b1f8cd5032bd', - sha512 => '8b5e7181fc76d49e1cb7971a6980b5d8db6b23c3b0553cf42f559156fd08e64567d17c4147c864efd4d3a5e22fb6602d613a055f7f14faad22744dbc3df89d59', - whirlpool => '31079767aa2dd9b8ab01caadd954a88aaaf6001941c38d17ba43c0ef80a074c3eedf35b73c3941929dea281805c6c5ffc0a619abef4c6a3365d6cb31412d0e0c', + md2 => '70982048c26bc1b0e4a14882143c43db', + md4 => '10d7111dd6931a247b88ad05a6389ade', + md5 => '92798fe3cda6fd622e1de6f78fe2ba78', + mdc2 => 'eba3531b18827ec79aa4b421c63e6931', + ripemd160 => '0976116cd4513f81d9696811d72c68e6d59ce73c', + sha => 'aa862084fa60357fd983fb78945c4870e8c455a1', + sha1 => '6bddd57399253c98ce7e1e1478426e317a6545ed', + sha224 => '3ea7316d84881fbff013e6852ad0767e605352ae1fbdc43105f91701', + sha256 => '76043f712d7c45bfad74bc0187b4eb259027193f68718e642fba976ec638b4ac', + sha512 => '593ed012548e15bd43e4a3fa95b7c9bdf43c1c6aa1e42ed8a7ad3ef87a40fbfa4503bf95b5e9ecf17fc9398958968e9766c171ac6cf268f9394b0de73e78e3b2', + whirlpool => '6216e98b1a920b14010f58c96299c738d4a156b7b533c74c9ae6da60e936958687017b8398d34efb05526e6156386f1af0b07f1b4af6feb41d6b45975d579a14', }; my %fps = (