feat: remove block_bridge_dnsc
no longer used
This commit is contained in:
parent
5c0170bdef
commit
9674cb4293
4 changed files with 14 additions and 59 deletions
|
@ -13,7 +13,6 @@ from app.models.activity import Activity
|
||||||
from app.models.automation import Automation, AutomationState, AutomationLogs
|
from app.models.automation import Automation, AutomationState, AutomationLogs
|
||||||
from app.terraform import BaseAutomation
|
from app.terraform import BaseAutomation
|
||||||
from app.terraform.block.block_blocky import BlockBlockyAutomation
|
from app.terraform.block.block_blocky import BlockBlockyAutomation
|
||||||
from app.terraform.block.bridge_dnsc import BlockBridgeDnscAutomation
|
|
||||||
from app.terraform.block.bridge_github import BlockBridgeGitHubAutomation
|
from app.terraform.block.bridge_github import BlockBridgeGitHubAutomation
|
||||||
from app.terraform.block.bridge_gitlab import BlockBridgeGitlabAutomation
|
from app.terraform.block.bridge_gitlab import BlockBridgeGitlabAutomation
|
||||||
from app.terraform.block.bridge_roskomsvoboda import BlockBridgeRoskomsvobodaAutomation
|
from app.terraform.block.bridge_roskomsvoboda import BlockBridgeRoskomsvobodaAutomation
|
||||||
|
@ -47,7 +46,6 @@ jobs = {
|
||||||
x.short_name: x # type: ignore[attr-defined]
|
x.short_name: x # type: ignore[attr-defined]
|
||||||
for x in [
|
for x in [
|
||||||
# Check for blocked resources first
|
# Check for blocked resources first
|
||||||
BlockBridgeDnscAutomation,
|
|
||||||
BlockBridgeGitHubAutomation,
|
BlockBridgeGitHubAutomation,
|
||||||
BlockBridgeGitlabAutomation,
|
BlockBridgeGitlabAutomation,
|
||||||
BlockBridgeRoskomsvobodaAutomation,
|
BlockBridgeRoskomsvobodaAutomation,
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
from io import BytesIO
|
|
||||||
from typing import BinaryIO
|
|
||||||
|
|
||||||
import openpyxl
|
|
||||||
import requests
|
|
||||||
|
|
||||||
from app.terraform.block.bridge import BlockBridgeAutomation
|
|
||||||
|
|
||||||
DOWNLOAD_URL = "https://dnsc.ro/vezi/document/situatie-site-uri-cu-activitate-in-contextul-crizei-ucraina-rusia-plus" \
|
|
||||||
"-adrese-ip-specifice-utilizate-in-atacuri-malware-detalii"
|
|
||||||
|
|
||||||
|
|
||||||
class BlockBridgeDnscAutomation(BlockBridgeAutomation):
|
|
||||||
short_name = "block_bridge_dnsc"
|
|
||||||
description = "Import the Romanian National Directorate for Cybersecurity blocklist"
|
|
||||||
frequency = 60 * 24
|
|
||||||
|
|
||||||
_content: BinaryIO
|
|
||||||
|
|
||||||
def fetch(self) -> None:
|
|
||||||
response = requests.get(DOWNLOAD_URL,
|
|
||||||
headers={"User-Agent": "Mozilla/5.0 (Windows NT x.y; Win64; x64; rv:10.0) "
|
|
||||||
"Gecko/20100101 Firefox/10.0"},
|
|
||||||
timeout=60)
|
|
||||||
self._content = BytesIO(response.content)
|
|
||||||
|
|
||||||
def parse(self) -> None:
|
|
||||||
wb = openpyxl.open(self._content)
|
|
||||||
sheet = wb[wb.sheetnames[0]]
|
|
||||||
idx = 2
|
|
||||||
while True:
|
|
||||||
addr = sheet['B' + str(idx)].value
|
|
||||||
if not addr:
|
|
||||||
break
|
|
||||||
self.ips.append(addr)
|
|
||||||
idx += 1
|
|
|
@ -27,12 +27,12 @@ def update_smart_proxy_instance(group_id: int,
|
||||||
).first()
|
).first()
|
||||||
if instance is None:
|
if instance is None:
|
||||||
instance = SmartProxy()
|
instance = SmartProxy()
|
||||||
instance.added = datetime.datetime.utcnow()
|
instance.added = datetime.datetime.now(datetime.UTC)
|
||||||
instance.group_id = group_id
|
instance.group_id = group_id
|
||||||
instance.provider = provider
|
instance.provider = provider
|
||||||
instance.region = region
|
instance.region = region
|
||||||
db.session.add(instance)
|
db.session.add(instance)
|
||||||
instance.updated = datetime.datetime.utcnow()
|
instance.updated = datetime.datetime.now(datetime.UTC)
|
||||||
instance.instance_id = instance_id
|
instance.instance_id = instance_id
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ import logging
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from datetime import timezone
|
|
||||||
from typing import Any, Dict, List, Optional, Tuple, Type
|
from typing import Any, Dict, List, Optional, Tuple, Type
|
||||||
from typing import OrderedDict as OrderedDictT
|
from typing import OrderedDict as OrderedDictT
|
||||||
|
|
||||||
|
@ -139,26 +138,20 @@ def auto_deprecate_proxies() -> None:
|
||||||
"""
|
"""
|
||||||
origin_destroyed_proxies = (db.session.query(Proxy)
|
origin_destroyed_proxies = (db.session.query(Proxy)
|
||||||
.join(Origin, Proxy.origin_id == Origin.id)
|
.join(Origin, Proxy.origin_id == Origin.id)
|
||||||
.filter(
|
.filter(Proxy.destroyed.is_(None),
|
||||||
Proxy.destroyed.is_(None),
|
|
||||||
Proxy.deprecated.is_(None),
|
Proxy.deprecated.is_(None),
|
||||||
Origin.destroyed.is_not(None),
|
Origin.destroyed.is_not(None))
|
||||||
)
|
.all())
|
||||||
.all()
|
|
||||||
)
|
|
||||||
for proxy in origin_destroyed_proxies:
|
for proxy in origin_destroyed_proxies:
|
||||||
proxy.deprecate(reason="origin_destroyed")
|
proxy.deprecate(reason="origin_destroyed")
|
||||||
max_age_proxies = (db.session.query(Proxy)
|
max_age_proxies = (db.session.query(Proxy)
|
||||||
.join(Origin, Proxy.origin_id == Origin.id)
|
.join(Origin, Proxy.origin_id == Origin.id)
|
||||||
.filter(
|
.filter(Proxy.destroyed.is_(None),
|
||||||
Proxy.destroyed.is_(None),
|
|
||||||
Proxy.deprecated.is_(None),
|
Proxy.deprecated.is_(None),
|
||||||
Proxy.pool_id != -1, # do not rotate hotspare proxies
|
Proxy.pool_id != -1, # do not rotate hotspare proxies
|
||||||
Origin.assets,
|
Origin.assets,
|
||||||
Origin.auto_rotation,
|
Origin.auto_rotation)
|
||||||
)
|
.all())
|
||||||
.all()
|
|
||||||
)
|
|
||||||
for proxy in max_age_proxies:
|
for proxy in max_age_proxies:
|
||||||
max_age_cutoff = datetime.datetime.now(datetime.UTC) - datetime.timedelta(
|
max_age_cutoff = datetime.datetime.now(datetime.UTC) - datetime.timedelta(
|
||||||
days=1, seconds=86400 * random.random()) # nosec: B311
|
days=1, seconds=86400 * random.random()) # nosec: B311
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue