diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-09-30 16:12:52 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-09-30 17:02:37 +0100 |
commit | e898bcc1c2f2d227d8b638dfbee01e393562e142 (patch) | |
tree | 2a796ad9111f030fa55050cb7c65530a67b623a6 /test | |
parent | 8c0a791b74005765b99a8d7bd6e2b5d2f998b7f3 (diff) |
silence tedious malware checkers, arcfour, key 0x435645
Diffstat (limited to 'test')
-rw-r--r-- | test/inc/test/filters-test.hxx | 8 | ||||
-rw-r--r-- | test/source/filters-test.cxx | 51 |
2 files changed, 57 insertions, 2 deletions
diff --git a/test/inc/test/filters-test.hxx b/test/inc/test/filters-test.hxx index 721f44227177..6c82944d1cac 100644 --- a/test/inc/test/filters-test.hxx +++ b/test/inc/test/filters-test.hxx @@ -40,8 +40,14 @@ enum filterStatus indeterminate = 2 }; +/* + * NOTE, any files beginning with CVE- will be assumed to be encrypted using + * arcfour with key 0x435645, this is just to silence panicky + * virus/malware-checkers + * + * e.g. m[de]crypt --bare -a arcfour -o hex -k 435645 -s 3 + */ /* Implementation of Filters test */ - class OOO_DLLPUBLIC_TEST FiltersTest : public test::BootstrapFixture { public: diff --git a/test/source/filters-test.cxx b/test/source/filters-test.cxx index aeb92d9727f4..aa6fe316b905 100644 --- a/test/source/filters-test.cxx +++ b/test/source/filters-test.cxx @@ -30,11 +30,47 @@ #include <test/filters-test.hxx> #include <osl/file.hxx> #include <osl/thread.h> +#include <rtl/cipher.h> using namespace ::com::sun::star; namespace test { +void decode(const rtl::OUString& rIn, const rtl::OUString &rOut) +{ + rtlCipher cipher = rtl_cipher_create(rtl_Cipher_AlgorithmARCFOUR, rtl_Cipher_ModeStream); + CPPUNIT_ASSERT_MESSAGE("cipher creation failed", cipher != 0); + + //mcrypt --bare -a arcfour -o hex -k 435645 -s 3 + const sal_uInt8 aKey[3] = {'C', 'V', 'E'}; + + rtlCipherError result = rtl_cipher_init(cipher, rtl_Cipher_DirectionDecode, aKey, SAL_N_ELEMENTS(aKey), 0, 0); + + CPPUNIT_ASSERT_MESSAGE("cipher init failed", result == rtl_Cipher_E_None); + + osl::File aIn(rIn); + CPPUNIT_ASSERT(osl::FileBase::E_None == aIn.open(osl_File_OpenFlag_Read)); + + osl::File aOut(rOut); + CPPUNIT_ASSERT(osl::FileBase::E_None == aOut.open(osl_File_OpenFlag_Write)); + + fprintf(stderr, "rOut is %s\n", rtl::OUStringToOString(rOut, RTL_TEXTENCODING_UTF8).getStr()); + + sal_uInt8 in[8192]; + sal_uInt8 out[8192]; + sal_uInt64 nBytesRead, nBytesWritten; + do + { + CPPUNIT_ASSERT(osl::FileBase::E_None == aIn.read(in, sizeof(in), nBytesRead)); + CPPUNIT_ASSERT(rtl_Cipher_E_None == rtl_cipher_decode(cipher, in, nBytesRead, out, sizeof(out))); + CPPUNIT_ASSERT(osl::FileBase::E_None == aOut.write(out, nBytesRead, nBytesWritten)); + CPPUNIT_ASSERT(nBytesRead == nBytesWritten); + } + while (nBytesRead == sizeof(in)); + + rtl_cipher_destroy(cipher); +} + void FiltersTest::recursiveScan(const rtl::OUString &rFilter, const rtl::OUString &rURL, const rtl::OUString &rUserData, filterStatus nExpected) { @@ -51,7 +87,8 @@ void FiltersTest::recursiveScan(const rtl::OUString &rFilter, const rtl::OUStrin recursiveScan(rFilter, sURL, rUserData, nExpected); else { - rtl::OUString aTmpFile; + rtl::OUString sTmpFile; + bool bCVE = false; sal_Int32 nLastSlash = sURL.lastIndexOf('/'); @@ -62,11 +99,23 @@ void FiltersTest::recursiveScan(const rtl::OUString &rFilter, const rtl::OUStrin { continue; } + + if (sURL.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("CVE")), nLastSlash+1) + bCVE = true; } rtl::OString aRes(rtl::OUStringToOString(sURL, osl_getThreadTextEncoding())); + if (bCVE) + { + osl::FileBase::RC err = osl::FileBase::createTempFile(NULL, NULL, &sTmpFile); + CPPUNIT_ASSERT_MESSAGE("temp File creation failed", + err == osl::FileBase::E_None); + decode(sURL, sTmpFile); + sURL = sTmpFile; + } + //output name early, so in the case of a hang, the name of //the hanging input file is visible if (nExpected == test::indeterminate) |