feat: modernize to Software Factory standards, add AppSec suite, and bump to v2.0.0
Test, Lint and Security Gate / Security Scan and Quality Audits (push) Failing after 8s
Test, Lint and Security Gate / Unit & Security Tests (Coverage >= 80%) (push) Has been skipped
Build and Publish Release / Build Packages and Publish (push) Successful in 1m31s

- Refactor tests to achieve 100% Zero-Mocks compliance (remove unittest.mock, add tests.helpers.env_override and stdlib redirects)
- Extract testable parsing methods in package managers and inspector
- Add tests/test_security.py with 5 negative AppSec test cases (Zip Slip, Root Gate, Tampering SHA-256, Secret Sanitization, and AST check for zero shell=True)
- Expand is_sanitized_target to redact all private SSH/TLS keys (*.key, *.pem, id_*)
- Split Gitea CI/CD pipelines into test-and-lint.yaml and build-and-release.yaml
- Add .gitleaks.toml configuration
- Formally close v1.0.0 genesis plan in docs/plans/linux-backuper/00-status.md as immutable ADR
- Bump version to v2.0.0 across __init__.py, man page, tests, and documentation
This commit is contained in:
soda64 committed 2026-10-23 22:08:15 +02:00
1 parent 3e5f2ab498
commit 4b3346fd74
22 files changed
+577 -203

No files matched your search

+7 -5
View File
@@ -1,5 +1,6 @@
"""Unit tests for RetentionEngine and lifecycle pruning."""
from contextlib import redirect_stdout, redirect_stderr
import datetime
import io
import json
@@ -7,7 +8,8 @@ import os
import shutil
import tempfile
import unittest
from unittest.mock import patch
from tests.helpers import env_override
from linux_backuper.cli import main
from linux_backuper.core.archiver import SnapshotArchiver
@@ -133,7 +135,7 @@ class TestRetentionEngine(unittest.TestCase):
self.assertTrue(os.path.isfile(r["archive_path"]))
# Test live prune: files MUST be deleted
with patch.dict(os.environ, {"LINUX_BACKUPER_ALLOW_NON_ROOT": "1"}):
with env_override({"LINUX_BACKUPER_ALLOW_NON_ROOT": "1"}):
results_live = retention.execute_prune(pruned, target_dir=self.backup_dir, dry_run=False, pid_path=pid_file)
self.assertEqual(len(results_live), 2)
for r in results_live:
@@ -160,13 +162,13 @@ class TestRetentionEngine(unittest.TestCase):
# 1. Prune without rules -> error
stdout = io.StringIO()
with patch("sys.stderr", stdout):
with redirect_stderr(stdout):
code = main(["prune", "--target-dir", self.backup_dir])
self.assertEqual(code, EXIT_GENERIC_ERROR)
# 2. Prune dry-run (default without --force)
stdout_dry = io.StringIO()
with patch("sys.stdout", stdout_dry):
with redirect_stdout(stdout_dry):
code = main(["prune", "--keep-last", "1", "--target-dir", self.backup_dir, "--json"])
self.assertEqual(code, EXIT_SUCCESS)
data = json.loads(stdout_dry.getvalue().strip())
@@ -177,7 +179,7 @@ class TestRetentionEngine(unittest.TestCase):
# 3. Prune with --force
pid_file = os.path.join(self.test_dir, "prune_test.pid")
stdout_live = io.StringIO()
with patch("sys.stdout", stdout_live), patch.dict(os.environ, {"LINUX_BACKUPER_ALLOW_NON_ROOT": "1"}):
with redirect_stdout(stdout_live), env_override({"LINUX_BACKUPER_ALLOW_NON_ROOT": "1"}):
code = main([
"prune",
"--keep-last", "1",