本文整理汇总了Python中models.Service.from_name方法的典型用法代码示例。如果您正苦于以下问题:Python Service.from_name方法的具体用法?Python Service.from_name怎么用?Python Service.from_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Service
的用法示例。
在下文中一共展示了Service.from_name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: search_service
# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import from_name [as 别名]
def search_service(self, pkg):
"""This method will return a Service that is involved with that pkg.
Priority to search:
1) From destiny IP. For example 50.22.198.206 -> WhatsApp
2) From URL (because of previous DNS query)
2.1) Absolute URL match with DB
2.2) URL relative match with DB (fb.com matches with xxx.ssss.dddd.fff.fb.com)
2.3) Name from URL
"""
service = self.environment.service_analyzer.find_service_from_ip(
pkg.ip.dst)
if service:
service.ips.add(pkg.ip.dst)
return service
else:
host = self.environment.find_host(pkg.ip.dst)
if host:
name = get_significant_name_from_url(host)
ret_service = self.environment.service_analyzer.find_service_from_absolute_url(
host
) or self.environment.service_analyzer.find_service_from_url(
host) or Service.from_name(name)
ret_service.hosts.add(host)
return ret_service
else:
return None