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.

fix(ci): prevent test process rlimit mutation causing MemoryError and add CI job timeouts

Mafifrizi3eb80f805d86
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 10c3c25..ae8224e 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -19,6 +19,7 @@ jobs:
backend:
name: Backend Unit Tests
runs-on: ubuntu-latest
+ timeout-minutes: 25
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
@@ -33,6 +34,7 @@ jobs:
postgres:
name: PostgreSQL Integration Tests
runs-on: ubuntu-latest
+ timeout-minutes: 40
services:
postgres:
image: postgres:16
@@ -69,6 +71,7 @@ jobs:
frontend:
name: Frontend Build
runs-on: ubuntu-latest
+ timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
diff --git a/tests/conftest.py b/tests/conftest.py
index 7d97fb4..3219dd0 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -58,6 +58,19 @@ def set_test_env():
# ── Temporary directories ─────────────────────────────────────────────────────
[email protected](autouse=True)
+def protect_runner_rlimits(monkeypatch: pytest.MonkeyPatch):
+ """Ensure in-process unit tests on Linux never mutate pytest runner's own OS rlimits."""
+ if sys.platform != "win32":
+ try:
+ import ares.core.sandbox
+ if getattr(ares.core.sandbox, "resource", None) is not None:
+ mock_resource = MagicMock()
+ monkeypatch.setattr("ares.core.sandbox.resource", mock_resource)
+ except (ImportError, AttributeError):
+ pass
+
+
@pytest.fixture(autouse=True)
def forbid_unmocked_pdf_browser_launch(monkeypatch: pytest.MonkeyPatch):
"""Unit tests must mock PDF browser execution instead of launching Chrome/Edge."""
diff --git a/tests/unit/test_hardening.py b/tests/unit/test_hardening.py
index 96316d7..0d8bea5 100644
--- a/tests/unit/test_hardening.py
+++ b/tests/unit/test_hardening.py
@@ -2617,6 +2617,9 @@ class TestStrictModeIntegrityAndTierTruthfulness:
monkeypatch.setattr("os.setuid", mock_setuid, raising=False)
monkeypatch.setattr("os.geteuid", lambda: current_id[0], raising=False)
monkeypatch.setattr("os.getuid", lambda: current_id[0], raising=False)
+ # Mock sandbox.resource to prevent rlimit mutation in simulated child execution
+ mock_resource = MagicMock()
+ monkeypatch.setattr("ares.core.sandbox.resource", mock_resource)
# Mock pwd account where UID 1001 != primary GID 2002
fake_pw = MagicMock()