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


Python validators.domain方法代码示例

本文整理汇总了Python中validators.domain方法的典型用法代码示例。如果您正苦于以下问题:Python validators.domain方法的具体用法?Python validators.domain怎么用?Python validators.domain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在validators的用法示例。


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

示例1: _create_payload

# 需要导入模块: import validators [as 别名]
# 或者: from validators import domain [as 别名]
def _create_payload(self, name: str, zone: str, address: str, address_type: str) -> dict:
        payload = {
            "name": name,
            "zone": zone
        }
        if address_type == "fqdn":
            payload["domain"] = address
            payload["dns_ttl"] = 0
        elif address_type == "cidr":
            payload["network"] = self._generate_subnet_netmask(address)
        else:
            payload["host"] = {
                "ip": address
            }

        object_type = address_type
        if address_type == "cidr":
            object_type = "ipv4"

        return {
            "address_objects": [{
                object_type: payload
            }]
        } 
开发者ID:rapid7,项目名称:insightconnect-plugins,代码行数:26,代码来源:action.py

示例2: test_bitcoin_based_network_definitions

# 需要导入模块: import validators [as 别名]
# 或者: from validators import domain [as 别名]
def test_bitcoin_based_network_definitions(network):
    assert isinstance(network.API, bool)
    assert isinstance(network.name, str)
    assert isinstance(network.symbols, tuple)
    assert isinstance(network().default_symbol, str)
    assert getattr(network, 'seeds') or getattr(network, 'nodes'), f'[{network.__name__}] no seeds and nodes'
    if network.nodes:
        assert isinstance(network.nodes, tuple)
        assert not network.seeds, f'{network}: use nodes or seeds, not both.'
        for node in network.nodes:
            assert ipaddress.ip_address(node)
    else:
        assert isinstance(network.seeds, tuple)
        for seed in network.seeds:
            assert domain(seed)
    assert isinstance(network.port, int)
    assert isinstance(network.blacklist_nodes, dict)
    assert isinstance(network.message_start, bytes)
    assert isinstance(network.base58_prefixes, dict)
    assert isinstance(network.source_code_url, str)
    if network.bitcoin_based and network.API:
        assert isinstance(network.api_url, str)
    if network.blockexplorer_tx:
        assert isinstance(network.blockexplorer_tx, str) 
开发者ID:Lamden,项目名称:clove,代码行数:26,代码来源:test_network.py

示例3: __init__

# 需要导入模块: import validators [as 别名]
# 或者: from validators import domain [as 别名]
def __init__(self, project_name, server_name_or_ip, static_url,
                 gunicorn_file, nginx_file, project_file, virtualenv_file):
        """
        :param project_name: Django project folder
        :param server_name_or_ip: Server ip or domain
        :param static_url: Django settings.py STATIC_URL address
        :param gunicorn_file : gunicorn file name
        :param nginx_file : nginx file name
        :param virtualenv_file : virtualenv file directory
        """

        self.project_name = project_name
        self.server_name_or_ip = server_name_or_ip
        self.static_url = static_url
        self.gunicorn_file = gunicorn_file
        self.nginx_file = nginx_file
        self.project_file = project_file
        self.virtualenv_file = virtualenv_file

        # package.json read.
        with open("{}/client/file/package.json".format(BASE_DIR)) as data_file:
            self.data = json.load(data_file) 
开发者ID:AliYmn,项目名称:djeasy,代码行数:24,代码来源:management.py

示例4: to_dict

# 需要导入模块: import validators [as 别名]
# 或者: from validators import domain [as 别名]
def to_dict(self):
        self.intel_dict['indicator_type'] = self.indicator_type
        self.intel_dict['ipaddress'] = self.ipaddress
        self.intel_dict['domain'] = self.domain
        self.intel_dict['domain_usage'] = self.domain_usage
        self.intel_dict['description'] = self.description
        self.intel_dict['url'] = self.url
        self.intel_dict['md5_hash'] = self.md5_hash
        self.intel_dict['sha1_hash'] = self.sha1_hash
        self.intel_dict['sha256_hash'] = self.sha256_hash
        self.intel_dict['src_port'] = self.src_port
        self.intel_dict['dst_port'] = self.dst_port
        self.intel_dict['proxy'] = self.proxy
        self.intel_dict['source'] = self.source
        self.intel_dict['submission_timestamp'] = self.submission_timestamp
        self.intel_dict['feed_date'] = self.feed_date
        self.intel_dict['country'] = self.country
        self.intel_dict['region'] = self.region
        self.intel_dict['city'] = self.city
        self.intel_dict['whois'] = self.whois
        return self.intel_dict 
开发者ID:securityclippy,项目名称:elasticintel,代码行数:23,代码来源:intel.py

示例5: VTSearch

# 需要导入模块: import validators [as 别名]
# 或者: from validators import domain [as 别名]
def VTSearch(value, uas, proxies):
    server = "www.virustotal.com"
    results = ""

    try:
        url = "https://" + server + "/en/domain/" + value + "/information/"
        s = requests.Session()
        r = s.get(url, verify=False, headers={'User-Agent': PickRandomUA(uas)}, proxies=proxies)
        if r.status_code != 200:
            print("[-] Something is going wrong (status code: {})".format(r.status_code))
            return [], []
        results += r.text
    except Exception as e:
        print(e)

    return GetHostnames(results, value) 
开发者ID:twelvesec,项目名称:gasmask,代码行数:18,代码来源:gasmask.py

示例6: validate_domain

# 需要导入模块: import validators [as 别名]
# 或者: from validators import domain [as 别名]
def validate_domain(self):
        """
        Use domain validator to confirm domain name. 
        :return: BOOL
        """
        try:
            val = domain(str(self.subdomain))
            if val:
                # domain is valid
                return True
            else:
                # domain validation failed
                return False
        except Exception as e:
            # TODO: add in logger class for errors
            return False 
开发者ID:SimplySecurity,项目名称:simplydomain,代码行数:18,代码来源:core_scrub.py

示例7: query_crtsh

# 需要导入模块: import validators [as 别名]
# 或者: from validators import domain [as 别名]
def query_crtsh(provided_ioc, session):
    """Search crt.sh for the given domain."""
    if sys.argv[1] == "subdomain":
        provided_ioc = "%25.{}".format(provided_ioc)
    elif sys.argv[1] == "wildcard":
        provided_ioc = "%25{}".format(provided_ioc)

    base_url  = "https://crt.sh/?q={}&output=json"
    url       = base_url.format(provided_ioc)
    resp      = session.get(url, timeout=180)
    crt_dicts = []

    if resp.status_code == 200 and resp.content != "":
        content      = resp.content.decode("UTF-8")
        cert_history = json.loads("{}".format(content.replace("}{", "},{")))
        # cert_history = json.loads("[{}]".format(content.replace("}{", "},{")))

        for cert in cert_history:
            cert = commons.lower_keys(cert)
            crt_dicts.append(cert)
    else:
        provided_ioc = provided_ioc.replace("%25.", "").replace("%25", "")
        crt_dicts.append({"no data": provided_ioc})
    return crt_dicts 
开发者ID:ecstatic-nobel,项目名称:OSweep,代码行数:26,代码来源:crtsh.py

示例8: _determine_address_type

# 需要导入模块: import validators [as 别名]
# 或者: from validators import domain [as 别名]
def _determine_address_type(address: str) -> str:
        if validators.ipv4(address):
            return "ipv4"
        if validators.ipv6(address):
            return "ipv6"
        if validators.domain(address):
            return "fqdn"
        if re.search('/', address):
            return "cidr"
        raise PluginException(cause="Unknown address type provided.",
                              assistance=f"{address} is not one of the following: IPv4, IPv6, CIDR or domain name.") 
开发者ID:rapid7,项目名称:insightconnect-plugins,代码行数:13,代码来源:action.py

示例9: get_data_type

# 需要导入模块: import validators [as 别名]
# 或者: from validators import domain [as 别名]
def get_data_type(indicator):
        if validators.ipv4(indicator) or validators.ipv6(indicator):
            return "IP"
        elif validators.url(indicator):
            return "URL"
        elif validators.domain(indicator):
            return "DOMAIN"
        elif validators.sha1(indicator):
            return "FILE_SHA1"

        raise PluginException(
            cause="Invalid indicator input provided.",
            assistance="Supported indicators are IP, URL, domain and SHA1 hash."
        ) 
开发者ID:rapid7,项目名称:insightconnect-plugins,代码行数:16,代码来源:action.py

示例10: test_account_data

# 需要导入模块: import validators [as 别名]
# 或者: from validators import domain [as 别名]
def test_account_data(account):
    assert isinstance(account, Account)
    assert account.uid > 0
    assert account.username != ''
    assert validators.email(account.email)

    username, domain = account.email.split('@')
    assert account.username == username
    assert validators.domain(domain) 
开发者ID:mimesis-lab,项目名称:mimesis-factory,代码行数:11,代码来源:test_raw_objects.py

示例11: validate_url

# 需要导入模块: import validators [as 别名]
# 或者: from validators import domain [as 别名]
def validate_url(url):
    """
    Validates the URL
    :param url:
    :return:
    """
    if validators.url(url):
        return url
    elif validators.domain(url):
        return "http://{}".format(url)
    return "" 
开发者ID:pyupio,项目名称:changelogs,代码行数:13,代码来源:finder.py

示例12: validate_hostname

# 需要导入模块: import validators [as 别名]
# 或者: from validators import domain [as 别名]
def validate_hostname(value):
    values = value.split(':')

    if len(values) != 2:
        return False

    return validate_domain(values[0]) and values[1].isdigit() 
开发者ID:fastlane-queue,项目名称:fastlane,代码行数:9,代码来源:api.py

示例13: test_json_is_valid

# 需要导入模块: import validators [as 别名]
# 或者: from validators import domain [as 别名]
def test_json_is_valid(self):
        with open("../world_universities_and_domains.json", encoding='utf-8') as json_file:
            valid_json = json.load(json_file)
        for university in valid_json:
            self.assertIn("name", university)
            self.assertIn("domains", university)
            self.assertIsInstance(university["domains"], list)
            for domain in university["domains"]:
                self.assertTrue(validators.domain(domain))
            self.assertIn("web_pages", university)
            self.assertIn("alpha_two_code", university)
            self.assertIn("state-province", university)
            self.assertIn("country", university) 
开发者ID:Hipo,项目名称:university-domains-list,代码行数:15,代码来源:main.py

示例14: check_valid_url

# 需要导入模块: import validators [as 别名]
# 或者: from validators import domain [as 别名]
def check_valid_url(url):

    """

    :type url: string

    """
    return validators.domain(url) 
开发者ID:david3107,项目名称:squatm3,代码行数:10,代码来源:checkvalidity.py

示例15: create

# 需要导入模块: import validators [as 别名]
# 或者: from validators import domain [as 别名]
def create(team):
    """
    Create a participant or host team.
    """
    """
    Invoked by running `evalai teams create`
    """
    is_host = False
    if team not in ("host", "participant"):
        echo(
            "Sorry, wrong argument. Please choose either "
            "{} or {}.".format(
                style("participant", bold=True, fg="yellow"),
                style("host", bold=True, fg="yellow"),
            )
        )
        sys.exit(1)

    team_name = click.prompt("Enter team name", type=str)
    if click.confirm(
        "Please confirm the team name - {}".format(team_name), abort=True
    ):
        team_url = ""
        if click.confirm("Do you want to enter the Team URL"):
            team_url = click.prompt("Team URL", type=str)
            while not (
                validators.url(team_url) or validators.domain(team_url)
            ):
                echo(
                    style(
                        "Sorry, please enter a valid link.",
                        bold=True,
                        fg="red",
                    )
                )
                team_url = click.prompt("Team URL", type=str)

        is_host = team == "host"
        create_team(team_name, team_url, is_host) 
开发者ID:Cloud-CV,项目名称:evalai-cli,代码行数:41,代码来源:teams.py


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