当前位置: 首页>>代码示例>>Python>>正文


Python actor.Actor类代码示例

本文整理汇总了Python中crits.actors.actor.Actor的典型用法代码示例。如果您正苦于以下问题:Python Actor类的具体用法?Python Actor怎么用?Python Actor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Actor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: set_identifier_confidence

def set_identifier_confidence(id_, identifier=None, confidence="low",
                              user=None, **kwargs):
    """
    Set the Identifier attribution confidence.

    :param id_: The ObjectId of the Actor.
    :param identifier: The Actor Identifier ObjectId.
    :type identifier: str
    :param confidence: The confidence level.
    :type confidence: str
    :param user: The user editing this identifier.
    :type user: str
    :returns: dict with keys:
              "success" (boolean),
              "message" (str),
    """

    sources = user_sources(user)
    actor = Actor.objects(id=id_,
                          source__name__in=sources).first()
    if not actor:
        return {'success': False,
                'message': "Could not find actor"}

    actor.set_identifier_confidence(identifier, confidence)
    actor.save(username=user)

    return {'success': True}
开发者ID:0x3a,项目名称:crits,代码行数:28,代码来源:handlers.py

示例2: set_actor_description

def set_actor_description(id_, description, analyst):
    """
    Set an Actor description.

    :param id_: Actor ObjectId.
    :type id_: str
    :param description: The new description.
    :type description: str
    :param analyst: The user updating the description.
    :type analyst: str
    :returns: dict with keys:
              "success" (boolean),
              "message" (str),
    """

    sources = user_sources(analyst)
    actor = Actor.objects(id=id_,
                          source__name__in=sources).first()
    if not actor:
        return {'success': False,
                'message': "Could not find actor"}

    actor.description = description.strip()
    actor.save(username=analyst)
    return {'success': True}
开发者ID:ababook,项目名称:crits,代码行数:25,代码来源:handlers.py

示例3: remove_attribution

def remove_attribution(id_, identifier=None, user=None, **kwargs):
    """
    Remove an attributed identifier.

    :param id_: The ObjectId of the Actor.
    :param identifier: The Actor Identifier ObjectId.
    :type identifier: str
    :param user: The user removing this attribution.
    :type user: str
    :returns: dict with keys:
              "success" (boolean),
              "message" (str),
    """

    sources = user_sources(user)
    admin = is_admin(user)
    actor = Actor.objects(id=id_,
                          source__name__in=sources).first()
    if not actor:
        return {'success': False,
                'message': "Could not find actor"}

    actor.remove_attribution(identifier)
    actor.save(username=user)
    actor.reload()
    actor_identifiers = actor.generate_identifiers_list(user)

    html = render_to_string('actor_identifiers_widget.html',
                            {'actor_identifiers': actor_identifiers,
                             'admin': admin,
                             'actor_id': str(actor.id)})

    return {'success': True,
            'message': html}
开发者ID:0x3a,项目名称:crits,代码行数:34,代码来源:handlers.py

示例4: set_actor_name

def set_actor_name(id_, name, user, **kwargs):
    """
    Set an Actor name.

    :param id_: Actor ObjectId.
    :type id_: str
    :param name: The new name.
    :type name: str
    :param user: The user updating the name.
    :type user: str
    :returns: dict with keys:
              "success" (boolean),
              "message" (str),
    """

    sources = user_sources(user)
    actor = Actor.objects(id=id_,
                          source__name__in=sources).first()
    if not actor:
        return {'success': False,
                'message': "Could not find actor"}

    actor.name = name.strip()
    actor.save(username=user)
    return {'success': True}
开发者ID:0x3a,项目名称:crits,代码行数:25,代码来源:handlers.py

示例5: parse_threat_actors

    def parse_threat_actors(self, threat_actors):
        """
        Parse list of Threat Actors.

        :param threat_actors: List of STIX ThreatActors.
        :type threat_actors: List of STIX ThreatActors.
        """
        from stix.threat_actor import ThreatActor
        analyst = self.source_instance.analyst
        for threat_actor in threat_actors: # for each STIX ThreatActor
            try: # create CRITs Actor from ThreatActor
                if isinstance(threat_actor, ThreatActor):
                    name = str(threat_actor.title)
                    description = str(threat_actor.description)
                    res = add_new_actor(name=name,
                                        description=description,
                                        source=[self.source],
                                        analyst=analyst)
                    if res['success']:
                        sl = ml = tl = il = []
                        for s in threat_actor.sophistications:
                            sl.append(str(s.value))
                        update_actor_tags(res['id'],
                                            'ActorSophistication',
                                            sl,
                                            analyst)
                        for m in threat_actor.motivations:
                            ml.append(str(m.value))
                        update_actor_tags(res['id'],
                                            'ActorMotivation',
                                            ml,
                                            analyst)
                        for t in threat_actor.types:
                            tl.append(str(t.value))
                        update_actor_tags(res['id'],
                                            'ActorThreatType',
                                            tl,
                                            analyst)
                        for i in threat_actor.intended_effects:
                            il.append(str(i.value))
                        update_actor_tags(res['id'],
                                            'ActorIntendedEffect',
                                            il,
                                            analyst)
                        obj = Actor.objects(id=res['id']).first()
                        self.imported.append((Actor._meta['crits_type'], obj))
                    else:
                        self.failed.append((res['message'],
                                            type(threat_actor).__name__,
                                            "")) # note for display in UI
            except Exception, e:
                self.failed.append((e.message, type(threat_actor).__name__,
                                    "")) # note for display in UI
开发者ID:Abdullah-Mughal,项目名称:crits,代码行数:53,代码来源:parsers.py

示例6: get_actor_by_name

def get_actor_by_name(allowed_sources, actor):
    """
    Get an Actor from the database by name.

    :param allowed_sources: The sources this Actor is allowed to have.
    :type allowed_sources: list
    :param actor: The Actor address to find.
    :type actor: str
    :returns: :class:`crits.actors.actor.Actor`
    """

    actor = Actor.objects(name=actor, source__name__in=allowed_sources).first()
    return actor
开发者ID:0x3a,项目名称:crits,代码行数:13,代码来源:handlers.py

示例7: parse_threat_actors

    def parse_threat_actors(self, threat_actors):
        """
        Parse list of Threat Actors.

        :param threat_actors: List of STIX ThreatActors.
        :type threat_actors: List of STIX ThreatActors.
        """
        for threat_actor in threat_actors: # for each STIX ThreatActor
            try: # create CRITs Actor from ThreatActor
                obj = Actor.from_stix(threat_actor)
                obj.add_source(self.source)
                obj.save(username=self.source_instance.analyst)
                self.imported.append((Actor._meta['crits_type'], obj))
            except Exception, e:
                self.failed.append((e.message, type(threat_actor).__name__,
                                    "")) # note for display in UI
开发者ID:AInquel,项目名称:crits,代码行数:16,代码来源:parsers.py

示例8: attribute_actor_identifier

def attribute_actor_identifier(id_, identifier_type, identifier=None,
                               confidence="low", user=None, **kwargs):
    """
    Attribute an Actor Identifier to an Actor in CRITs.

    :param id_: The Actor ObjectId.
    :type id_: str
    :param identifier_type: The Actor Identifier Type.
    :type identifier_type: str
    :param identifier: The Actor Identifier.
    :type identifier: str
    :param user: The user attributing this identifier.
    :type user: str
    :returns: dict with keys:
              "success" (boolean),
              "message" (str),
    """

    if not user:
        return {'success': False,
                'message': "Could not find actor"}
    sources = user.get_sources_list()
    actor = Actor.objects(id=id_,
                          source__name__in=sources).first()
    if not actor:
        return {'success': False,
                'message': "Could not find actor"}

    c = len(actor.identifiers)
    actor.attribute_identifier(identifier_type,
                               identifier,
                               confidence,
                               user.username)
    actor.save(username=user.username)
    actor.reload()
    actor_identifiers = actor.generate_identifiers_list(user.username)

    if len(actor.identifiers) <= c:
        return {'success': False,
                'message': "Invalid data submitted or identifier is already attributed."}

    html = render_to_string('actor_identifiers_widget.html',
                            {'actor_identifiers': actor_identifiers,
                             'actor_id': str(actor.id)})

    return {'success': True,
            'message': html}
开发者ID:brlogan,项目名称:crits,代码行数:47,代码来源:handlers.py

示例9: actor_remove

def actor_remove(id_, user):
    """
    Remove an Actor from CRITs.

    :param id_: The ObjectId of the Actor to remove.
    :type id_: str
    :param user: The user removing this Actor.
    :type user: :class:`crits.core.user.CRITsUser`
    :returns: dict with keys "success" (boolean) and "message" (str) if failed.
    """

    actor = Actor.objects(id=id_).first()
    if actor:
        actor.delete(username=user.username)
        return {'success': True}
    else:
        return {'success':False, 'message':'Could not find Actor.'}
开发者ID:brlogan,项目名称:crits,代码行数:17,代码来源:handlers.py

示例10: actor_remove

def actor_remove(id_, username):
    """
    Remove an Actor from CRITs.

    :param id_: The ObjectId of the Actor to remove.
    :type id_: str
    :param username: The user removing this Actor.
    :type username: str
    :returns: dict with keys "success" (boolean) and "message" (str) if failed.
    """

    if is_admin(username):
        actor = Actor.objects(id=id_).first()
        if actor:
            actor.delete(username=username)
            return {'success': True}
        else:
            return {'success': False, 'message': 'Could not find Actor.'}
    else:
        return {'success': False, 'message': 'Must be an admin to remove'}
开发者ID:0x3a,项目名称:crits,代码行数:20,代码来源:handlers.py

示例11: update_actor_tags

def update_actor_tags(id_, tag_type, tags, user, **kwargs):
    """
    Update a subset of tags for an Actor.

    :param id_: The ObjectId of the Actor to update.
    :type id_: str
    :param tag_type: The type of tag we are updating.
    :type tag_type: str
    :param tags: The tags we are setting.
    :type tags: list
    :returns: dict
    """

    actor = Actor.objects(id=id_).first()
    if not actor:
        return {'success': False,
                'message': 'No actor could be found.'}
    else:
        actor.update_tags(tag_type, tags)
        actor.save(username=user)
        return {'success': True}
开发者ID:0x3a,项目名称:crits,代码行数:21,代码来源:handlers.py

示例12: update_actor_aliases

def update_actor_aliases(id_, aliases, user, **kwargs):
    """
    Update aliases for an Actor.

    :param id_: The ObjectId of the Actor to update.
    :type id_: str
    :param aliases: The aliases we are setting.
    :type aliases: list
    :param user: The user updating the aliases.
    :type user: str
    :returns: dict
    """

    sources = user_sources(user)
    actor = Actor.objects(id=id_,
                          source__name__in=sources).first()
    if not actor:
        return {'success': False,
                'message': 'No actor could be found.'}
    else:
        actor.update_aliases(aliases)
        actor.save(username=user)
        return {'success': True}
开发者ID:0x3a,项目名称:crits,代码行数:23,代码来源:handlers.py

示例13: update_actor_aliases

def update_actor_aliases(actor_id, aliases, analyst):
    """
    Update aliases for an Actor.

    :param actor_id: The ObjectId of the Actor to update.
    :type actor_id: str
    :param aliases: The aliases we are setting.
    :type aliases: list
    :param analyst: The user updating the aliases.
    :type analyst: str
    :returns: dict
    """

    sources = user_sources(analyst)
    actor = Actor.objects(id=actor_id,
                          source__name__in=sources).first()
    if not actor:
        return {'success': False,
                'message': 'No actor could be found.'}
    else:
        actor.update_aliases(aliases)
        actor.save(username=analyst)
        return {'success': True}
开发者ID:ababook,项目名称:crits,代码行数:23,代码来源:handlers.py

示例14: class_from_id

def class_from_id(type_, _id):
    """
    Return an instantiated class object.

    :param type_: The CRITs top-level object type.
    :type type_: str
    :param _id: The ObjectId to search for.
    :type _id: str
    :returns: class which inherits from
              :class:`crits.core.crits_mongoengine.CritsBaseAttributes`
    """

    # Quick fail
    if not _id or not type_:
        return None

    # doing this to avoid circular imports
    from crits.actors.actor import ActorThreatIdentifier, Actor
    from crits.backdoors.backdoor import Backdoor
    from crits.campaigns.campaign import Campaign
    from crits.certificates.certificate import Certificate
    from crits.comments.comment import Comment
    from crits.core.crits_mongoengine import Action
    from crits.core.source_access import SourceAccess
    from crits.core.user_role import UserRole
    from crits.domains.domain import Domain
    from crits.emails.email import Email
    from crits.events.event import Event
    from crits.exploits.exploit import Exploit
    from crits.indicators.indicator import Indicator
    from crits.ips.ip import IP
    from crits.pcaps.pcap import PCAP
    from crits.raw_data.raw_data import RawData, RawDataType
    from crits.samples.sample import Sample
    from crits.screenshots.screenshot import Screenshot
    from crits.signatures.signature import Signature, SignatureType, SignatureDependency
    from crits.targets.target import Target

    # make sure it's a string
    _id = str(_id)

    # Use bson.ObjectId to make sure this is a valid ObjectId, otherwise
    # the queries below will raise a ValidationError exception.
    if not ObjectId.is_valid(_id.decode("utf8")):
        return None

    if type_ == "Actor":
        return Actor.objects(id=_id).first()
    elif type_ == "Backdoor":
        return Backdoor.objects(id=_id).first()
    elif type_ == "ActorThreatIdentifier":
        return ActorThreatIdentifier.objects(id=_id).first()
    elif type_ == "Campaign":
        return Campaign.objects(id=_id).first()
    elif type_ == "Certificate":
        return Certificate.objects(id=_id).first()
    elif type_ == "Comment":
        return Comment.objects(id=_id).first()
    elif type_ == "Domain":
        return Domain.objects(id=_id).first()
    elif type_ == "Email":
        return Email.objects(id=_id).first()
    elif type_ == "Event":
        return Event.objects(id=_id).first()
    elif type_ == "Exploit":
        return Exploit.objects(id=_id).first()
    elif type_ == "Indicator":
        return Indicator.objects(id=_id).first()
    elif type_ == "Action":
        return Action.objects(id=_id).first()
    elif type_ == "IP":
        return IP.objects(id=_id).first()
    elif type_ == "PCAP":
        return PCAP.objects(id=_id).first()
    elif type_ == "RawData":
        return RawData.objects(id=_id).first()
    elif type_ == "RawDataType":
        return RawDataType.objects(id=_id).first()
    elif type_ == "Sample":
        return Sample.objects(id=_id).first()
    elif type_ == "Signature":
        return Signature.objects(id=_id).first()
    elif type_ == "SignatureType":
        return SignatureType.objects(id=_id).first()
    elif type_ == "SignatureDependency":
        return SignatureDependency.objects(id=_id).first()
    elif type_ == "SourceAccess":
        return SourceAccess.objects(id=_id).first()
    elif type_ == "Screenshot":
        return Screenshot.objects(id=_id).first()
    elif type_ == "Target":
        return Target.objects(id=_id).first()
    elif type_ == "UserRole":
        return UserRole.objects(id=_id).first()
    else:
        return None
开发者ID:cephurs,项目名称:crits,代码行数:96,代码来源:class_mapper.py

示例15: generate_actor_identifier_jtable

def generate_actor_identifier_jtable(request, option):
    """
    Generate the jtable data for rendering in the list template.

    :param request: The request for this jtable.
    :type request: :class:`django.http.HttpRequest`
    :param option: Action to take.
    :type option: str of either 'jtlist', 'jtdelete', or 'inline'.
    :returns: :class:`django.http.HttpResponse`
    """

    obj_type = ActorIdentifier
    type_ = "actor_identifier"
    mapper = obj_type._meta['jtable_opts']
    if option == "jtlist":
        # Sets display url
        details_url = mapper['details_url']
        details_url_key = mapper['details_url_key']
        fields = mapper['fields']
        response = jtable_ajax_list(obj_type,
                                    details_url,
                                    details_url_key,
                                    request,
                                    includes=fields)
        return HttpResponse(json.dumps(response,
                                       default=json_handler),
                            content_type="application/json")
    if option == "jtdelete":
        response = {"Result": "ERROR"}
        if jtable_ajax_delete(obj_type, request):
            obj_id = request.POST.get('id', None)
            if obj_id:
                # Remove this identifier from any Actors who reference it.
                Actor.objects(identifiers__identifier_id=obj_id)\
                    .update(pull__identifiers__identifier_id=obj_id)
            response = {"Result": "OK"}
        return HttpResponse(json.dumps(response,
                                       default=json_handler),
                            content_type="application/json")
    jtopts = {
        'title': "Actor Identifiers",
        'default_sort': mapper['default_sort'],
        'listurl': reverse('crits.actors.views.%ss_listing' %
                           (type_), args=('jtlist',)),
        'deleteurl': reverse('crits.actors.views.%ss_listing' %
                             (type_), args=('jtdelete',)),
        'searchurl': reverse(mapper['searchurl']),
        'fields': mapper['jtopts_fields'],
        'hidden_fields': mapper['hidden_fields'],
        'linked_fields': mapper['linked_fields'],
        'details_link': mapper['details_link'],
        'no_sort': mapper['no_sort']
    }
    jtable = build_jtable(jtopts, request)
    for field in jtable['fields']:
        if field['fieldname'] == "'name'":
            url = reverse('crits.actors.views.actors_listing')
            field['display'] = """ function (data) {
            return '<a href="%s?q='+data.record.id+'&search_type=actor_identifier&force_full=1">'+data.record.name+'</a>';
            }
            """ % url
        break
    jtable['toolbar'] = [
        {
            'tooltip': "'Add Actor Identifier'",
            'text': "'Add Actor Identifier'",
            'click': "function () {$('#new-actor-identifier').click()}",
        },
    ]
    if option == "inline":
        return render_to_response("jtable.html",
                                  {'jtable': jtable,
                                   'jtid': '%s_listing' % type_,
                                   'button': '%ss_tab' % type_},
                                  RequestContext(request))
    else:
        return render_to_response("%s_listing.html" % type_,
                                  {'jtable': jtable,
                                   'jtid': '%s_listing' % type_},
                                  RequestContext(request))
开发者ID:0x3a,项目名称:crits,代码行数:80,代码来源:handlers.py


注:本文中的crits.actors.actor.Actor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。