How to use the threatexchange.handlers function in threatexchange

To help you get started, we’ve selected a few threatexchange 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 crits / crits_services / threatexchange / views.py View on Github external
id_ = request.POST.get('id', None)
        related_type = request.POST.get('related_type', None)
        td = {
            'descriptors': "Threat Descriptors",
            'dropped': "Malware Analyses",
            'dropped_by': "Malware Analyses",
            'families': "Malware Families",
            'related': "Threat Indicators",
            'similar_malware': "Malware Analyses",
            'threat_indicators': "Threat Indicators",
            'variants': "Malware Analyses"
        }
        type_ = td.get(related_type, None)
        if id_ and related_type and type_:
            url = tx.URL + tx.VERSION + id_ + '/' + related_type + '/'
            results = handlers.submit_query(request, url, type_)
            return HttpResponse(json.dumps(results),
                                content_type="application/json")
        else:
            return HttpResponse({'success': False,
                                 'message': "Need ID and valid related type."},
                                content_type="application/json")
    else:
        return render_to_response('error.html',
                                  {'error': "Must be AJAX."},
                                  RequestContext(request))