Ejemplo n.º 1
0
    def tlp(self, text):
        """
    returns the status

    :returns: String
    """
        self.tlp_lvl = TLP.get_by_value(text)
Ejemplo n.º 2
0
    def tlp(self):
        """
      returns the tlp level

      :returns: String
    """

        return TLP.get_by_id(self.tlp_lvl)
Ejemplo n.º 3
0
  def tlp(self):
    """
      returns the tlp level

      :returns: String
    """
    if self.__tlp_obj is None:
      self.__tlp_obj = TLP(self.tlp_level_id)
    return self.__tlp_obj
Ejemplo n.º 4
0
 def get_tlp_id_from_markings(self, indicator):
     handling = indicator.handling
     if handling:
         markings = handling.markings
         for marking in markings:
             for stucture in marking.marking_structures:
                 if isinstance(stucture, TLPMarkingStructure):
                     color = stucture.color
                     tlp_id = TLP.get_by_value(color.title())
                     return tlp_id
     return None
Ejemplo n.º 5
0
def get_max_tlp(user_group):
    if user_group:
        if user_group.permissions.propagate_tlp:
            max_tlp = user_group.tlp_lvl
            for group in user_group.children:
                if group.tlp_lvl < max_tlp:
                    max_tlp = group.tlp_lvl
                # check for group children
                child_max = get_max_tlp(group)
                if child_max < max_tlp:
                    max_tlp = child_max
            return max_tlp
        else:
            return user_group.tlp_lvl
    else:
        return TLP.get_by_value('White')
Ejemplo n.º 6
0
    def __set_parameters(self, result, parameters):
        # add additinal filters

        if parameters:
            anal = parameters.get('filter[analysis]', None)
            if anal:
                matching_ids = self.__find_id(Analysis.get_dictionary(), anal)
                result = result.filter(Event.analysis_id.in_(matching_ids))
            anal = parameters.get('filter[creator_group_name]', None)
            if anal:
                result = result.join(Event.creator_group).filter(
                    Group.name.like('%{0}%'.format(anal)))
            anal = parameters.get('filter[created_at]', None)
            if anal:
                result = result.filter(
                    Event.created_at.like('%{0}%'.format(anal)))
            anal = parameters.get('filter[title]', None)
            if anal:
                result = result.filter(Event.title.like('%{0}%'.format(anal)))
            anal = parameters.get('filter[status]', None)
            if anal:
                matching_ids = self.__find_id(Status.get_dictionary(), anal)
                result = result.filter(Event.status_id.in_(matching_ids))
            anal = parameters.get('filter[tlp]', None)
            if anal:
                matching_ids = self.__find_id(TLP.get_dictionary(), anal)
                result = result.filter(Event.tlp_level_id.in_(matching_ids))

            # do a similar stuff for sorting
            anal = parameters.get('sorting[analysis]', None)
            if anal:
                if anal == 'desc':
                    result = result.order_by(Event.analysis_id.desc())
                else:
                    result = result.order_by(Event.analysis_id.asc())

            anal = parameters.get('sorting[creator_group_name]', None)
            if anal:
                if anal == 'desc':
                    result = result.join(Event.creator_group).order_by(
                        Group.name.desc())
                else:
                    result = result.join(Event.creator_group).order_by(
                        Group.name.asc())

            anal = parameters.get('sorting[created_at]', None)
            if anal:
                if anal == 'desc':
                    result = result.order_by(Event.created_at.desc())
                else:
                    result = result.order_by(Event.created_at.asc())

            anal = parameters.get('sorting[title]', None)
            if anal:
                if anal == 'desc':
                    result = result.order_by(Event.title.desc())
                else:
                    result = result.order_by(Event.title.asc())

            anal = parameters.get('sorting[status]', None)
            if anal:
                if anal == 'desc':
                    result = result.order_by(Event.status_id.desc())
                else:
                    result = result.order_by(Event.status_id.asc())

            anal = parameters.get('sorting[tlp]', None)
            if anal:
                if anal == 'desc':
                    result = result.order_by(Event.tlp_level_id.desc())
                else:
                    result = result.order_by(Event.tlp_level_id.asc())

            anal = parameters.get('sorting[id]', None)
            if anal:
                if anal == 'desc':
                    result = result.order_by(Event.identifier.desc())
                else:
                    result = result.order_by(Event.identifier.asc())
        return result
Ejemplo n.º 7
0
 def tlps(self, **args):
     try:
         return TLP.get_cb_values()
     except ControllerException as error:
         raise RestHandlerException(error)
Ejemplo n.º 8
0
 def tlps(self, **args):
     values = TLP.get_dictionary()
     result = list()
     for key, value in values.iteritems():
         result.append({'identifier': key, 'name': value})
     return result