(self)
return sorted(
            self.iocs.values(), key=self._parse_date, reverse=True
        )
Run analysis.
        @return: MISP results dict.
Run analysis.
Run analysis .
def run(self):
        """Run analysis.
        @return: MISP results dict.
        """
        self.url = self.options.get("url", "")
        self.apikey = self.options.get("apikey", "")
        maxioc = int(self.options.get("maxioc", 100))

        if not self.url or not self.apikey:
            raise CuckooProcessingError(
                "Please configure the URL and API key for your MISP instance."
            )

        self.key = "misp"
        self.iocs = {}

        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            import pymisp

        self.misp = pymisp.PyMISP(self.url, self.apikey, False, "json")
        iocs = set()

        iocs.add(self.results.get("target", {}).get("file", {}).get("md5"))

        for dropped in self.results.get("dropped", []):
            if not dropped.get("type"):
                continue
            if dropped["type"].startswith(self.file_types):
                iocs.add(dropped.get("md5"))

        iocs.update(self.results.get("network", {}).get("hosts", []))

        for block in self.results.get("network", {}).get("domains", []):
            iocs.add(block.get("ip"))
            iocs.add(block.get("domain"))

        # Remove empty entries and turn the collection into a list.
        iocs = list(iocs.difference((None, "")))

        # Acquire all information related to IOCs.
        for ioc in iocs[:maxioc]:
            self.search_ioc(ioc)

        # Sort IOC information by date and return all information.
        return sorted(
            self.iocs.values(), key=self._parse_date, reverse=True
        )
def run ( self ) : self . url = self . options . get ( "url" , "" ) self . apikey = self . options . get ( "apikey" , "" ) maxioc = int ( self . options . get ( "maxioc" , 100 ) ) if not self . url or not self . apikey : raise CuckooProcessingError ( "Please configure the URL and API key for your MISP instance." ) self . key = "misp" self . iocs = { } with warnings . catch_warnings ( ) : warnings . simplefilter ( "ignore" ) import pymisp self . misp = pymisp . PyMISP ( self . url , self . apikey , False , "json" ) iocs = set ( ) iocs . add ( self . results . get ( "target" , { } ) . get ( "file" , { } ) . get ( "md5" ) ) for dropped in self . results . get ( "dropped" , [ ] ) : if not dropped . get ( "type" ) : continue if dropped [ "type" ] . startswith ( self . file_types ) : iocs . add ( dropped . get ( "md5" ) ) iocs . update ( self . results . get ( "network" , { } ) . get ( "hosts" , [ ] ) ) for block in self . results . get ( "network" , { } ) . get ( "domains" , [ ] ) : iocs . add ( block . get ( "ip" ) ) iocs . add ( block . get ( "domain" ) ) # Remove empty entries and turn the collection into a list. iocs = list ( iocs . difference ( ( None , "" ) ) ) # Acquire all information related to IOCs. for ioc in iocs [ : maxioc ] : self . search_ioc ( ioc ) # Sort IOC information by date and return all information. return sorted ( self . iocs . values ( ) , key = self . _parse_date , reverse = True )