本文整理汇总了Python中crits.targets.target.Target.email_address方法的典型用法代码示例。如果您正苦于以下问题:Python Target.email_address方法的具体用法?Python Target.email_address怎么用?Python Target.email_address使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类crits.targets.target.Target
的用法示例。
在下文中一共展示了Target.email_address方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: upsert_target
# 需要导入模块: from crits.targets.target import Target [as 别名]
# 或者: from crits.targets.target.Target import email_address [as 别名]
def upsert_target(data, analyst):
"""
Add/update target information.
:param data: The target information.
:type data: dict
:param analyst: The user adding the target.
:type analyst: str
:returns: dict with keys "success" (boolean) and "message" (str)
"""
if 'email_address' not in data:
return {'success': False,
'message': "No email address to look up"}
target = Target.objects(email_address__iexact=data['email_address']).first()
is_new = False
if not target:
is_new = True
target = Target()
target.email_address = data['email_address']
bucket_list = False
ticket = False
if 'department' in data:
target.department = data['department']
if 'division' in data:
target.division = data['division']
if 'organization_id' in data:
target.organization_id = data['organization_id']
if 'firstname' in data:
target.firstname = data['firstname']
if 'lastname' in data:
target.lastname = data['lastname']
if 'note' in data:
target.note = data['note']
if 'title' in data:
target.title = data['title']
if 'bucket_list' in data:
bucket_list = data.get(form_consts.Common.BUCKET_LIST_VARIABLE_NAME)
if 'ticket' in data:
ticket = data.get(form_consts.Common.TICKET_VARIABLE_NAME)
if bucket_list:
target.add_bucket_list(bucket_list, analyst)
if ticket:
target.add_ticket(ticket, analyst)
try:
target.save(username=analyst)
target.reload()
if is_new:
run_triage(target, analyst)
return {'success': True,
'message': "Target saved successfully",
'id': str(target.id)}
except ValidationError, e:
return {'success': False,
'message': "Target save failed: %s" % e}
示例2: target_user_stats
# 需要导入模块: from crits.targets.target import Target [as 别名]
# 或者: from crits.targets.target.Target import email_address [as 别名]
def target_user_stats():
"""
Generate targets from email To/CC fields, then generate divisions from
targets list.
No cleanup or logic is being done on the To/CC fields. If they are not
valid email addresses ([email protected]), they do not get added as a target.
"""
mapcode = """
function () {
try {
this.to.forEach(function(z) {
emit(z, {count: 1});
});
} catch(err) {}
}
"""
reducecode = """
function(k,v) {
var count = 0;
v.forEach(function(v) {
count += v["count"];
});
return {count: count};
}
"""
m = Code(mapcode)
r = Code(reducecode)
results = Email.objects(to__exists=True).map_reduce(m, r, 'inline')
for result in results:
try:
targ = Target.objects(email_address__iexact=result.key).first()
if not targ:
targ = Target()
targ.email_address = result.key
targ.email_count = result.value['count']
targ.save()
except:
pass
mapcode = """
function() {
if ("division" in this) {
emit(this.division, {count: this.email_count})
}
}
"""
m = Code(mapcode)
try:
results = Target.objects().map_reduce(m, r, 'inline')
for result in results:
div = Division.objects(division__iexact=result.key).first()
if not div:
div = Division()
div.division = result.key
div.email_count = result.value['count']
div.save()
except:
raise
示例3: upsert_target
# 需要导入模块: from crits.targets.target import Target [as 别名]
# 或者: from crits.targets.target.Target import email_address [as 别名]
def upsert_target(data, analyst):
"""
Add/update target information.
:param data: The target information.
:type data: dict
:param analyst: The user adding the target.
:type analyst: str
:returns: dict with keys "success" (boolean) and "message" (str)
"""
if "email_address" not in data:
return {"success": False, "message": "No email address to look up"}
target = Target.objects(email_address=data["email_address"]).first()
if not target:
target = Target()
target.email_address = data["email_address"]
target.department = data["department"]
target.division = data["division"]
target.organization_id = data["organization_id"]
target.firstname = data["firstname"]
target.lastname = data["lastname"]
target.note = data["note"]
target.title = data["title"]
bucket_list = data.get(form_consts.Common.BUCKET_LIST_VARIABLE_NAME)
ticket = data.get(form_consts.Common.TICKET_VARIABLE_NAME)
if bucket_list:
target.add_bucket_list(bucket_list, analyst)
if ticket:
target.add_ticket(ticket, analyst)
try:
target.save(username=analyst)
target.reload()
return {"success": True, "message": "Target saved successfully", "id": str(target.id)}
except ValidationError, e:
return {"success": False, "message": "Target save failed: %s" % e}
示例4: upsert_target
# 需要导入模块: from crits.targets.target import Target [as 别名]
# 或者: from crits.targets.target.Target import email_address [as 别名]
def upsert_target(data, analyst):
"""
Add/update target information.
:param data: The target information.
:type data: dict
:param analyst: The user adding the target.
:type analyst: str
:returns: dict with keys "success" (boolean) and "message" (str)
"""
if 'email_address' not in data:
return {'success': False,
'message': "No email address to look up"}
# check for exact match first
target = Target.objects(email_address=data['email_address']).first()
if not target: # if no exact match, look for case-insensitive match
target = Target.objects(email_address__iexact=data['email_address']).first()
is_new = False
if not target:
is_new = True
target = Target()
target.email_address = data['email_address'].strip().lower()
bucket_list = False
ticket = False
if 'department' in data:
target.department = data['department']
if 'division' in data:
target.division = data['division']
if 'organization_id' in data:
target.organization_id = data['organization_id']
if 'firstname' in data:
target.firstname = data['firstname']
if 'lastname' in data:
target.lastname = data['lastname']
if 'note' in data:
target.note = data['note']
if 'title' in data:
target.title = data['title']
if 'campaign' in data and 'camp_conf' in data:
target.add_campaign(EmbeddedCampaign(name=data['campaign'],
confidence=data['camp_conf'],
analyst=analyst))
if 'bucket_list' in data:
bucket_list = data.get(form_consts.Common.BUCKET_LIST_VARIABLE_NAME)
if 'ticket' in data:
ticket = data.get(form_consts.Common.TICKET_VARIABLE_NAME)
if 'related_id' in data:
related_id = data['related_id']
if 'related_type' in data:
related_type = data['related_type']
if 'relationship_type' in data:
relationship_type = data['relationship_type']
if bucket_list:
target.add_bucket_list(bucket_list, analyst)
if ticket:
target.add_ticket(ticket, analyst)
related_obj = None
if related_id:
related_obj = class_from_id(related_type, related_id)
if not related_obj:
retVal['success'] = False
retVal['message'] = 'Related Object not found.'
return retVal
try:
target.save(username=analyst)
if related_obj and target:
relationship_type=RelationshipTypes.inverse(relationship=relationship_type)
target.add_relationship(related_obj,
relationship_type,
analyst=analyst,
get_rels=False)
target.save(username=analyst)
target.reload()
if is_new:
run_triage(target, analyst)
return {'success': True,
'message': "Target saved successfully",
'id': str(target.id)}
except ValidationError, e:
return {'success': False,
'message': "Target save failed: %s" % e}
示例5: get_target_details
# 需要导入模块: from crits.targets.target import Target [as 别名]
# 或者: from crits.targets.target.Target import email_address [as 别名]
def get_target_details(email_address, analyst):
"""
Generate the data to render the Target details template.
:param email_address: The email address of the target.
:type email_address: str
:param analyst: The user requesting this information.
:type analyst: str
:returns: template (str), arguments (dict)
"""
template = None
if not email_address:
template = "error.html"
args = {'error': "Must provide an email address."}
return template, args
# check for exact match first
target = Target.objects(email_address=email_address).first()
if not target: # if no exact match, look for case-insensitive match
target = Target.objects(email_address__iexact=email_address).first()
if not target:
target = Target()
target.email_address = email_address.strip().lower()
form = TargetInfoForm(initial={'email_address': email_address})
email_list = target.find_emails(analyst)
form = TargetInfoForm(initial=target.to_dict())
if form.fields.get(form_consts.Common.BUCKET_LIST_VARIABLE_NAME) != None:
form.fields.pop(form_consts.Common.BUCKET_LIST_VARIABLE_NAME)
if form.fields.get(form_consts.Common.TICKET_VARIABLE_NAME) != None:
form.fields.pop(form_consts.Common.TICKET_VARIABLE_NAME)
subscription = {
'type': 'Target',
'id': target.id,
'subscribed': is_user_subscribed("%s" % analyst,
'Target',
target.id)
}
#objects
objects = target.sort_objects()
#relationships
relationships = target.sort_relationships("%s" % analyst,
meta=True)
# relationship
relationship = {
'type': 'Target',
'value': target.id
}
#comments
if target.id:
comments = {'comments': target.get_comments(),
'url_key': email_address}
else:
comments = {'comments': [],
'url_key': email_address}
#screenshots
screenshots = target.get_screenshots(analyst)
# favorites
favorite = is_user_favorite("%s" % analyst, 'Target', target.id)
# analysis results
service_results = target.get_analysis_results()
args = {'objects': objects,
'relationships': relationships,
'relationship': relationship,
'comments': comments,
'favorite': favorite,
'subscription': subscription,
'screenshots': screenshots,
'email_list': email_list,
'target_detail': target,
'service_results': service_results,
'form': form}
return template, args
示例6: get_target_details
# 需要导入模块: from crits.targets.target import Target [as 别名]
# 或者: from crits.targets.target.Target import email_address [as 别名]
def get_target_details(email_address, analyst):
"""
Generate the data to render the Target details template.
:param email_address: The email address of the target.
:type email_address: str
:param analyst: The user requesting this information.
:type analyst: str
:returns: template (str), arguments (dict)
"""
template = None
if not email_address:
template = "error.html"
args = {"error": "Must provide an email address."}
return template, args
target = Target.objects(email_address=email_address).first()
if not target:
target = Target()
target.email_address = email_address
form = TargetInfoForm(initial={"email_address": email_address})
email_list = target.find_emails(analyst)
# initial_data = target.to_dict()
# initial_data['bucket_list'] = target.get_bucket_list_string();
form = TargetInfoForm(initial=target.to_dict())
if form.fields.get(form_consts.Common.BUCKET_LIST_VARIABLE_NAME) != None:
form.fields.pop(form_consts.Common.BUCKET_LIST_VARIABLE_NAME)
if form.fields.get(form_consts.Common.TICKET_VARIABLE_NAME) != None:
form.fields.pop(form_consts.Common.TICKET_VARIABLE_NAME)
subscription = {
"type": "Target",
"id": target.id,
"subscribed": is_user_subscribed("%s" % analyst, "Target", target.id),
}
# objects
objects = target.sort_objects()
# relationships
relationships = target.sort_relationships("%s" % analyst, meta=True)
# relationship
relationship = {"type": "Target", "value": target.id}
# comments
if target.id:
comments = {"comments": target.get_comments(), "url_key": email_address}
else:
comments = {"comments": [], "url_key": email_address}
# screenshots
screenshots = target.get_screenshots(analyst)
# favorites
favorite = is_user_favorite("%s" % analyst, "Target", target.id)
args = {
"objects": objects,
"relationships": relationships,
"relationship": relationship,
"comments": comments,
"favorite": favorite,
"subscription": subscription,
"screenshots": screenshots,
"email_list": email_list,
"target_detail": target,
"form": form,
}
return template, args