This adds a check for malware spoofing of RFC 822 mailbox addresses such as those found in Mailsploit, and if found only displays the email address part and not the mailbox name part. Part 1 of Mailsploit mitigation. * src/engine/rfc822/rfc822-mailbox-address.vala (MailboxAddress): Add new is_spoofed method to check if the mailbox address looks like it has been spoofed. Add is_distinct method to determine if the name and the label is the same. Do whitespace and non-printing character stripping when generating display versions of the mailbox address, rename methods to make it more obvious what they do and update call sites. Add unit tests to cover all this. * src/client/conversation-viewer/conversation-message.vala (ConversationMessage): Check name is distinct and is not valid before displaying it. Use new MailboxAddress methods for getting display versions of the address, to ensure we get the stripped versions of the addresses. * src/client/conversation-list/formatted-conversation-data.vala (ParticipantDisplay): Ensure full addresses are always HTML-markup escaped before displaying them as markup, to avoid dropping "<address>" values as invalid HTML. Always show the full address if an address is invalid. * src/engine/util/util-string.vala (reduce_whitespace): Strip not only whitespace but also non-printing characters. Add unit tests.
62 lines
2 KiB
Vala
62 lines
2 KiB
Vala
/*
|
|
* Copyright 2016-2017 Michael Gratton <mike@vee.net>
|
|
*
|
|
* This software is licensed under the GNU Lesser General Public License
|
|
* (version 2.1 or later). See the COPYING file in this distribution.
|
|
*/
|
|
|
|
int main(string[] args) {
|
|
/*
|
|
* Initialise all the things.
|
|
*/
|
|
|
|
Test.init(ref args);
|
|
|
|
Geary.RFC822.init();
|
|
Geary.HTML.init();
|
|
Geary.Logging.init();
|
|
|
|
/*
|
|
* Hook up all tests into appropriate suites
|
|
*/
|
|
|
|
TestSuite engine = new TestSuite("engine");
|
|
|
|
engine.add_suite(new Geary.AttachmentTest().get_suite());
|
|
engine.add_suite(new Geary.EngineTest().get_suite());
|
|
engine.add_suite(new Geary.IdleManagerTest().get_suite());
|
|
engine.add_suite(new Geary.TimeoutManagerTest().get_suite());
|
|
engine.add_suite(new Geary.App.ConversationTest().get_suite());
|
|
engine.add_suite(new Geary.App.ConversationSetTest().get_suite());
|
|
engine.add_suite(new Geary.HTML.UtilTest().get_suite());
|
|
engine.add_suite(new Geary.Imap.DeserializerTest().get_suite());
|
|
engine.add_suite(new Geary.Imap.CreateCommandTest().get_suite());
|
|
engine.add_suite(new Geary.Imap.NamespaceResponseTest().get_suite());
|
|
engine.add_suite(new Geary.ImapEngine.AccountProcessorTest().get_suite());
|
|
engine.add_suite(new Geary.Inet.Test().get_suite());
|
|
engine.add_suite(new Geary.JS.Test().get_suite());
|
|
engine.add_suite(new Geary.Mime.ContentTypeTest().get_suite());
|
|
engine.add_suite(new Geary.RFC822.MailboxAddressTest().get_suite());
|
|
engine.add_suite(new Geary.RFC822.MessageTest().get_suite());
|
|
engine.add_suite(new Geary.RFC822.MessageDataTest().get_suite());
|
|
engine.add_suite(new Geary.RFC822.Utils.Test().get_suite());
|
|
engine.add_suite(new Geary.String.Test().get_suite());
|
|
|
|
/*
|
|
* Run the tests
|
|
*/
|
|
TestSuite root = TestSuite.get_root();
|
|
root.add_suite(engine);
|
|
|
|
MainLoop loop = new MainLoop ();
|
|
|
|
int ret = -1;
|
|
Idle.add(() => {
|
|
ret = Test.run();
|
|
loop.quit();
|
|
return false;
|
|
});
|
|
|
|
loop.run();
|
|
return ret;
|
|
}
|