本文整理汇总了Python中crits.vocabulary.relationships.RelationshipTypes.values方法的典型用法代码示例。如果您正苦于以下问题:Python RelationshipTypes.values方法的具体用法?Python RelationshipTypes.values怎么用?Python RelationshipTypes.values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类crits.vocabulary.relationships.RelationshipTypes
的用法示例。
在下文中一共展示了RelationshipTypes.values方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_relationship_type_dropdown
# 需要导入模块: from crits.vocabulary.relationships import RelationshipTypes [as 别名]
# 或者: from crits.vocabulary.relationships.RelationshipTypes import values [as 别名]
def get_relationship_type_dropdown(request):
"""
Get relationship type dropdown data. Should be an AJAX POST.
:param request: Django request object (Required)
:type request: :class:`django.http.HttpRequest`
:returns: :class:`django.http.HttpResponse`
"""
if request.method == 'POST':
if request.is_ajax():
dd_final = {}
for type_ in RelationshipTypes.values(sort=True):
dd_final[type_] = type_
result = {'types': dd_final}
return HttpResponse(json.dumps(result), mimetype="application/json")
else:
error = "Expected AJAX"
return render_to_response("error.html",
{"error" : error },
RequestContext(request))
else:
error = "Expected POST"
return render_to_response("error.html",
{"error" : error },
RequestContext(request))
示例2: add_new_relationship
# 需要导入模块: from crits.vocabulary.relationships import RelationshipTypes [as 别名]
# 或者: from crits.vocabulary.relationships.RelationshipTypes import values [as 别名]
def add_new_relationship(request):
"""
Add a new relationship. Should be an AJAX POST.
:param request: Django request object (Required)
:type request: :class:`django.http.HttpRequest`
:returns: :class:`django.http.HttpResponse`
"""
if request.method == 'POST' and request.is_ajax():
form = ForgeRelationshipForm(request.POST)
user = request.user
choices = [(c,c) for c in RelationshipTypes.values(sort=True)]
form.fields['forward_relationship'].choices = choices
if form.is_valid():
cleaned_data = form.cleaned_data
# Get user permission to verify the user can forge relationships...
# Should we check permission on both the forward and reverse TLO for this?
acl = get_acl_object(cleaned_data.get('forward_type'))
if user.has_access_to(acl.RELATIONSHIPS_ADD):
results = forge_relationship(type_=cleaned_data.get('forward_type'),
id_=cleaned_data.get('forward_value'),
right_type=cleaned_data.get('reverse_type'),
right_id=cleaned_data.get('dest_id'),
rel_type=cleaned_data.get('forward_relationship'),
rel_date=cleaned_data.get('relationship_date'),
user=request.user.username,
rel_reason=cleaned_data.get('rel_reason'),
rel_confidence=cleaned_data.get('rel_confidence'),
get_rels=True)
else:
results = {"success":False,
"message":"User does not have permission to forge relationships"}
if results['success'] == True:
relationship = {'type': cleaned_data.get('forward_type'),
'value': cleaned_data.get('forward_value')}
message = render_to_string('relationships_listing_widget.html',
{'relationship': relationship,
'nohide': True,
'relationships': results['relationships']},
RequestContext(request))
result = {'success': True, 'message': message}
else:
message = "Error adding relationship: %s" % results['message']
result = {'success': False, 'message': message}
else:
message = "Invalid Form: %s" % form.errors
form = form.as_table()
result = {'success': False, 'form': form, 'message': message}
return HttpResponse(json.dumps(result), content_type="application/json")
else:
error = "Expected AJAX POST"
return render_to_response("error.html",
{"error" : error },
RequestContext(request))
示例3: __init__
# 需要导入模块: from crits.vocabulary.relationships import RelationshipTypes [as 别名]
# 或者: from crits.vocabulary.relationships.RelationshipTypes import values [as 别名]
def __init__(self, *args, **kwargs):
super(ForgeRelationshipForm, self).__init__(*args, **kwargs)
self.fields['forward_type'].choices = self.fields['reverse_type'].choices = [
(c, c) for c in sorted(settings.CRITS_TYPES.iterkeys())
]
self.fields['forward_relationship'].choices = [
(c, c) for c in RelationshipTypes.values(sort=True)
]
self.fields['rel_confidence'].choices = [('unknown', 'unknown'),
('low', 'low'),
('medium', 'medium'),
('high', 'high')]
self.fields['rel_confidence'].initial = 'medium'
示例4: add_new_relationship
# 需要导入模块: from crits.vocabulary.relationships import RelationshipTypes [as 别名]
# 或者: from crits.vocabulary.relationships.RelationshipTypes import values [as 别名]
def add_new_relationship(request):
"""
Add a new relationship. Should be an AJAX POST.
:param request: Django request object (Required)
:type request: :class:`django.http.HttpRequest`
:returns: :class:`django.http.HttpResponse`
"""
if request.method == 'POST' and request.is_ajax():
form = ForgeRelationshipForm(request.POST)
choices = [(c,c) for c in RelationshipTypes.values(sort=True)]
form.fields['forward_relationship'].choices = choices
if form.is_valid():
cleaned_data = form.cleaned_data;
results = forge_relationship(type_=cleaned_data.get('forward_type'),
id_=cleaned_data.get('forward_value'),
right_type=cleaned_data.get('reverse_type'),
right_id=cleaned_data.get('dest_id'),
rel_type=cleaned_data.get('forward_relationship'),
rel_date=cleaned_data.get('relationship_date'),
user=request.user.username,
rel_reason=cleaned_data.get('rel_reason'),
rel_confidence=cleaned_data.get('rel_confidence'),
get_rels=True)
if results['success'] == True:
relationship = {'type': cleaned_data.get('forward_type'),
'value': cleaned_data.get('forward_value')}
message = render_to_string('relationships_listing_widget.html',
{'relationship': relationship,
'nohide': True,
'relationships': results['relationships']},
RequestContext(request))
result = {'success': True, 'message': message}
else:
message = "Error adding relationship: %s" % results['message']
result = {'success': False, 'message': message}
else:
message = "Invalid Form: %s" % form.errors
form = form.as_table()
result = {'success': False, 'form': form, 'message': message}
return HttpResponse(json.dumps(result), mimetype="application/json")
else:
error = "Expected AJAX POST"
return render_to_response("error.html",
{"error" : error },
RequestContext(request))
示例5: TargetInfoForm
# 需要导入模块: from crits.vocabulary.relationships import RelationshipTypes [as 别名]
# 或者: from crits.vocabulary.relationships.RelationshipTypes import values [as 别名]
from django import forms
from django.forms.utils import ErrorList
from crits.campaigns.campaign import Campaign
from crits.core import form_consts
from crits.core.forms import add_bucketlist_to_form, add_ticket_to_form
from crits.core.handlers import get_item_names
from crits.vocabulary.relationships import RelationshipTypes
from crits.vocabulary.acls import Common, TargetACL
relationship_choices = [(c, c) for c in RelationshipTypes.values(sort=True)]
class TargetInfoForm(forms.Form):
"""
Django form for adding/updating target information.
"""
error_css_class = 'error'
required_css_class = 'required'
firstname = forms.CharField(widget=forms.TextInput(attrs={'size': '50'}),
required=False)
lastname = forms.CharField(widget=forms.TextInput(attrs={'size': '50'}),
required=False)
division = forms.CharField(widget=forms.TextInput(attrs={'size': '50'}),
required=False)
department = forms.CharField(widget=forms.TextInput(attrs={'size': '50'}),
required=False)
email_address = forms.CharField(widget=forms.TextInput(attrs={'size': '50'}),
required=True)
organization_id = forms.CharField(widget=forms.TextInput(attrs={'size': '50'}),
示例6: gather_relationships
# 需要导入模块: from crits.vocabulary.relationships import RelationshipTypes [as 别名]
# 或者: from crits.vocabulary.relationships.RelationshipTypes import values [as 别名]
#.........这里部分代码省略.........
tlo_relationships[str(obj_id)][str(rel.object_id)]=str(rel.relationship)
### A bunch of the stuff below here can probably go...
value = getattr(obj, field_dict[obj_type], '')
if obj_type == 'Backdoor':
# Append a version or family
if obj.version == '':
value += " (family)"
else:
value += " (v:%s)" % obj.version
href = reverse('crits.core.views.details', args=(obj_type, obj_id))
if len(types) != 0 and obj_type not in types:
continue
# For every campaign on this object, make a new node in the list.
if 'Campaign' in types and hasattr(obj, 'campaign'):
for i, campaign in enumerate(obj.campaign):
name = "%s" % obj.campaign[i].name
if name not in campaign_cache:
campaign_cache[name] = get_campaign_details(name, user)
(x, campaign_details) = campaign_cache[name]
if 'error' in campaign_details:
continue
campaign_id = str(campaign_details['campaign_detail'].id)
# If this campaign already exists as a node then
# add a relationship to the current object
if campaign_id in obj_graph:
(tnode, source_ids) = obj_graph[campaign_id]
source_ids.append(obj_id)
else:
total = 0
for count in campaign_details['counts'].values():
total += count
campaign = name + " (" + str(total) + ")"
campaign_href = reverse('crits.core.views.details', args=('Campaign', campaign_id))
n = dict(tlo_styles_dict['Campaign'])
n['label'] = campaign
n['url'] = campaign_href
n['type'] = n['group'] = 'Campaign'
n['crits_status'] = 'Analyzed'
n['id'] = campaign_id
nodes.append(n)
obj_graph[campaign_id] = (node_position, [obj_id])
node_position += 1
# n will contain the vis.js-schema data to load into the graph
n = {}
if obj_type in tlo_styles_dict:
n = dict(tlo_styles_dict[obj_type])
n['label'] = '%s' % value
else:
n = {
'label': '%s' % value,
'shape': 'dot'
}
n['url'] = href
n['crits_status'] = obj['status'];
n['id'] = obj_id
n['type'] = n['group'] = obj_type
n['visible'] = True