• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python RequestObject.RequestObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: VictimAssetFilterObject

class VictimAssetFilterObject(FilterObject):
    """ """

    def __init__(self, base_uri, tcl, victim_asset_type_enum=None):
        """ """
        super(VictimAssetFilterObject, self).__init__(base_uri, tcl)
        self._owners = []

        # get resource type from indicator type
        if isinstance(victim_asset_type_enum, VictimAssetType):
            # get resource type from indicator type number
            resource_type = ResourceType(victim_asset_type_enum.value)

            # get resource properties from resource type name
            self._properties = ResourceProperties[resource_type.name].value(base_uri=self.base_uri)
        else:
            self._properties = ResourceProperties['VICTIM_ASSETS'].value(base_uri=self.base_uri)

        self._resource_type = self._properties.resource_type

        # create default request object for filtered request with only owners
        self._request_object = RequestObject('victimAssets', 'default')
        self._request_object.set_http_method(self._properties.http_method)
        self._request_object.set_owner_allowed(self._properties.base_owner_allowed)
        self._request_object.set_request_uri(self._properties.base_path)
        self._request_object.set_resource_pagination(self._properties.resource_pagination)
        self._request_object.set_resource_type(self._properties.resource_type)

        #
        # add_obj filter methods
        #
        for method_name in self._properties.filters:
            method = getattr(FilterMethods, method_name)
            setattr(self, method_name, types.MethodType(method, self))
开发者ID:tiatam010,项目名称:threatconnect-python,代码行数:34,代码来源:VictimAssets.py


示例2: BulkIndicatorFilterObject

class BulkIndicatorFilterObject(FilterObject):
    """ """

    def __init__(self, base_uri, tcl):
        """ """
        super(BulkIndicatorFilterObject, self).__init__(base_uri, tcl)
        self._owners = []

        # pd('IndicatorFilterObject', header=True)
        # pd('indicator_type_enum', indicator_type_enum)

        self._properties = BulkIndicatorsProperties(base_uri=self.base_uri)
        self._resource_type = self._properties.resource_type

        # create default request object for filtered request with only owners
        self._request_object = RequestObject('indicators', 'default')
        self._request_object.set_http_method(self._properties.http_method)
        self._request_object.set_owner_allowed(self._properties.base_owner_allowed)
        self._request_object.set_request_uri(self._properties.base_path)
        self._request_object.set_resource_pagination(self._properties.resource_pagination)
        self._request_object.set_resource_type(self._properties.resource_type)

        #
        # add_obj filter methods
        #
        for method_name in self._properties.filters:
            # pd('method_name', method_name)
            method = getattr(FilterMethods, method_name)
            setattr(self, method_name, types.MethodType(method, self))
开发者ID:tiatam010,项目名称:threatconnect-python,代码行数:29,代码来源:BulkIndicators.py


示例3: BulkFilterObject

class BulkFilterObject(FilterObject):
    """ """
    def __init__(self, base_uri, tcl):
        """ """
        super(BulkFilterObject, self).__init__(base_uri, tcl)
        self._owners = []

        # define properties for resource type
        # self._properties = BulkProperties(base_uri=self.base_uri)
        self._properties = None
        self._resource_type = self._properties.resource_type

        # create default request object for filtered request with only owners
        self._request_object = RequestObject('groups', 'default')
        self._request_object.set_http_method(self._properties.http_method)
        self._request_object.set_owner_allowed(self._properties.base_owner_allowed)
        self._request_object.set_request_uri(self._properties.base_path)
        self._request_object.set_resource_pagination(self._properties.resource_pagination)
        self._request_object.set_resource_type(self._properties.resource_type)

        #
        # add_obj filter methods
        #
        for method_name in self._properties.filters:
            method = getattr(IndicatorFilterMethods, method_name)
            setattr(self, method_name, types.MethodType(method, self))
开发者ID:bschmoker,项目名称:threatconnect-python,代码行数:26,代码来源:Bulk.py


示例4: SignatureFilterObject

class SignatureFilterObject(FilterObject):
    """ """
    def __init__(self, base_uri, tcl):
        """ """
        super(SignatureFilterObject, self).__init__(base_uri, tcl)
        self._owners = []

        # define properties for resource type
        self._properties = SignaturesProperties(base_uri=self.base_uri)
        self._resource_type = self._properties.resource_type

        # create default request object for filtered request with only owners
        self._request_object = RequestObject('signatures', 'default')
        self._request_object.set_http_method(self._properties.http_method)
        self._request_object.set_owner_allowed(self._properties.base_owner_allowed)
        self._request_object.set_request_uri(self._properties.base_path)
        self._request_object.set_resource_pagination(self._properties.resource_pagination)
        self._request_object.set_resource_type(self._properties.resource_type)

        #
        # add_obj filter methods
        #
        for method_name in self._properties.filters:
            # special case for download
            if method_name == 'add_id':
                method = getattr(FilterMethods, 'add_id_signature')
                setattr(self, method_name, types.MethodType(method, self))
            else:
                method = getattr(FilterMethods, method_name)
                setattr(self, method_name, types.MethodType(method, self))
开发者ID:tiatam010,项目名称:threatconnect-python,代码行数:30,代码来源:Signatures.py


示例5: add_id

def add_id(self, data_int, asset_id=None):
    """ """
    resource_type = ResourceType(self._resource_type.value - 5)
    properties = ResourceProperties[resource_type.name].value()
    if asset_id is not None:
        # resource_type = ResourceType(self._resource_type.value - 5)
        # properties = ResourceProperties[resource_type.name].value()
        uri_data = [data_int, asset_id]
    else:
        # properties = self._properties
        uri_data = [data_int]

    # validation of data input
    if not isinstance(data_int, int):
        self.add_error(ErrorCodes.e4020.value.format(data_int))
        self._error = True
    else:
        filter_type = 'id'
        if asset_id is not None:
            filter_values = '{0}-{1}'.format(data_int, asset_id)
        else:
            filter_values = data_int
        ro = RequestObject(filter_type, filter_values)
        ro.set_owner_allowed(properties.id_owner_allowed)
        ro.set_resource_pagination(properties.resource_pagination)
        ro.set_request_uri(properties.id_path, uri_data)
        ro.set_resource_type(properties.resource_type)
        self._add_request_objects(ro)
开发者ID:tiatam010,项目名称:threatconnect-python,代码行数:28,代码来源:FilterMethods.py


示例6: VictimFilterObject

class VictimFilterObject(FilterObject):
    """ """
    def __init__(self, base_uri, tcl):
        """ """
        super(VictimFilterObject, self).__init__(base_uri, tcl)
        self._owners = []

        # define properties for resource type
        self._properties = VictimsProperties(base_uri=self.base_uri)
        self._resource_type = self._properties.resource_type

        # create default request object for filtered request with only owners
        self._request_object = RequestObject('victims', 'default')
        self._request_object.set_http_method(self._properties.http_method)
        self._request_object.set_owner_allowed(self._properties.base_owner_allowed)
        self._request_object.set_request_uri(self._properties.base_path)
        self._request_object.set_resource_pagination(self._properties.resource_pagination)
        self._request_object.set_resource_type(self._properties.resource_type)

        #
        # add_obj filter methods
        #
        for method_name in self._properties.filters:
            method = getattr(FilterMethods, method_name)
            setattr(self, method_name, types.MethodType(method, self))

    # special case for indicator associations
    def filter_associations(self, base_resource_type, identifier):
        """Get victims associated with base resource object
        GET /v2/groups/adversaries/747266/victims

        GET /v2/indicators/addresses/4.3.2.1/victims

        """
        base_properties = ResourceProperties[base_resource_type.name].value()

        request_uri = base_properties.base_path + '/'
        request_uri += str(identifier)
        request_uri += '/victims'

        description = 'Get victim associations for {0} resource ({1}).'.format(
            base_resource_type.name.lower(), str(identifier))

        filter_type = 'victim association'
        ro = RequestObject(
            filter_type, '{0}|{1}'.format(base_resource_type.name.lower(), identifier))
        ro.set_description(description)
        ro.set_owner_allowed(False)
        ro.set_resource_pagination(True)
        ro.set_request_uri(request_uri)
        ro.set_resource_type(ResourceType.VICTIMS)
        self._add_request_objects(ro)
开发者ID:tiatam010,项目名称:threatconnect-python,代码行数:52,代码来源:Victims.py


示例7: add_indicator

def add_indicator(self, data, data_type_enum=None):
    """ """
    if data_type_enum is None:
        # use indicator value to get the resource type
        data_type_enum = _get_resource_type(data)
    else:
        # indicator type provided
        if isinstance(data_type_enum, IndicatorType):
            data_type_enum = ResourceType(data_type_enum.value)

    error = False
    # validation indicator
    if not validate_indicator(data):
        self.add_error(ErrorCodes.e5010.value.format(data))
        self._error = True
        error = True

    # validation resource type
    if not isinstance(data_type_enum, ResourceType):
        self.add_error(ErrorCodes.e5011.value.format(data_type_enum))
        self._error = True
        error = True

    if not error:
        # get properties for indicator
        # (e.g ADDRESSES is 515 and ADDRESS is 510.
        indicator_resource_type = ResourceType(data_type_enum.value - 5)
        indicator_properties = ResourceProperties[indicator_resource_type.name].value()
        indicator_type = indicator_properties.resource_uri_attribute

        # determine properties
        indicator_resources = [
            'INDICATORS', 'ADDRESSES', 'EMAIL_ADDRESSES', 'FILES', 'HOSTS', 'URLS']
        if self._properties.resource_type.name in indicator_resources:
            # if the resource type is one of the above use the properties of that indicator
            properties = indicator_properties
        else:
            # otherwise use the properties of the resource
            properties = self._properties

        # url
        if data_type_enum == ResourceType.URLS:
            data = urllib.quote(data, safe='~')

        filter_type = data_type_enum.name.lower()

        ro = RequestObject(filter_type, data)
        ro.set_owner_allowed(properties.indicator_owner_allowed)
        ro.set_resource_pagination(properties.resource_pagination)
        ro.set_request_uri(
            properties.indicator_path, [indicator_type, data])
        ro.set_resource_type(properties.resource_type)
        self._add_request_objects(ro)
开发者ID:tiatam010,项目名称:threatconnect-python,代码行数:53,代码来源:FilterMethods.py


示例8: BulkIndicators

class BulkIndicators(Resource):
    """ """

    def __init__(self, tc_obj):
        """ """
        super(BulkIndicators, self).__init__(tc_obj)
        self._filter_class = BulkIndicatorFilterObject
        self._modified_since = None

        # set properties
        properties = BulkIndicatorsProperties(base_uri=self.base_uri)
        self._resource_type = properties.resource_type

        # create default request object for non-filtered requests
        self._request_object = RequestObject('bulk_indicators', 'default')
        self._request_object.set_http_method(properties.http_method)
        self._request_object.set_owner_allowed(properties.base_owner_allowed)
        self._request_object.set_request_uri(properties.base_path)
        self._request_object.set_resource_pagination(properties.resource_pagination)
        self._request_object.set_resource_type(properties.resource_type)

    @property
    def csv(self):
        """ """
        headers = [
            'confidence', 'dateAdded', 'id', 'indicator', 'lastModified', 'ownerName', 'rating', 'type', 'webLink']
        csv_output = io.BytesIO()

        csv_data = csv.writer(csv_output, delimiter=',', quotechar='"', quoting=csv.QUOTE_NONNUMERIC)
        csv_data.writerow(headers)

        for obj in self._objects:
            csv_row = [
                obj.get_confidence(),
                obj.get_date_added(),
                obj.get_id(),
                obj.get_indicator(),
                obj.get_last_modified(),
                obj.get_owner_name(),
                obj.get_rating(),
                obj.get_type(),
                obj.get_web_link(),
                ]
            csv_data.writerow(csv_row)

        for row in csv_output.getvalue().split('\r\n'):
            yield row
开发者ID:tiatam010,项目名称:threatconnect-python,代码行数:47,代码来源:BulkIndicators.py


示例9: add_tag

def add_tag(self, data):
    """ """
    properties = self._properties
    if not isinstance(data, str):
        self.add_error(ErrorCodes.e4080.value.format(data))
        self._error = True
    else:
        filter_type = 'tag'
        ro = RequestObject(filter_type, data)
        ro.set_owner_allowed(properties.tag_owner_allowed)
        ro.set_resource_pagination(properties.resource_pagination)
        ro.set_request_uri(properties.tag_path, [data])
        ro.set_resource_type(properties.resource_type)
        self._add_request_objects(ro)
开发者ID:tiatam010,项目名称:threatconnect-python,代码行数:14,代码来源:FilterMethods.py


示例10: Victims

class Victims(Resource):
    """ """
    def __init__(self, tc_obj):
        """ """
        super(Victims, self).__init__(tc_obj)
        self._filter_class = VictimFilterObject

        # set properties
        properties = VictimsProperties(base_uri=self.base_uri)
        self._resource_type = properties.resource_type

        # create default request object for non-filtered requests
        self._request_object = RequestObject('victims', 'default')
        self._request_object.set_http_method(properties.http_method)
        self._request_object.set_owner_allowed(properties.base_owner_allowed)
        self._request_object.set_request_uri(properties.base_path)
        self._request_object.set_resource_pagination(properties.resource_pagination)
        self._request_object.set_resource_type(properties.resource_type)
开发者ID:tiatam010,项目名称:threatconnect-python,代码行数:18,代码来源:Victims.py


示例11: add_victim_id

def add_victim_id(self, data_int):
    """ """
    properties = self._properties
    # validation of data input
    if not isinstance(data_int, int):
        self.add_error(ErrorCodes.e4060.value.format(data_int))
        self._error = True
    else:
        filter_type = 'victim_id'
        ro = RequestObject(filter_type, data_int)
        ro.set_owner_allowed(properties.victim_owner_allowed)
        ro.set_resource_pagination(properties.resource_pagination)
        ro.set_request_uri(properties.victim_path, [data_int])
        ro.set_resource_type(properties.resource_type)
        self._add_request_objects(ro)
开发者ID:tiatam010,项目名称:threatconnect-python,代码行数:15,代码来源:FilterMethods.py


示例12: set_format

def set_format(self, data):
    """ """
    properties = self._properties

    # if invalid format specified return json
    if data in ['json', 'csv']:
        d_format = data
    else:
        d_format = 'json'

    ro = RequestObject('bulk download', d_format)
    ro.set_owner_allowed(properties.base_owner_allowed)
    ro.set_resource_pagination(properties.resource_pagination)
    ro.set_request_uri(properties.base_path, [d_format])
    ro.set_resource_type(properties.resource_type)
    self._add_request_objects(ro)
开发者ID:tiatam010,项目名称:threatconnect-python,代码行数:16,代码来源:FilterMethods.py


示例13: add_name

def add_name(self, data):
    """ """
    resource_type = ResourceType(self._resource_type.value - 5)
    properties = ResourceProperties[resource_type.name].value()
    # validation of data input
    if not isinstance(data, str):
        self.add_error(ErrorCodes.e4080.value.format(data))
        self._error = True
    else:
        filter_type = 'name'
        ro = RequestObject(filter_type, data)
        ro.set_owner_allowed(properties.name_owner_allowed)
        ro.set_resource_pagination(properties.resource_pagination)
        ro.set_request_uri(properties.name_path, [data])
        ro.set_resource_type(properties.resource_type)
        self._add_request_objects(ro)
开发者ID:tiatam010,项目名称:threatconnect-python,代码行数:16,代码来源:FilterMethods.py


示例14: Owners

class Owners(Resource):
    """ """
    def __init__(self, tc_obj):
        """ """
        super(Owners, self).__init__(tc_obj)
        self._filter_class = OwnerFilterObject

        # set properties
        properties = OwnersProperties(base_uri=self.base_uri)
        self._resource_type = properties.resource_type

        # create default request object for non-filtered requests
        self._request_object = RequestObject('owners', 'default')
        self._request_object.set_http_method(properties.http_method)
        self._request_object.set_owner_allowed(properties.base_owner_allowed)
        self._request_object.set_request_uri(properties.base_path)
        self._request_object.set_resource_pagination(properties.resource_pagination)
        self._request_object.set_resource_type(properties.resource_type)

    def get_owner_by_id(self, data):
        for obj in self._objects:
            if obj.get_id() == data:
                return obj
        return None

    def get_owner_by_name(self, data):
        for obj in self._objects:
            if obj.get_name() == data:
                return obj
        return None

    def get_owner_names(self):
        owner_names = []
        for obj in self._objects:
            owner_names.append(obj.get_name())
        return owner_names
开发者ID:tiatam010,项目名称:threatconnect-python,代码行数:36,代码来源:Owners.py


示例15: __init__

    def __init__(self, base_uri, tcl, indicator_type_enum=None):
        """ """
        super(IndicatorFilterObject, self).__init__(base_uri, tcl)
        self._owners = []

        # pd('IndicatorFilterObject', header=True)
        # pd('indicator_type_enum', indicator_type_enum)

        # get resource type from indicator type
        if isinstance(indicator_type_enum, IndicatorType):
            # get resource type from indicator type number
            resource_type = ResourceType(indicator_type_enum.value)

            # get resource properties from resource type name
            self._properties = ResourceProperties[resource_type.name].value(base_uri=self.base_uri)
        else:
            self._properties = ResourceProperties['INDICATORS'].value(base_uri=self.base_uri)

        self._resource_type = self._properties.resource_type

        # create default request object for filtered request with only owners
        self._request_object = RequestObject('adversaries', 'default')
        self._request_object.set_http_method(self._properties.http_method)
        self._request_object.set_owner_allowed(self._properties.base_owner_allowed)
        self._request_object.set_request_uri(self._properties.base_path)
        self._request_object.set_resource_pagination(self._properties.resource_pagination)
        self._request_object.set_resource_type(self._properties.resource_type)

        # add_obj properties for filter objects with no request object
        # happens when a indicator type is specified, but no other
        # filters are provided
        # self._owner_allowed = self._properties.base_owner_allowed
        # self._request_uri = self._properties.base_path
        # self._resource_pagination = self._properties.resource_pagination
        # self._resource_type = self._properties.resource_type

        # pd('owner_allowed', self._owner_allowed)
        # pd('resource_pagination', self._resource_pagination)
        # pd('resource_type', self._resource_type)

        #
        # add_obj filter methods
        #
        for method_name in self._properties.filters:
            # pd('method_name', method_name)
            method = getattr(FilterMethods, method_name)
            setattr(self, method_name, types.MethodType(method, self))
开发者ID:tiatam010,项目名称:threatconnect-python,代码行数:47,代码来源:Indicators.py


示例16: add_adversary_id

def add_adversary_id(self, data_int, asset_id=None):
    """ """
    if asset_id is not None:
        resource_type = ResourceType(self._resource_type.value - 5)
        properties = ResourceProperties[resource_type.name].value()
        uri_data = [data_int, asset_id]
    else:
        properties = self._properties
        uri_data = [data_int]

    # validation of data input
    if not isinstance(data_int, int):
        self.add_error(ErrorCodes.e4000.value.format(data_int))
        self._error = True
    else:
        filter_type = 'adversary_id'
        ro = RequestObject(filter_type, data_int)
        ro.set_owner_allowed(properties.adversary_owner_allowed)
        ro.set_resource_pagination(properties.resource_pagination)
        ro.set_request_uri(properties.adversary_path, uri_data)
        ro.set_resource_type(properties.resource_type)
        self._add_request_objects(ro)
开发者ID:tiatam010,项目名称:threatconnect-python,代码行数:22,代码来源:FilterMethods.py


示例17: __init__

    def __init__(self, tc_obj):
        """ """
        super(BulkIndicators, self).__init__(tc_obj)
        self._filter_class = BulkIndicatorFilterObject
        self._modified_since = None

        # set properties
        properties = BulkIndicatorsProperties(base_uri=self.base_uri)
        self._resource_type = properties.resource_type

        # create default request object for non-filtered requests
        self._request_object = RequestObject('bulk_indicators', 'default')
        self._request_object.set_http_method(properties.http_method)
        self._request_object.set_owner_allowed(properties.base_owner_allowed)
        self._request_object.set_request_uri(properties.base_path)
        self._request_object.set_resource_pagination(properties.resource_pagination)
        self._request_object.set_resource_type(properties.resource_type)
开发者ID:tiatam010,项目名称:threatconnect-python,代码行数:17,代码来源:BulkIndicators.py


示例18: __init__

    def __init__(self, tc_obj):
        """ """
        super(Attributes, self).__init__(tc_obj)
        self._filter_class = AttributeFilterObject
        # self._object_class = AttributeObject

        # set properties for non filtered request
        properties = AttributesProperties(base_uri=self.base_uri)
        self._resource_type = properties.resource_type

        # create default request object for non-filtered requests
        self._request_object = RequestObject('attribute', 'default')
        self._request_object.set_http_method(properties.http_method)
        self._request_object.set_owner_allowed(properties.base_owner_allowed)
        self._request_object.set_request_uri(properties.base_path)
        self._request_object.set_resource_pagination(properties.resource_pagination)
        self._request_object.set_resource_type(properties.resource_type)
开发者ID:tiatam010,项目名称:threatconnect-python,代码行数:17,代码来源:Attributes.py


示例19: download_request

def download_request(self):
    """ """
    # build request object
    request_object = RequestObject(self._drd['name1'], self._drd['name2_method']())
    request_object.set_content_type(self._drd['content_type'])
    request_object.set_description(
        self._drd['description'].format(self._drd['identifier_method']()))
    request_object.set_http_method(self._drd['http_method'])
    request_object.set_request_uri(
        self._drd['request_uri_path'].format(self._drd['identifier_method']()))
    request_object.set_owner_allowed(self._drd['owner_allowed'])
    request_object.set_resource_pagination(self._drd['resource_pagination'])
    request_object.set_resource_type(self._drd['resource_type'])

    return request_object
开发者ID:tiatam010,项目名称:threatconnect-python,代码行数:15,代码来源:ResourceMethods.py


示例20: add_id_signature

def add_id_signature(self, data_int, download=False):
    """ """
    resource_type = ResourceType(self._resource_type.value - 5)
    properties = ResourceProperties[resource_type.name].value()
    uri_data = [data_int]

    # validation of data input
    if not isinstance(data_int, int):
        self.add_error(ErrorCodes.e4020.value.format(data_int))
        self._error = True
    else:
        filter_type = 'id'
        ro = RequestObject(filter_type, data_int)
        ro.set_owner_allowed(properties.id_owner_allowed)
        ro.set_resource_pagination(properties.resource_pagination)
        ro.set_request_uri(properties.id_path, uri_data)
        ro.set_resource_type(properties.resource_type)

        # add_obj download
        if download:
            ro.set_download(True)

        self._add_request_objects(ro)
开发者ID:tiatam010,项目名称:threatconnect-python,代码行数:23,代码来源:FilterMethods.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python three.Three类代码示例发布时间:2022-05-27
下一篇:
Python PostFilterObject.PostFilterObject类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap