chore: remove unused dnstwist integration (#818)
The dnstwist analyze endpoint was never wired into the UI and has no active callers. Drop the backend integration package, router, and the `dnstwist` pin from requirements.in/requirements.txt. The transitive `dnspython==2.4.2` pin is left in requirements.txt — inert until the next pip-compile pass. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
taylor_socfortress committed
Apr 24, 2026 at 16:04 UTC
61c64c24db295d6c4fb9ee88872b966098a71517
9 files changed
-142
backend/app/integrations/dnstwist/routes/analyze.py
deleted
-55
@@ -1,55 +0,0 @@
1
-import regex
2
-from fastapi import APIRouter
3
-from fastapi import Depends
4
-from fastapi import HTTPException
5
-from loguru import logger
6
-
7
-from app.integrations.dnstwist.schema.analyze import DomainAnalysisResponse
8
-from app.integrations.dnstwist.schema.analyze import DomainRequestBody
9
-from app.integrations.dnstwist.services.analyze import analyze_domain
10
-
11
-dnstwist_router = APIRouter()
12
-
13
-
14
-def is_domain(domain: str) -> DomainRequestBody:
15
- """
16
- Check if the provided domain is valid.
17
-
18
- Args:
19
- domain (str): The domain to check.
20
-
21
- Returns:
22
- bool: True if the domain is valid, False otherwise.
23
- """
24
- logger.info(f"Checking if domain {domain} is valid.")
25
- pattern = regex.compile(
26
- r"^(?:[a-zA-Z0-9]+([-._]?[a-zA-Z0-9]+)*\.)+[a-zA-Z]{2,}$",
27
- )
28
- if not pattern.match(domain):
29
- raise HTTPException(status_code=400, detail="Invalid domain")
30
- return DomainRequestBody(domain=domain)
31
-
32
-
33
-@dnstwist_router.post(
34
- "/analyze",
35
- response_model=DomainAnalysisResponse,
36
- status_code=200,
37
- description="Analyze domain with DNS Twist",
38
-)
39
-async def analyze(body: DomainRequestBody = Depends(is_domain)):
40
- """
41
- Analyzes a domain using DNS Twist.
42
-
43
- Args:
44
- body (DomainRequestBody): The request body containing the domain to analyze.
45
-
46
- Returns:
47
- DomainAnalysisResponse: The analysis result for the domain.
48
- """
49
- return analyze_domain(body.domain)
50
-
51
-
52
-# ! TODO: Add phishing analysis - Need more clarification on this
53
-# @dnstwist_router.post('/analyze/phishing', response_model=DomainAnalysisResponse, status_code=200, description='Analyze domain with DNS Twist')
54
-# async def analyze_phishing(body: DomainRequestBody = Depends(is_domain)):
55
-# return analyze_domain_phishing(body.domain)
backend/app/integrations/dnstwist/schema/analyze.py
deleted
-23
@@ -1,23 +0,0 @@
1
-from typing import List
2
-from typing import Optional
3
-
4
-from pydantic import BaseModel
5
-from pydantic import Field
6
-
7
-
8
-class DomainData(BaseModel):
9
- dns_a: Optional[List[str]]
10
- dns_mx: Optional[List[str]]
11
- dns_ns: Optional[List[str]]
12
- domain: str
13
- fuzzer: str
14
-
15
-
16
-class DomainAnalysisResponse(BaseModel):
17
- data: List[DomainData]
18
- message: str
19
- success: bool
20
-
21
-
22
-class DomainRequestBody(BaseModel):
23
- domain: str = Field("socfortress.co", description="The domain to analyze.")
backend/app/integrations/dnstwist/services/analyze.py
deleted
-50
@@ -1,50 +0,0 @@
1
-import dnstwist
2
-from loguru import logger
3
-
4
-from app.integrations.dnstwist.schema.analyze import DomainAnalysisResponse
5
-from app.integrations.dnstwist.schema.analyze import DomainRequestBody
6
-
7
-
8
-def analyze_domain(domain: DomainRequestBody) -> DomainAnalysisResponse:
9
- """
10
- Analyze the domain using dnstwist and return the results for registered domains.
11
-
12
- Args:
13
- domain (DomainRequestBody): The domain to analyze.
14
-
15
- Returns:
16
- DomainAnalysisResponse: The response from DNS Twist.
17
- """
18
- logger.info(f"Analyzing domain {domain} with DNS Twist.")
19
- logger.info("Analyzing domain for registered domains.")
20
- data = dnstwist.run(domain=domain, registered=True, format="json")
21
- return DomainAnalysisResponse(
22
- data=data,
23
- message="Domain analysis completed.",
24
- success=True,
25
- )
26
-
27
-
28
-def analyze_domain_phishing(domain: DomainRequestBody) -> DomainAnalysisResponse:
29
- """
30
- Analyze the domain using dnstwist and return the results for registered domains.
31
-
32
- Args:
33
- domain (DomainRequestBody): The domain to analyze.
34
-
35
- Returns:
36
- DomainAnalysisResponse: The response from DNS Twist.
37
- """
38
- logger.info(f"Analyzing domain {domain} with DNS Twist.")
39
- logger.info("Analyzing domain for registered domains.")
40
- data = dnstwist.run(
41
- domain=domain,
42
- registered=True,
43
- format="json",
44
- lsh=True,
45
- )
46
- return DomainAnalysisResponse(
47
- data=data,
48
- message="Domain analysis completed.",
49
- success=True,
50
- )
backend/app/integrations/dnstwist/utils/universal.py
backend/app/routers/__init__.py
-1
@@ -4,7 +4,6 @@ from .connectors import router as connectors_router
4
from .cortex import router as cortex_router
5
from .customers import router as customers_router
6
from .dfir_iris import router as dfir_iris_router
7
-from .dnstwist import router as dnstwist_router
7
from .graylog import router as graylog_router
8
from .healthcheck import router as healtcheck_router
9
from .logs import router as logs_router
backend/app/routers/dnstwist.py
deleted
-9
@@ -1,9 +0,0 @@
1
-from fastapi import APIRouter
2
-
3
-from app.integrations.dnstwist.routes.analyze import dnstwist_router
4
-
5
-# Instantiate the APIRouter
6
-router = APIRouter()
7
-
8
-# Include the DNS Twist related routes
9
-router.include_router(dnstwist_router, prefix="/dnstwist", tags=["dnstwist"])
backend/copilot.py
-2
@@ -51,7 +51,6 @@ from app.routers import darktrace
51
from app.routers import data_store
52
from app.routers import defenderforendpoint
53
from app.routers import dfir_iris
54
-from app.routers import dnstwist
54
from app.routers import duo
55
from app.routers import github_audit
56
from app.routers import grafana
@@ -144,7 +143,6 @@ api_router.include_router(sublime.router)
143
api_router.include_router(microsoft_patch_tuesday.router)
144
api_router.include_router(customers.router)
145
api_router.include_router(healthcheck.router)
147
-api_router.include_router(dnstwist.router)
146
api_router.include_router(logs.router)
147
api_router.include_router(influxdb.router)
148
api_router.include_router(version.router)
backend/requirements.in
-1
@@ -5,7 +5,6 @@ bcrypt
5
blueprint
6
cortex4py
7
dfir_iris_client
8
-dnstwist
8
elasticsearch7==7.10.1
9
environs
10
fastapi
backend/requirements.txt
-1
@@ -39,7 +39,6 @@ deepdiff==6.5.0
39
Deprecated==1.2.14
40
dfir-iris-client==2.0.4
41
dnspython==2.4.2
42
-dnstwist==20230918
42
docxtpl==0.18.0
43
drawsvg==2.3.0
44
ecdsa==0.18.0