Download SECURITY ALERTS COLLECTING SYSTEM (SYRAS)
Transcript
61 o Import feedparser: a module for parsing the atom entries. In this case, it is used for accessing the new entries because the gmail inbox is accessed and parsed as rss. [38] o Import urllib :a module for handling and accessing URLs. [39] o Import imaplib: a module for handling IMAP protocol that allows handling email requests. [40] GMAIL_ATOM_URL is a constant that stores the URL to access gmail accounts as atom RSS. As it can be seen in the class definition (class Email_Sources(Sources):) Email_Sources inherits from Sources. gmail_user and gmail_pass are the username and password for the gmail account. In this case they are embedded in the code in plain text because the email does not store any personal information, although it would be more correct to cipher and store them in a safer place. The second thing to point out is the constructor __init__. o It uses an instance of the database as an argument when called. o It uses the superclass creator. The class attributes are inherited from the parent class Sources, adding a new one: feed (representing the inbox parsed as RSS newsfeed using the module feedparser). Next are the new methods introduced by the class and used for performing operations with the email sources. The main objective of this class and its methods is to collect new entries coming from mailing lists. The first thing to point out is that we are using FancyURLopener, that subclasses URLopener providing default handling for 401 response codes (authentication required), performing basic HTTP authentication. The prompt_user_passwd() method was overridden TURKU UNIVERSITY OF APPLIED SCIENCES THESIS | Pablo Molina Martínez