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


Python AssetDAO.AssetDAO类代码示例

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


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

示例1: get

  def get(self, environment,asset):
    session_id = get_session_id(session, request)
    hide_concerns = request.args.get('hide_concerns', '1')
    if hide_concerns == '0' or hide_concerns == 0:
      hide_concerns = False
    else:
      hide_concerns = True
    if asset == 'all':
      asset = ''
    model_generator = get_model_generator()

    dao = AssetDAO(session_id)
    dot_code = dao.get_asset_model(environment, asset, hide_concerns=hide_concerns)
    dao.close()

    if not isinstance(dot_code, str):
      raise ObjectNotFoundHTTPError('The model')

    resp = make_response(model_generator.generate(dot_code,renderer='dot'), OK)
    accept_header = request.headers.get('Accept', 'image/svg+xml')
    if accept_header.find('text/plain') > -1:
      resp.headers['Content-type'] = 'text/plain'
    else:
      resp.headers['Content-type'] = 'image/svg+xml'

    return resp
开发者ID:failys,项目名称:cairis,代码行数:26,代码来源:AssetController.py

示例2: get_misuse_case_obj_and_assets

  def get_misuse_case_obj_and_assets(self, threat_name, vulnerability_name, environment_name):
    """
    :rtype : str, list[Asset]
    """
    dao = AssetDAO(self.session_id)
    threatened_assets = []
    vulnerable_assets = []
    try:
      threatened_assets = dao.get_threatened_assets(threat_name, environment_name)
      vulnerable_assets = dao.get_vulnerable_assets(vulnerability_name, environment_name)
    except ObjectNotFoundHTTPError as ex:
      SilentHTTPError(ex.message)

    objectiveText = 'Exploit vulnerabilities in '
    for idx,vulAsset in enumerate(vulnerable_assets):
      objectiveText += vulAsset
      if (idx != (len(vulnerable_assets) -1)):
        objectiveText += ','
    objectiveText += ' to threaten '
    for idx,thrAsset in enumerate(threatened_assets):
      objectiveText += thrAsset
      if (idx != (len(threatened_assets) -1)):
        objectiveText += ','
    objectiveText += '.'
    assets = set(threatened_assets + vulnerable_assets)

    return objectiveText, list(assets)
开发者ID:failys,项目名称:cairis,代码行数:27,代码来源:RiskDAO.py

示例3: get

    def get(self, environment):
        session_id = get_session_id(session, request)

        dao = AssetDAO(session_id)
        assets = dao.get_asset_names(environment=environment)
        dao.close()

        resp = make_response(json_serialize(assets, session_id=session_id))
        resp.headers['Content-Type'] = "application/json"
        return resp
开发者ID:RachelLar,项目名称:cairis,代码行数:10,代码来源:AssetController.py

示例4: delete

    def delete(self, name):
        session_id = request.args.get('session_id', None)
        dao = AssetDAO(session_id)

        dao.delete_asset(name=name)
        dao.close()

        resp_dict = {'message': 'Asset successfully deleted'}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.contenttype = 'application/json'
        return resp
开发者ID:RachelLar,项目名称:cairis,代码行数:11,代码来源:AssetController.py

示例5: put

  def put(self, name):
    session_id = get_session_id(session, request)

    dao = AssetDAO(session_id)
    asset = dao.from_json(request)
    assetName = dao.update_asset(asset, name=name)
    dao.close()

    resp_dict = {'message': assetName + ' updated'}
    resp = make_response(json_serialize(resp_dict), OK)
    resp.contenttype = 'application/json'
    return resp
开发者ID:failys,项目名称:cairis,代码行数:12,代码来源:AssetController.py

示例6: post

    def post(self):
        session_id = get_session_id(session, request)

        dao = AssetDAO(session_id)
        asset = dao.from_json(request)
        new_id = dao.add_asset(asset)
        dao.close()

        resp_dict = {'asset_id': new_id}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.contenttype = 'application/json'
        return resp
开发者ID:RachelLar,项目名称:cairis,代码行数:12,代码来源:AssetController.py

示例7: delete

    def delete(self, name):
        session_id = get_session_id(session, request)
        environment_name = request.args.get("environment", "")

        dao = AssetDAO(session_id)
        dao.delete_asset_type(name=name, environment_name=environment_name)
        dao.close()

        resp_dict = {"message": "Asset type successfully deleted"}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.headers["Content-type"] = "application/json"
        return resp
开发者ID:failys,项目名称:cairis,代码行数:12,代码来源:AssetController.py

示例8: put

    def put(self, asset_name):
        session_id = get_session_id(session, request)

        dao = AssetDAO(session_id)
        asset_prop = dao.from_json(request, to_props=True)
        dao.update_asset_properties(asset_prop, name=asset_name)
        dao.close()

        resp_dict = {'message': 'The asset properties were successfully updated.'}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.contenttype = 'application/json'
        return resp
开发者ID:RachelLar,项目名称:cairis,代码行数:12,代码来源:AssetController.py

示例9: post

    def post(self):
        session_id = get_session_id(session, request)
        environment_name = request.args.get("environment", "")

        dao = AssetDAO(session_id)
        new_value_type = dao.type_from_json(request)
        dao.add_asset_type(new_value_type, environment_name=environment_name)
        dao.close()

        resp_dict = {"message": "Asset type successfully added"}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.contenttype = "application/json"
        return resp
开发者ID:failys,项目名称:cairis,代码行数:13,代码来源:AssetController.py


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