How to use the rc-cts.rc_cts.components.threat_webservice.ThreatLookupIncompleteException function in rc-cts

To help you get started, we’ve selected a few rc-cts examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ibmresilient / resilient-community-apps / rc-cts / rc_cts / components / threat_webservice.py View on Github external
# the results can be a single value (dict), or an array, or None,
        # or an exception, or a tuple (type, exception, traceback)
        hits = []
        complete = True
        if isinstance(results, list):
            for result in results:
                if result:
                    if isinstance(result, (tuple, ThreatLookupIncompleteException)):
                        LOG.info("Retry later!")
                        complete = False
                    elif isinstance(result, (tuple, Exception)):
                        LOG.error("No hits due to exception")
                    else:
                        hits.append(result)
        elif results:
            if isinstance(results, (tuple, ThreatLookupIncompleteException)):
                LOG.info("Retry later!")
                complete = False
            elif isinstance(results, (tuple, Exception)):
                LOG.error("No hits due to exception")
            else:
                hits.append(results)

        # Store the result and mark as complete (or not)
        cache_key = (cts_channel, request_id)
        self.cache[cache_key] = {"id": request_id, "artifact": artifact, "hits": hits, "complete": complete}