old_contents: import csv
  import StringIO
  from intelmq.lib.bot import Bot, sys
  from intelmq.lib.event import Event
  from intelmq.bots import utils
  
  class MalwareDomainListParserBot(Bot):
  
      def process(self):
          report = self.receive_message()
  
          if report:
              report = report.strip()
              
              columns = ["source_time", "source_url", "source_ip", "source_reverse_dns", "malware", "__IGNORE__", "source_asn"]
              rows = csv.DictReader(StringIO.StringIO(report), fieldnames = columns)
  
              for row in rows:
                  event = Event()
                  
                  for key, value in row.items():
                      
                      if key is "__IGNORE__":
                          continue
                      
                      if key is "source_time":
                          value = value.replace('_',' ')
                          
                      if key is "malware":
                          value = value.lower()
                          
                      event.add(key, value)
                      
                  event.add('feed', 'malwaredomainslist')
                  event.add('feed_url', 'http://www.malwaredomainlist.com/updatescsv.php')
                  event.add('type', 'malware')    # FIXME
                  
                  event = utils.parse_source_time(event, "source_time")
                  event = utils.generate_observation_time(event, "observation_time")
                  event = utils.generate_reported_fields(event)
                      
                  self.send_message(event)
          self.acknowledge_message()
  
  
  if __name__ == "__main__":
      bot = MalwareDomainListParserBot(sys.argv[1])
      bot.start()
  
new_contents: import csv
  import StringIO
  from intelmq.lib.bot import Bot, sys
  from intelmq.lib.event import Event
  from intelmq.bots import utils
  
  class MalwareDomainListParserBot(Bot):
  
      def process(self):
          report = self.receive_message()
  
          if report:
              report = report.strip()
              
              columns = ["source_time", "source_url", "source_ip", "source_reverse_dns", "malware", "__IGNORE__", "source_asn"]
              rows = csv.DictReader(StringIO.StringIO(report), fieldnames = columns)
  
              for row in rows:
                  event = Event()
                  
                  for key, value in row.items():
                      
                      if key is "__IGNORE__":
                          continue
                      
                      if key is "source_time":
                          value = value.replace('_',' ')
                          value += " UTC"
                          
                      if key is "malware":
                          value = value.lower()
                          
                      event.add(key, value)
                      
                  event.add('feed', 'malwaredomainslist')
                  event.add('feed_url', 'http://www.malwaredomainlist.com/updatescsv.php')
                  event.add('type', 'malware')    # FIXME
                  
                  event = utils.parse_source_time(event, "source_time")
                  event = utils.generate_observation_time(event, "observation_time")
                  event = utils.generate_reported_fields(event)
                      
                  self.send_message(event)
          self.acknowledge_message()
  
  
  if __name__ == "__main__":
      bot = MalwareDomainListParserBot(sys.argv[1])
      bot.start()
  
subject: Update parser.py