def get_users_scan_count(**kwargs): """ 获取所有用户及其扫描次数 To use: >>> users = UserService.get_users_scan_count(fields=(User.full_name), where=(User.mobile_phone == "122222")) >>> print(users) :param kwargs: :return: """ from model.user_task import UserTask """ open_id = TextField(null=True) user_name = TextField(null=True) pass_word = TextField(null=True) full_name = TextField(null=True) email = TextField(null=True) dept_name = TextField(null=True) role = IntegerField(default=Role.USER) recent_operation_time = DateTimeField(null=True) user_info = TextField(null=True) mobile_phone = TextField(null=True) """ kwargs["fields"] = ( User.id, User.open_id, User.user_name, User.full_name, User.email, User.dept_name, User.role, User.recent_operation_time, User.user_info, User.mobile_phone, UserTask.select(fn.COUNT(UserTask.id)).alias('scan_count').where(UserTask.user_id == User.id)) return HunterModelService.get_fields_by_where(User, **kwargs)
def save(**kwargs): """ 保存操作,已经close掉connect :param self: :return: """ return HunterModelService.save(Url, **kwargs)
def save(**kwargs): """ 保存任务信息,用户任务id关联表,一个任务可以分配给多个用户 To use: >>> UserTaskService.save(task_id=1, user_id=3) :return: """ return HunterModelService.save(UserTask, **kwargs)
def remove(**kwargs): """ 删除操作 To use: >>> UserTaskService.remove(where=(UserTask.task_id == 1)) :return: """ return HunterModelService.remove(UserTask, **kwargs)
def count(**kwargs): """ 数据数量 To use: >>> NetWorkProxyConfigService.count(where=(NetWorkProxyConfig.id == 1)) :param kwargs: :return: """ return HunterModelService.count(NetWorkProxyConfig, **kwargs)
def count(**kwargs): """ 数据数量 To use: >>> LdapConfigService.count(where=(LdapConfig.id == 1)) :param kwargs: :return: """ return HunterModelService.count(LdapConfig, **kwargs)
def update(**kwargs): """ 更新操作,更新操作之后 To use: >>> TaskService.update(fields=({Task.hunter_status: TaskStatus.DONE })) :param kwargs: :return: """ return HunterModelService.update(Task, **kwargs)
def get_fields_by_where(**kwargs): """ To use: >>> tasks = TaskService.get_fields_by_where(fields=(Task.task_status), where=(Task.id == 1)) >>> print(tasks) :param kwargs: :return: """ return HunterModelService.get_fields_by_where(Task, **kwargs)
def count(**kwargs): """ 数据数量 To use: >>> VulnerabilityService.count(where=(Vulnerability.id == 1)) :param kwargs: :return: """ return HunterModelService.count(Vulnerability, **kwargs)
def count(**kwargs): """ 数据数量 To use: >>> UrlService.count(where=(Url.id == 1)) :param kwargs: :return: """ return HunterModelService.count(Url, **kwargs)
def get_fields_by_where(**kwargs): """ To use: >>> users = UserService.get_fields_by_where(fields=(User.full_name), where=(User.mobile_phone == "122222")) >>> print(users) :param kwargs: :return: """ return HunterModelService.get_fields_by_where(User, **kwargs)
def update(**kwargs): """ 更新操作,更新操作之后 To use: >>> UserTaskService.update(fields=({UserTask.task_id: 1 })) :param kwargs: :return: """ return HunterModelService.update(UserTask, **kwargs)
def get_fields_by_where(**kwargs): """ To use: >>> user_tasks = UserTaskService.get_fields_by_where(fields=(UserTask.task_id), where=(UserTask.id == 1)) >>> print(user_tasks) :param kwargs: :return: """ return HunterModelService.get_fields_by_where(UserTask, **kwargs)
def save(**kwargs): """ 保存操作,不做第二次 To use: >>> CaCertConfigService.save(ca_country_name="ldap://127.0.0.1") :param kwargs: :return: """ return HunterModelService.save(NetWorkProxyConfig, **kwargs)
def save(**kwargs): """ 保存操作,不做第二次 To use: >>> PluginInfoService.save(plugin_name="cve1222") :param kwargs: :return: """ return HunterModelService.save(PluginInfo, **kwargs)
def count(**kwargs): """ 数据数量 To use: >>> UserService.count(where=(User.full_name == "xxxx")) :param kwargs: :return: """ return HunterModelService.count(User, **kwargs)
def get_fields_by_where(**kwargs): """ To use: >>> urls = UrlService.get_fields_by_where(fields=(Url.origin_data), where=(Url.task_id == 1)) >>> print(urls) :param kwargs: :return: """ return HunterModelService.get_fields_by_where(Url, **kwargs)
def update(**kwargs): """ 更新操作,更新操作之后 To use: >>> UserService.update(fields=({User.recent_operation_time: datetime })) :param kwargs: :return: """ return HunterModelService.update(User, **kwargs)
def update(**kwargs): """ 更新操作,更新操作之后 To use: >>> UrlService.update(fields=({Url.plugin: "xxe" })) :param kwargs: :return: """ return HunterModelService.update(Url, **kwargs)
def save(**kwargs): """ 保存操作,不做第二次 To use: >>> UserService.save(user_name="admin") :param kwargs: :return: """ return HunterModelService.save(User, **kwargs)
def get_fields_by_where(**kwargs): """ To use: >>> vulns = VulnerabilityService.get_fields_by_where(fields=(User.full_name), where=(User.mobile_phone == "122222")) >>> print(vulns) :param kwargs: :return: """ return HunterModelService.get_fields_by_where(Vulnerability, **kwargs)
def get_fields_by_where(**kwargs): """ To use: >>> system_config = SystemConfigService.get_fields_by_where(fields=(SystemConfig.socket_port), where=(SystemConfig.id == 1)) >>> print(system_config) :param kwargs: :return: """ return HunterModelService.get_fields_by_where(SystemConfig, **kwargs)
def update(**kwargs): """ 更新操作,更新操作之后 To use: >>> VulnerabilityService.update(fields=({Vulnerability.level: VulnLevel.HIGHT })) :param kwargs: :return: """ return HunterModelService.update(Vulnerability, **kwargs)
def get_fields_by_where(**kwargs): """ To use: >>> plugin_infos = PluginInfoService.get_fields_by_where(fields=(PluginInfo.plugin_name), where=(PluginInfo.level == VulnLevel.LOW)) >>> print(plugin_infos) :param kwargs: :return: """ return HunterModelService.get_fields_by_where(PluginInfo, **kwargs)
def count(**kwargs): """ 数据数量 To use: >>> TaskService.count(where=(Task.id == 1)) :param kwargs: :return: """ return HunterModelService.count(Task, **kwargs)
def count(**kwargs): """ 数据数量 To use: >>> PluginInfoService.count(where=(PluginInfo.level == VulnLevel.HIGHT)) :param kwargs: :return: """ return HunterModelService.count(PluginInfo, **kwargs)
def get_fields_by_where(**kwargs): """ To use: >>> ldap_config = LdapConfigService.get_fields_by_where(fields=(LdapConfig.ldap_host), where=(LdapConfig.id == 1)) >>> print(ldap_config) :param kwargs: :return: """ return HunterModelService.get_fields_by_where(LdapConfig, **kwargs)
def update(**kwargs): """ 更新操作,更新操作之后 To use: >>> PluginInfoService.update(fields=({PluginInfo.useable: PluginSwith.OFF })) :param kwargs: :return: """ return HunterModelService.update(PluginInfo, **kwargs)
def save(**kwargs): """ 保存操作,不做第二次 To use: >>> LdapConfigService.save(ldap_host="ldap://127.0.0.1") :param kwargs: :return: """ return HunterModelService.save(LdapConfig, **kwargs)
def get_fields_by_where(**kwargs): """ To use: >>> proxy_config = NetWorkProxyConfigService.get_fields_by_where(fields=(NetWorkProxyConfig.ca_country_name), where=(NetWorkProxyConfig.id == 1)) >>> print(ca_config) :param kwargs: :return: """ return HunterModelService.get_fields_by_where(NetWorkProxyConfig, **kwargs)