Merge ~federicoquattrin/qa-regression-testing:add_libspreadsheet-parseexcel-perl_tests into qa-regression-testing:master

Proposed by Federico Quattrin
Status: Needs review
Proposed branch: ~federicoquattrin/qa-regression-testing:add_libspreadsheet-parseexcel-perl_tests
Merge into: qa-regression-testing:master
Diff against target: 110 lines (+89/-0)
2 files modified
scripts/spreadsheet-parseexcel/exploit.pl (+6/-0)
scripts/test-libspreadsheet-parseexcel-perl.py (+83/-0)
Reviewer Review Type Date Requested Status
Ubuntu Security Team Pending
Review via email: mp+466194@code.launchpad.net

Commit message

added tests for libspreadsheet-parseexcel-perl

Description of the change

added tests for libspreadsheet-parseexcel-perl

To post a comment you must log in.
bf54b5f... by Federico Quattrin

added additional files for libspreadsheet-parseexcel-perl

Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

Where did the binary files come from, and how are they licensed?

Unmerged commits

bf54b5f... by Federico Quattrin

added additional files for libspreadsheet-parseexcel-perl

Failed
[SUCCEEDED] imagemagick:0 (build)
[SUCCEEDED] imagemagick:1 (build)
[SUCCEEDED] imagemagick:2 (build)
[SUCCEEDED] gcc-security:0 (build)
[SUCCEEDED] gcc-security:1 (build)
[SUCCEEDED] gcc-security:2 (build)
[SUCCEEDED] glibc:0 (build)
[SUCCEEDED] glibc:1 (build)
[SUCCEEDED] glibc:2 (build)
[SUCCEEDED] glibc-security:0 (build)
[SUCCEEDED] glibc-security:1 (build)
[SUCCEEDED] glibc-security:2 (build)
[SUCCEEDED] gnupg:0 (build)
[SUCCEEDED] gnupg:1 (build)
[SUCCEEDED] gnupg:2 (build)
[SUCCEEDED] sudo:0 (build)
[SUCCEEDED] sudo:1 (build)
[SUCCEEDED] sudo:2 (build)
[SUCCEEDED] git:0 (build)
[SUCCEEDED] git:1 (build)
[SUCCEEDED] git:2 (build)
[SUCCEEDED] ghostscript:0 (build)
[SUCCEEDED] ghostscript:1 (build)
[SUCCEEDED] ghostscript:2 (build)
[SUCCEEDED] busybox:0 (build)
[SUCCEEDED] busybox:1 (build)
[SUCCEEDED] busybox:2 (build)
[SUCCEEDED] coreutils:0 (build)
[SUCCEEDED] coreutils:1 (build)
[SUCCEEDED] coreutils:2 (build)
[SUCCEEDED] util-linux:0 (build)
[SUCCEEDED] util-linux:1 (build)
[SUCCEEDED] util-linux:2 (build)
[SUCCEEDED] ecdsautils:0 (build)
[SUCCEEDED] ecdsautils:1 (build)
[SUCCEEDED] ecdsautils:2 (build)
[SUCCEEDED] python-urllib3:0 (build)
[SUCCEEDED] python-urllib3:1 (build)
[SUCCEEDED] python-urllib3:2 (build)
[SUCCEEDED] amanda:0 (build)
[SUCCEEDED] amanda:1 (build)
[FAILED] cryptojs:0 (build)
[FAILED] cryptojs:1 (build)
[FAILED] cryptojs:2 (build)
[FAILED] cryptojs:3 (build)
145 of 45 results
5450203... by Federico Quattrin

added tests for libspreadsheet-parseexcel-perl

Failed
[SUCCEEDED] imagemagick:0 (build)
[SUCCEEDED] imagemagick:1 (build)
[SUCCEEDED] imagemagick:2 (build)
[SUCCEEDED] gcc-security:0 (build)
[SUCCEEDED] gcc-security:1 (build)
[SUCCEEDED] gcc-security:2 (build)
[SUCCEEDED] glibc:0 (build)
[SUCCEEDED] glibc:1 (build)
[SUCCEEDED] glibc:2 (build)
[SUCCEEDED] glibc-security:0 (build)
[SUCCEEDED] glibc-security:1 (build)
[SUCCEEDED] glibc-security:2 (build)
[SUCCEEDED] gnupg:0 (build)
[SUCCEEDED] gnupg:1 (build)
[SUCCEEDED] gnupg:2 (build)
[SUCCEEDED] sudo:0 (build)
[SUCCEEDED] sudo:1 (build)
[SUCCEEDED] sudo:2 (build)
[SUCCEEDED] git:0 (build)
[SUCCEEDED] git:1 (build)
[SUCCEEDED] git:2 (build)
[SUCCEEDED] ghostscript:0 (build)
[SUCCEEDED] ghostscript:1 (build)
[SUCCEEDED] ghostscript:2 (build)
[SUCCEEDED] busybox:0 (build)
[SUCCEEDED] busybox:1 (build)
[SUCCEEDED] busybox:2 (build)
[SUCCEEDED] coreutils:0 (build)
[SUCCEEDED] coreutils:1 (build)
[SUCCEEDED] coreutils:2 (build)
[SUCCEEDED] util-linux:0 (build)
[SUCCEEDED] util-linux:1 (build)
[SUCCEEDED] util-linux:2 (build)
[SUCCEEDED] ecdsautils:0 (build)
[SUCCEEDED] ecdsautils:1 (build)
[SUCCEEDED] ecdsautils:2 (build)
[SUCCEEDED] python-urllib3:0 (build)
[SUCCEEDED] python-urllib3:1 (build)
[SUCCEEDED] python-urllib3:2 (build)
[SUCCEEDED] amanda:0 (build)
[SUCCEEDED] amanda:1 (build)
[FAILED] cryptojs:0 (build)
[FAILED] cryptojs:1 (build)
[FAILED] cryptojs:2 (build)
[FAILED] cryptojs:3 (build)
145 of 45 results

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/scripts/spreadsheet-parseexcel/exploit.pl b/scripts/spreadsheet-parseexcel/exploit.pl
2new file mode 100644
3index 0000000..b9ef0de
4--- /dev/null
5+++ b/scripts/spreadsheet-parseexcel/exploit.pl
6@@ -0,0 +1,6 @@
7+use strict;
8+use Spreadsheet::ParseExcel;
9+
10+my $parser = Spreadsheet::ParseExcel->new();
11+# file.xls is malicious file from end user
12+my $workbook = $parser->parse("test.xls");
13\ No newline at end of file
14diff --git a/scripts/spreadsheet-parseexcel/test.xls b/scripts/spreadsheet-parseexcel/test.xls
15new file mode 100644
16index 0000000..6e89acc
17Binary files /dev/null and b/scripts/spreadsheet-parseexcel/test.xls differ
18diff --git a/scripts/spreadsheet-parseexcel/test.xlsx b/scripts/spreadsheet-parseexcel/test.xlsx
19new file mode 100644
20index 0000000..c9190fc
21Binary files /dev/null and b/scripts/spreadsheet-parseexcel/test.xlsx differ
22diff --git a/scripts/test-libspreadsheet-parseexcel-perl.py b/scripts/test-libspreadsheet-parseexcel-perl.py
23new file mode 100755
24index 0000000..0a8c03d
25--- /dev/null
26+++ b/scripts/test-libspreadsheet-parseexcel-perl.py
27@@ -0,0 +1,83 @@
28+#!/usr/bin/python3
29+#
30+# test-spreadsheet-parseexcel.py quality assurance test script for PKG
31+# Copyright (C) 2012 Canonical Ltd.
32+# Author:
33+#
34+# This program is free software: you can redistribute it and/or modify
35+# it under the terms of the GNU General Public License version 3,
36+# as published by the Free Software Foundation.
37+#
38+# This program is distributed in the hope that it will be useful,
39+# but WITHOUT ANY WARRANTY; without even the implied warranty of
40+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41+# GNU General Public License for more details.
42+#
43+# You should have received a copy of the GNU General Public License
44+# along with this program. If not, see <http://www.gnu.org/licenses/>.
45+#
46+
47+# QRT-Packages: libspreadsheet-parseexcel-perl
48+# QRT-Depends: spreadsheet-parseexcel
49+
50+'''
51+ In general, this test should be run in a virtual machine (VM) or possibly
52+ a chroot and not on a production machine. While efforts are made to make
53+ these tests non-destructive, there is no guarantee this script will not
54+ alter the machine. You have been warned.
55+
56+ How to run in a clean VM:
57+ $ ./make-test-tarball test-spreadsheet-parseexcel.py # creates tarball in /tmp/
58+ $ scp /tmp/qrt-test-spreadsheet-parseexcel.tar.gz root@vm.host:/tmp
59+ on VM:
60+ # cd /tmp ; tar zxvf ./qrt-test-spreadsheet-parseexcel.tar.gz
61+ # cd /tmp/qrt-test-spreadsheet-parseexcel ; ./install-packages ./test-spreadsheet-parseexcel.py
62+ # ./test-spreadsheet-parseexcel.py -v
63+
64+ To run in all VMs named sec*:
65+ $ vm-qrt -p sec test-<script.py>
66+
67+ ### TODO: update for ./install-packages step ###
68+ How to run in a clean schroot named 'lucid':
69+ $ schroot -c lucid -u root -- sh -c 'apt-get -y install lsb-release <QRT-Packages> && ./test-PKG.py -v'
70+'''
71+
72+from __future__ import print_function
73+
74+import os
75+import subprocess
76+import sys
77+import unittest
78+import testlib
79+
80+
81+class SpreadsheetParseExcelTest(testlib.TestlibCase):
82+ '''Test the perl library Spreadsheet::ParseExcel.'''
83+
84+ def tearDown(self):
85+ '''Clean up after each test_* function'''
86+ if os.path.exists("/tmp/inject.txt"):
87+ os.remove("/tmp/inject.txt")
88+
89+ def test_cve_2023_7101(self):
90+ '''Test CVE-2023-7101'''
91+ os.chdir("{}/spreadsheet-parseexcel".format(os.path.dirname(os.path.realpath(__file__))))
92+ self.exploit()
93+ injected_exists = os.path.exists("/tmp/inject.txt")
94+ if injected_exists:
95+ with open("/tmp/inject.txt", "r") as injected_file:
96+ file_content = injected_file.read()
97+ print("Injected file exists and it's content is {}".format(file_content))
98+ self.assertFalse(injected_exists)
99+
100+ def exploit(self):
101+ if self.lsb_release.get("Release") == 14.04:
102+ subprocess.call(["perl", "exploit.pl"])
103+ else:
104+ subprocess.run(["perl", "exploit.pl"])
105+
106+
107+
108+
109+if __name__ == '__main__':
110+ unittest.main()

Subscribers

People subscribed via source and target branches