本文整理汇总了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
示例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)
示例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
示例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
示例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
示例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
示例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
示例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
示例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