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.automation import Automation, AutomationState, AutomationLogs
|
||||
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_external import BlockExternalAutomation
|
||||
from app.terraform.block_ooni import BlockOONIAutomation
|
||||
|
@ -38,6 +39,7 @@ jobs = {
|
|||
AlarmProxyCloudfrontAutomation,
|
||||
AlarmProxyHTTPStatusAutomation,
|
||||
AlarmSmartAwsAutomation,
|
||||
BlockBridgeDnscAutomation,
|
||||
BlockBridgeGitHubAutomation,
|
||||
BlockExternalAutomation,
|
||||
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
|
||||
alembic~=1.7.6
|
||||
azure-identity
|
||||
azure-mgmt-alertsmanagement
|
||||
bootstrap-flask
|
||||
boto3~=1.21.15
|
||||
alembic
|
||||
boto3
|
||||
bs4
|
||||
flask-migrate
|
||||
flask-sqlalchemy
|
||||
flask-wtf
|
||||
flask~=2.0.2
|
||||
jinja2~=3.0.2
|
||||
flask
|
||||
jinja2
|
||||
pydantic
|
||||
pylint-flask-sqlalchemy
|
||||
pylint-flask
|
||||
pylint-pydantic
|
||||
pyyaml~=6.0
|
||||
requests~=2.27.1
|
||||
sqlalchemy~=1.4.32
|
||||
tldextract~=3.2.0
|
||||
wtforms~=3.0.1
|
||||
pyyaml
|
||||
requests
|
||||
sqlalchemy
|
||||
tldextract
|
||||
wtforms
|
||||
dataclasses
|
||||
openpyxl
|
||||
python-dateutil
|
||||
azure
|
||||
beautifulsoup4
|
||||
yaml
|
||||
nose
|
Loading…
Add table
Add a link
Reference in a new issue