|
11 | 11 | import re |
12 | 12 | import subprocess |
13 | 13 | import sys |
| 14 | +import tempfile |
14 | 15 | from pathlib import Path |
15 | 16 |
|
16 | 17 | REQUIRED = { |
@@ -221,7 +222,6 @@ def main() -> int: |
221 | 222 | # Ensure the public-site template renders without leaving placeholder tokens. |
222 | 223 | template_dir = root / "public-site/site-template" |
223 | 224 | if template_dir.is_dir(): |
224 | | - import tempfile |
225 | 225 | with tempfile.TemporaryDirectory(prefix="vibmail-public-render-") as temporary: |
226 | 226 | destination = Path(temporary) / "site" |
227 | 227 | code, output = run( |
@@ -275,24 +275,28 @@ def main() -> int: |
275 | 275 |
|
276 | 276 | if args.full: |
277 | 277 | app = root / "mailbox-app" |
278 | | - commands = [ |
279 | | - ([sys.executable, "-m", "pytest", "--cov=apps", "--cov-report=term-missing", "--cov-fail-under=85"], app, "PYTEST_COVERAGE", True), |
280 | | - ([sys.executable, "-m", "ruff", "check", "."], app, "RUFF", True), |
281 | | - ([sys.executable, "-m", "bandit", "-c", ".bandit", "-q", "-r", "apps", "config"], app, "BANDIT", True), |
282 | | - ([sys.executable, "manage.py", "makemigrations", "--check", "--dry-run", "--settings=config.settings.test"], app, "MIGRATION_DRIFT", True), |
283 | | - ([sys.executable, "manage.py", "check", "--settings=config.settings.test"], app, "DJANGO_CHECK", True), |
284 | | - ([sys.executable, "test_contact_app.py"], root / "public-site/contact_service", "CONTACT_TESTS", False), |
285 | | - ([sys.executable, "-m", "pip", "check"], root, "PIP_CHECK", False), |
286 | | - ] |
287 | | - for command, cwd, label, django_environment in commands: |
288 | | - env = os.environ.copy() |
289 | | - if django_environment: |
290 | | - env["DJANGO_SETTINGS_MODULE"] = "config.settings.test" |
291 | | - else: |
292 | | - env.pop("DJANGO_SETTINGS_MODULE", None) |
293 | | - completed = subprocess.run(command, cwd=cwd, env=env, text=True, capture_output=True) |
294 | | - if completed.returncode: |
295 | | - findings.append(f"{label}:{(completed.stdout + completed.stderr).strip()}") |
| 278 | + with tempfile.TemporaryDirectory(prefix="mailstack-full-audit-") as temporary: |
| 279 | + coverage_file = Path(temporary) / ".coverage" |
| 280 | + commands = [ |
| 281 | + ([sys.executable, "-m", "pytest", "--cov=apps", "--cov-report=term-missing", "--cov-fail-under=85"], app, "PYTEST_COVERAGE", True), |
| 282 | + ([sys.executable, "-m", "ruff", "check", "."], app, "RUFF", True), |
| 283 | + ([sys.executable, "-m", "bandit", "-c", ".bandit", "-q", "-r", "apps", "config"], app, "BANDIT", True), |
| 284 | + ([sys.executable, "manage.py", "makemigrations", "--check", "--dry-run", "--settings=config.settings.test"], app, "MIGRATION_DRIFT", True), |
| 285 | + ([sys.executable, "manage.py", "check", "--settings=config.settings.test"], app, "DJANGO_CHECK", True), |
| 286 | + ([sys.executable, "test_contact_app.py"], root / "public-site/contact_service", "CONTACT_TESTS", False), |
| 287 | + ([sys.executable, "-m", "pip", "check"], root, "PIP_CHECK", False), |
| 288 | + ] |
| 289 | + for command, cwd, label, django_environment in commands: |
| 290 | + env = os.environ.copy() |
| 291 | + if django_environment: |
| 292 | + env["DJANGO_SETTINGS_MODULE"] = "config.settings.test" |
| 293 | + else: |
| 294 | + env.pop("DJANGO_SETTINGS_MODULE", None) |
| 295 | + if label == "PYTEST_COVERAGE": |
| 296 | + env["COVERAGE_FILE"] = str(coverage_file) |
| 297 | + completed = subprocess.run(command, cwd=cwd, env=env, text=True, capture_output=True) |
| 298 | + if completed.returncode: |
| 299 | + findings.append(f"{label}:{(completed.stdout + completed.stderr).strip()}") |
296 | 300 |
|
297 | 301 | print("=== MAILSTACK FORENSIC SOURCE AUDIT ===") |
298 | 302 | print(f"ROOT={root}") |
|
0 commit comments