403Webshell
Server IP : 172.67.158.161  /  Your IP : 3.15.195.18
Web Server : LiteSpeed
System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : giankuin ( 1871)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/self/root/opt/imunify360/venv/lib64/python3.11/site-packages/defence360agent/migrations/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/opt/imunify360/venv/lib64/python3.11/site-packages/defence360agent/migrations//111_ignore_list_ip_as_int.py
import ipaddress


def migrate(migrator, database, fake=False, **kwargs):
    if fake:
        return

    IgnoreListNew = migrator.orm["ignore_list_new"]
    IgnoreList = migrator.orm["ignore_list"]
    try:
        from im360.utils.validate import IP
        from im360.utils.net import pack_ip_network
    except ImportError:
        pass
    else:
        with database.atomic():
            # FIXME: after migrating to peewee 3 add .iterator()
            ip_strings = [item["ip"] for item in IgnoreList.select().dicts()]
            ips = set()
            for item in ip_strings:
                try:
                    ip = ipaddress.ip_network(item)
                except ValueError:
                    # malformed ip
                    continue
                ips.add(ip)
            for ip in ips:
                net, mask, version = pack_ip_network(ip)
                IgnoreListNew.create(
                    ip=IP.ip_net_to_string(ip),
                    network_address=net,
                    netmask=mask,
                    version=version,
                )

    migrator.sql("DROP TABLE ignore_list")
    migrator.sql("ALTER TABLE ignore_list_new RENAME TO ignore_list")


def rollback(migrator, database, fake=False, **kwargs):
    """Write your rollback migrations here."""
    pass

Youez - 2016 - github.com/yon3zu
LinuXploit