protected void FromFile(POIDataSamples dataSamples, String filename) { FileInfo f = dataSamples.GetFileInfo(filename); VBAMacroReader r = new VBAMacroReader(f); try { AssertMacroContents(dataSamples, r); } finally { r.Close(); } }
public void Bug59830() { // This file is intentionally omitted from the test-data directory // unless we can extract the vbaProject.bin from this Word 97-2003 file // so that it's less likely to be opened and executed on a Windows computer. // The file is attached to bug 59830. // The Macro Virus only affects Windows computers, as it Makes a // subprocess call to powershell.exe with an encoded payload // The document Contains macros that execute on workbook open if macros // are enabled FileInfo doc = POIDataSamples.GetDocumentInstance().GetFileInfo("macro_virus.doc.do_not_open"); VBAMacroReader Reader = new VBAMacroReader(doc); Dictionary <String, String> macros = Reader.ReadMacros(); Assert.IsNotNull(macros); Reader.Close(); }
protected void FromStream(POIDataSamples dataSamples, String filename) { InputStream fis = new FileInputStream(dataSamples.OpenResourceAsStream(filename)); try { VBAMacroReader r = new VBAMacroReader(fis); try { AssertMacroContents(dataSamples, r); } finally { r.Close(); } } finally { fis.Close(); } }
protected void FromNPOIFS(POIDataSamples dataSamples, String filename) { FileInfo f = dataSamples.GetFileInfo(filename); NPOIFSFileSystem fs = new NPOIFSFileSystem(f); try { VBAMacroReader r = new VBAMacroReader(fs); try { AssertMacroContents(dataSamples, r); } finally { r.Close(); } } finally { fs.Close(); } }