block/bridge: add a dnsc module
This commit is contained in:
parent
3ed6f0908a
commit
0c4929592a
3 changed files with 52 additions and 18 deletions
|
@ -9,6 +9,7 @@ from app.extensions import db
|
||||||
from app.models.activity import Activity
|
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.bridge_dnsc import BlockBridgeDnscAutomation
|
||||||
from app.terraform.block.bridge_github import BlockBridgeGitHubAutomation
|
from app.terraform.block.bridge_github import BlockBridgeGitHubAutomation
|
||||||
from app.terraform.block_external import BlockExternalAutomation
|
from app.terraform.block_external import BlockExternalAutomation
|
||||||
from app.terraform.block_ooni import BlockOONIAutomation
|
from app.terraform.block_ooni import BlockOONIAutomation
|
||||||
|
@ -38,6 +39,7 @@ jobs = {
|
||||||
AlarmProxyCloudfrontAutomation,
|
AlarmProxyCloudfrontAutomation,
|
||||||
AlarmProxyHTTPStatusAutomation,
|
AlarmProxyHTTPStatusAutomation,
|
||||||
AlarmSmartAwsAutomation,
|
AlarmSmartAwsAutomation,
|
||||||
|
BlockBridgeDnscAutomation,
|
||||||
BlockBridgeGitHubAutomation,
|
BlockBridgeGitHubAutomation,
|
||||||
BlockExternalAutomation,
|
BlockExternalAutomation,
|
||||||
BlockOONIAutomation,
|
BlockOONIAutomation,
|
||||||
|
|
34
app/terraform/block/bridge_dnsc.py
Normal file
34
app/terraform/block/bridge_dnsc.py
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
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):
|
||||||
|
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"})
|
||||||
|
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
|
|
@ -1,21 +1,19 @@
|
||||||
PyGithub
|
PyGithub
|
||||||
alembic~=1.7.6
|
alembic
|
||||||
azure-identity
|
boto3
|
||||||
azure-mgmt-alertsmanagement
|
|
||||||
bootstrap-flask
|
|
||||||
boto3~=1.21.15
|
|
||||||
bs4
|
bs4
|
||||||
flask-migrate
|
flask
|
||||||
flask-sqlalchemy
|
jinja2
|
||||||
flask-wtf
|
|
||||||
flask~=2.0.2
|
|
||||||
jinja2~=3.0.2
|
|
||||||
pydantic
|
pydantic
|
||||||
pylint-flask-sqlalchemy
|
pyyaml
|
||||||
pylint-flask
|
requests
|
||||||
pylint-pydantic
|
sqlalchemy
|
||||||
pyyaml~=6.0
|
tldextract
|
||||||
requests~=2.27.1
|
wtforms
|
||||||
sqlalchemy~=1.4.32
|
dataclasses
|
||||||
tldextract~=3.2.0
|
openpyxl
|
||||||
wtforms~=3.0.1
|
python-dateutil
|
||||||
|
azure
|
||||||
|
beautifulsoup4
|
||||||
|
yaml
|
||||||
|
nose
|
Loading…
Add table
Add a link
Reference in a new issue