test_msoffice.c (9348B)
1 /* 2 This file is part of libextractor. 3 Copyright (C) 2026 Vidyut Samanta and Christian Grothoff 4 5 libextractor is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published 7 by the Free Software Foundation; either version 3, or (at your 8 option) any later version. 9 10 libextractor is distributed in the hope that it will be useful, but 11 WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with libextractor; see the file COPYING. If not, write to the 17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 Boston, MA 02110-1301, USA. 19 */ 20 /** 21 * @file plugins/test_msoffice.c 22 * @brief testcase for the msoffice plugin 23 * @author Christian Grothoff 24 * 25 * See testdata/README for where the sample documents come from and 26 * under what terms they are redistributed here. 27 */ 28 #include "platform.h" 29 #include "test_lib.h" 30 31 32 /** 33 * Shorthand for a UTF-8 text solution entry. 34 * 35 * @param t meta data type to expect 36 * @param s string value to expect 37 */ 38 #define TXT(t, s) { t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, \ 39 strlen (s) + 1, 0 } 40 41 42 /** 43 * Main function for the msoffice testcase. 44 * 45 * @param argc number of arguments (ignored) 46 * @param argv arguments (ignored) 47 * @return 0 on success 48 */ 49 int 50 main (int argc, char *argv[]) 51 { 52 /* A real Word 2007 document: summary, application properties and a 53 tracked insertion. Note that the tracked change is timestamped 54 five hours before the modification date in the summary -- Word 55 writes the local time of the editing session here, which leaks the 56 author's time zone. */ 57 struct SolutionData msoffice_word_sol[] = { 58 TXT (EXTRACTOR_METATYPE_MIMETYPE, 59 "application/vnd.openxmlformats-officedocument.wordprocessingml.document"), 60 TXT (EXTRACTOR_METATYPE_TITLE, "Database Deployment Request"), 61 TXT (EXTRACTOR_METATYPE_CREATOR, "Doug Kanoza"), 62 TXT (EXTRACTOR_METATYPE_LAST_SAVED_BY, "Administrator"), 63 TXT (EXTRACTOR_METATYPE_REVISION_NUMBER, "16"), 64 TXT (EXTRACTOR_METATYPE_LAST_PRINTED, "2113-01-01T04:00:00Z"), 65 TXT (EXTRACTOR_METATYPE_CREATION_DATE, "2008-09-25T15:27:00Z"), 66 TXT (EXTRACTOR_METATYPE_MODIFICATION_DATE, "2009-01-21T19:46:00Z"), 67 TXT (EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, "Microsoft Office Word"), 68 TXT (EXTRACTOR_METATYPE_SOFTWARE_VERSION, "12.0000"), 69 TXT (EXTRACTOR_METATYPE_COMPANY, "NCI"), 70 TXT (EXTRACTOR_METATYPE_TEMPLATE, "Normal.dotm"), 71 TXT (EXTRACTOR_METATYPE_TOTAL_EDITING_TIME, "152"), 72 TXT (EXTRACTOR_METATYPE_PAGE_COUNT, "1"), 73 TXT (EXTRACTOR_METATYPE_WORD_COUNT, "240"), 74 TXT (EXTRACTOR_METATYPE_CHARACTER_COUNT, "1371"), 75 TXT (EXTRACTOR_METATYPE_LINE_COUNT, "11"), 76 TXT (EXTRACTOR_METATYPE_PARAGRAPH_COUNT, "3"), 77 TXT (EXTRACTOR_METATYPE_CONTRIBUTOR_NAME, "Administrator"), 78 TXT (EXTRACTOR_METATYPE_REVISION_HISTORY, 79 "Author `Administrator' edited the document on `2009-01-21T14:46:00Z'") 80 , 81 { 0, 0, NULL, NULL, 0, -1 } 82 }; 83 84 /* A real Excel 2007 workbook. */ 85 struct SolutionData msoffice_excel_sol[] = { 86 TXT (EXTRACTOR_METATYPE_MIMETYPE, 87 "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"), 88 TXT (EXTRACTOR_METATYPE_CREATOR, "Kelly Kozar"), 89 TXT (EXTRACTOR_METATYPE_LAST_SAVED_BY, "Kelly Kozar"), 90 TXT (EXTRACTOR_METATYPE_CREATION_DATE, "2009-01-09T23:02:03Z"), 91 TXT (EXTRACTOR_METATYPE_MODIFICATION_DATE, "2009-01-10T01:50:37Z"), 92 TXT (EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, "Microsoft Excel"), 93 TXT (EXTRACTOR_METATYPE_SOFTWARE_VERSION, "12.0000"), 94 TXT (EXTRACTOR_METATYPE_COMPANY, "National Park Service"), 95 { 0, 0, NULL, NULL, 0, -1 } 96 }; 97 98 /* A real PowerPoint 2007 presentation. */ 99 struct SolutionData msoffice_powerpoint_sol[] = { 100 TXT (EXTRACTOR_METATYPE_MIMETYPE, 101 "application/vnd.openxmlformats-officedocument.presentationml.presentation"), 102 TXT (EXTRACTOR_METATYPE_TITLE, 103 "Assessment of Implantable Monitoring of Heart Failure Patients"), 104 TXT (EXTRACTOR_METATYPE_CREATOR, "irms"), 105 TXT (EXTRACTOR_METATYPE_LAST_SAVED_BY, "vhapalsahaya"), 106 TXT (EXTRACTOR_METATYPE_REVISION_NUMBER, "15"), 107 TXT (EXTRACTOR_METATYPE_CREATION_DATE, "2007-04-25T02:29:26Z"), 108 TXT (EXTRACTOR_METATYPE_MODIFICATION_DATE, "2007-11-01T22:43:05Z"), 109 TXT (EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, "Microsoft PowerPoint"), 110 TXT (EXTRACTOR_METATYPE_SOFTWARE_VERSION, "12.0000"), 111 TXT (EXTRACTOR_METATYPE_COMPANY, "SFVAMC"), 112 TXT (EXTRACTOR_METATYPE_TOTAL_EDITING_TIME, "70"), 113 TXT (EXTRACTOR_METATYPE_WORD_COUNT, "827"), 114 TXT (EXTRACTOR_METATYPE_PARAGRAPH_COUNT, "84"), 115 { 0, 0, NULL, NULL, 0, -1 } 116 }; 117 118 /* A bare BIFF stream, as written before Excel used OLE2 containers. 119 The only meta data such a file has is the user name in the 120 WRITEACCESS record of its File Protection Block -- which is 121 exactly the record that https://bugs.gnunet.org/view.php?id=2096 122 asks for. */ 123 struct SolutionData msoffice_biff4_sol[] = { 124 TXT (EXTRACTOR_METATYPE_LAST_SAVED_BY, "FCC"), 125 TXT (EXTRACTOR_METATYPE_MIMETYPE, "application/vnd.ms-excel"), 126 { 0, 0, NULL, NULL, 0, -1 } 127 }; 128 129 /* A synthetic document exercising the parts that identify people: 130 the "send for review" custom properties Outlook leaves behind, a 131 comment, tracked changes by two different authors and the Word 132 2013 "people" part that ties an author name to a directory 133 identity. */ 134 struct SolutionData msoffice_review_sol[] = { 135 TXT (EXTRACTOR_METATYPE_MIMETYPE, 136 "application/vnd.openxmlformats-officedocument.wordprocessingml.document"), 137 TXT (EXTRACTOR_METATYPE_TITLE, "Quarterly Report & Review"), 138 TXT (EXTRACTOR_METATYPE_CREATOR, "Jane Doe"), 139 TXT (EXTRACTOR_METATYPE_LAST_SAVED_BY, "Richard Roe"), 140 TXT (EXTRACTOR_METATYPE_REVISION_NUMBER, "7"), 141 TXT (EXTRACTOR_METATYPE_CREATION_DATE, "2026-03-04T09:00:00Z"), 142 TXT (EXTRACTOR_METATYPE_MODIFICATION_DATE, "2026-03-05T11:45:00Z"), 143 TXT (EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, "Microsoft Office Word"), 144 TXT (EXTRACTOR_METATYPE_SOFTWARE_VERSION, "16.0000"), 145 TXT (EXTRACTOR_METATYPE_COMPANY, "Example Organisation"), 146 TXT (EXTRACTOR_METATYPE_TOTAL_EDITING_TIME, "42"), 147 TXT (EXTRACTOR_METATYPE_AUTHOR_EMAIL, "jane.doe@example.com"), 148 TXT (EXTRACTOR_METATYPE_AUTHOR_NAME, "Jane Doe"), 149 TXT (EXTRACTOR_METATYPE_SUBJECT, "Draft for review"), 150 TXT (EXTRACTOR_METATYPE_CONTRIBUTOR_NAME, "Jane Doe"), 151 TXT (EXTRACTOR_METATYPE_CONTRIBUTOR_NAME, "Richard Roe"), 152 TXT (EXTRACTOR_METATYPE_REVISION_HISTORY, 153 "Author `Jane Doe' edited the document on `2026-03-04T09:15:00Z'"), 154 TXT (EXTRACTOR_METATYPE_REVISION_HISTORY, 155 "Author `Richard Roe' edited the document on `2026-03-05T11:42:00Z'"), 156 TXT (EXTRACTOR_METATYPE_REVISION_HISTORY, 157 "Author `Richard Roe' edited the document on `2026-03-05T11:40:00Z'"), 158 TXT (EXTRACTOR_METATYPE_CONTACT_INFORMATION, "richard.roe@example.com"), 159 TXT (EXTRACTOR_METATYPE_CONTACT_INFORMATION, 160 "S-1-5-21-1004336348-1177238915-682003330-512"), 161 { 0, 0, NULL, NULL, 0, -1 } 162 }; 163 164 /* A synthetic workbook exercising the Excel side: the modern 165 equivalent of the FILESHARING record, the classic cell comment 166 author list, the threaded comment "persons" part and the shared 167 workbook revision log. */ 168 struct SolutionData msoffice_shared_sol[] = { 169 TXT (EXTRACTOR_METATYPE_MIMETYPE, 170 "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"), 171 TXT (EXTRACTOR_METATYPE_CREATOR, "Ada Lovelace"), 172 TXT (EXTRACTOR_METATYPE_LAST_SAVED_BY, "Grace Hopper"), 173 TXT (EXTRACTOR_METATYPE_CREATION_DATE, "2026-02-17T08:29:00Z"), 174 TXT (EXTRACTOR_METATYPE_MODIFICATION_DATE, "2026-02-18T14:06:00Z"), 175 TXT (EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, "Microsoft Excel"), 176 TXT (EXTRACTOR_METATYPE_SOFTWARE_VERSION, "16.0300"), 177 TXT (EXTRACTOR_METATYPE_COMPANY, "Example Organisation"), 178 TXT (EXTRACTOR_METATYPE_CONTRIBUTOR_NAME, "Sam Poe"), 179 TXT (EXTRACTOR_METATYPE_CONTRIBUTOR_NAME, "Ada Lovelace"), 180 TXT (EXTRACTOR_METATYPE_CONTRIBUTOR_NAME, "Grace Hopper"), 181 TXT (EXTRACTOR_METATYPE_CONTACT_INFORMATION, "grace.hopper@example.com"), 182 TXT (EXTRACTOR_METATYPE_REVISION_HISTORY, 183 "Author `Ada Lovelace' edited the document on `2026-02-17T08:30:11'"), 184 TXT (EXTRACTOR_METATYPE_REVISION_HISTORY, 185 "Author `Grace Hopper' edited the document on `2026-02-18T14:05:47'"), 186 { 0, 0, NULL, NULL, 0, -1 } 187 }; 188 189 struct ProblemSet ps[] = { 190 { "testdata/msoffice_word.docx", 191 msoffice_word_sol }, 192 { "testdata/msoffice_excel.xlsx", 193 msoffice_excel_sol }, 194 { "testdata/msoffice_powerpoint.pptx", 195 msoffice_powerpoint_sol }, 196 #if HAVE_ICONV 197 { "testdata/msoffice_biff4.xls", 198 msoffice_biff4_sol }, 199 #endif 200 { "testdata/msoffice_review.docx", 201 msoffice_review_sol }, 202 { "testdata/msoffice_shared.xlsx", 203 msoffice_shared_sol }, 204 { NULL, NULL } 205 }; 206 return ET_main ("msoffice", ps); 207 } 208 209 210 /* end of test_msoffice.c */