Skip to content

armgit / ARES

Public Imported from GitHub
0

ARES - authorized red-team engagement automation with dashboard, campaign scope, module orchestration, OPSEC controls, encrypted vault, and reporting.

refactor(deps): replace netaddr with stdlib ipaddress, prune 5 unused dependencies

Mafifrizidb49db41e22e
diff --git a/README.md b/README.md
index 1536593..f28fab8 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@
[![Version](https://img.shields.io/badge/Release-v6.0--Enterprise-red?style=for-the-badge&logo=shield)](releases/)
[![Python](https://img.shields.io/badge/Engine-Python%203.12%2B-3776AB?style=for-the-badge&logo=python&logoColor=white)](https://python.org)
[![FastAPI](https://img.shields.io/badge/Backend-FastAPI%20Async-009688?style=for-the-badge&logo=fastapi&logoColor=white)](https://fastapi.tiangolo.com)
-[![React](https://img.shields.io/badge/Frontend-React%2019%20%7C%20Vite-61DAFB?style=for-the-badge&logo=react&logoColor=111111)](https://react.dev)
+[![React](https://img.shields.io/badge/Frontend-React%2018%20%7C%20Vite-61DAFB?style=for-the-badge&logo=react&logoColor=111111)](https://react.dev)
[![MITRE](https://img.shields.io/badge/Coverage-MITRE%20ATT%26CK-FF6F00?style=for-the-badge)](docs/modules.md)
[![Security](https://img.shields.io/badge/Security-Zero--Trust%20Enclave-22C55E?style=for-the-badge)](docs/security-model.md)
[![License](https://img.shields.io/badge/License-MIT-blue?style=for-the-badge)](LICENSE)
diff --git a/ares/api/server.py b/ares/api/server.py
index 6cca7d1..9c21907 100644
--- a/ares/api/server.py
+++ b/ares/api/server.py
@@ -138,10 +138,10 @@ def _campaign_from_db_row(row: Any) -> Campaign:
for s in scope:
if isinstance(s, str):
try:
- from netaddr import IPNetwork
- IPNetwork(s)
+ import ipaddress
+ ipaddress.ip_network(s, strict=False)
coerced_scope.append({"cidr": s, "description": ""})
- except Exception:
+ except (ValueError, TypeError):
continue
elif isinstance(s, dict):
coerced_scope.append(s)
@@ -1950,8 +1950,9 @@ class CampaignCreate(BaseModel):
if not entry:
continue
try:
- IPNetwork(entry)
- except (AddrFormatError, ValueError) as exc:
+ import ipaddress
+ ipaddress.ip_network(entry, strict=False)
+ except (ValueError, TypeError) as exc:
raise ValueError(
f"scope_cidrs[{i}]: {entry!r} is not a valid CIDR or IP range. "
"Examples: '10.0.0.0/24', '192.168.1.10/32'"
diff --git a/ares/core/campaign.py b/ares/core/campaign.py
index c575ce6..f0ecb1e 100644
--- a/ares/core/campaign.py
+++ b/ares/core/campaign.py
@@ -9,7 +9,7 @@ from enum import Enum
from typing import Any
from pydantic import BaseModel, Field, PrivateAttr, field_validator
-from netaddr import IPNetwork, AddrFormatError
+import ipaddress
from ares.core.scope import CampaignScope, CloudScope
@@ -116,8 +116,8 @@ class ScopeEntry(BaseModel):
@classmethod
def validate_cidr(cls, v: str) -> str:
try:
- IPNetwork(v)
- except (AddrFormatError, ValueError) as e:
+ ipaddress.ip_network(v, strict=False)
+ except ValueError as e:
raise ValueError(f"Invalid CIDR: {v}") from e
return v
@@ -241,10 +241,9 @@ class Campaign(BaseModel):
def _check_scope_uncached(self, target: str) -> bool:
try:
- from netaddr import IPAddress
- addr = IPAddress(target)
- return any(addr in IPNetwork(s.cidr) for s in self.scope)
- except (AddrFormatError, ValueError):
+ addr = ipaddress.ip_address(target)
+ return any(addr in ipaddress.ip_network(s.cidr, strict=False) for s in self.scope)
+ except ValueError:
pass
explicit_hosts = {
@@ -270,9 +269,8 @@ class Campaign(BaseModel):
if results:
resolved_ip = results[0][4][0]
- from netaddr import IPAddress as _IPAddr
- addr = _IPAddr(resolved_ip)
- in_scope = any(addr in IPNetwork(s.cidr) for s in self.scope)
+ addr = ipaddress.ip_address(resolved_ip)
+ in_scope = any(addr in ipaddress.ip_network(s.cidr, strict=False) for s in self.scope)
if not in_scope:
_log.warning(
"scope_check_hostname_out_of_scope: %r resolved to %s which is NOT in scope %s",
diff --git a/ares/core/security.py b/ares/core/security.py
index a65d997..fc4f71b 100644
--- a/ares/core/security.py
+++ b/ares/core/security.py
@@ -498,17 +498,17 @@ def sanitize_path(value: str) -> str:
def validate_ip_or_cidr(value: str) -> bool:
"""Returns True if value is a valid IP or CIDR."""
- from netaddr import AddrFormatError, IPAddress, IPNetwork
+ import ipaddress
try:
- IPAddress(value)
+ ipaddress.ip_address(value)
return True
- except (AddrFormatError, ValueError):
+ except (ValueError, TypeError):
pass
try:
- IPNetwork(value)
+ ipaddress.ip_network(value, strict=False)
return True
- except (AddrFormatError, ValueError):
+ except (ValueError, TypeError):
return False
diff --git a/pyproject.toml b/pyproject.toml
index 7da5e58..b531051 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -11,13 +11,11 @@ license = { text = "MIT" }
requires-python = ">=3.10,<3.13"
dependencies = [
# Core
- "click>=8.1",
"rich>=13.7",
"pydantic>=2.6",
"pydantic-settings>=2.2",
"pyyaml>=6.0",
"python-dotenv>=1.0",
- "anyio>=4.3",
# Structured logging
"structlog>=24.1",
@@ -46,13 +44,11 @@ dependencies = [
# Reporting
"jinja2>=3.1",
- "markdown>=3.5",
# Database (async + sync SQLite + migrations)
"aiosqlite>=0.20",
"sqlalchemy[asyncio]>=2.0",
"greenlet>=3.0",
- "aiofiles>=23.2",
"alembic>=1.13", # DB migrations - required for revoked_access_tokens table
# CLI
@@ -60,7 +56,6 @@ dependencies = [
# Network
"dnspython>=2.6",
- "netaddr>=1.2",
]
[project.optional-dependencies]
diff --git a/requirements-lock.txt b/requirements-lock.txt
index 42af9aa..5a58cfb 100644
--- a/requirements-lock.txt
+++ b/requirements-lock.txt
@@ -20,13 +20,11 @@
# pip install -r requirements-lock.txt
#
# Core
-click>=8.1
rich>=13.7
pydantic>=2.6
pydantic-settings>=2.2
pyyaml>=6.0
python-dotenv>=1.0
-anyio>=4.3
structlog>=24.1
# API + Auth
@@ -46,7 +44,6 @@ cryptography>=42.0
# Database
aiosqlite>=0.20
sqlalchemy>=2.0
-aiofiles>=23.2
alembic>=1.13
# Graph
@@ -54,14 +51,12 @@ networkx>=3.3
# Reporting
jinja2>=3.1
-markdown>=3.5
# CLI
typer>=0.12
# Network / DNS
dnspython>=2.6
-netaddr>=1.2
# SSH lateral movement
paramiko>=3.4