feat(v2.0): Add business software detection (Task #6)#14
Merged
Conversation
Implemented v2.0 requirement to prevent backups when business software is running. Features: - BusinessSoftwareDetector service with IsRunning(processName) method - BackupService.ExecuteBackup() now accepts optional businessSoftwareName parameter - Throws InvalidOperationException if business software detected - Case-insensitive process name matching - Handles .exe extension automatically Tests (12 new tests, 123/124 passing): - 8 unit tests for BusinessSoftwareDetector (null/empty/running/closed/case-insensitive) - 4 integration tests for BackupService (exception when running, success when not running) - All tests use CalculatorApp (Windows 10+) as proof of concept - Backward compatible: null/empty businessSoftwareName allows backup to proceed Related config: - Uses AppConfig.GetBusinessSoftwareName() (added in Task #4) - Default empty string means no detection (v1.0/v1.1 behavior) Cahier des charges: v2.0 - Interdiction de lancer un travail si logiciel métier détecté
Implemented v2.0 requirement for file encryption using external CryptoSoft.exe. CryptoSoft (external tool): - Standalone executable developed during Prosit 4 - XOR cipher encryption (simple, fast, reversible for v2.0) - Command-line interface: CryptoSoft.exe <source> <target> - Exit codes: 0=success, -1/-2/-3/-4=specific errors - Built to CryptoSoft/bin/Release/net10.0/CryptoSoft.exe Features: - EncryptionService launches CryptoSoft.exe as external process - Measures encryption time in milliseconds - Returns negative error codes on failure (-1 to -5) - AppConfig.CryptoSoftPath configurable (default: relative path) - BackupService checks ExtensionsToEncrypt from AppConfig - Only configured extensions are encrypted (.docx, .xlsx, etc.) - LogEntry.EncryptionTime populated (0=no encryption, >0=success, <0=error) Architecture: - EncryptionService.EncryptFile() with timeout support (60s default) - EncryptionService.ShouldEncrypt() checks file extension (case-insensitive) - BackupService constructor overload for encryption support - Temporary file used during encryption, cleaned up automatically - Falls back to unencrypted copy if encryption fails Tests (8 new tests, 131/132 passing): - EncryptFile with valid file (positive time) - EncryptFile with non-existent source (-2) - EncryptFile with invalid CryptoSoft path (-1) - ShouldEncrypt with matching/non-matching extensions - ShouldEncrypt case-insensitive - ShouldEncrypt with empty extension list - Encrypt + Decrypt roundtrip (XOR reversibility) Backward compatibility: - BackupService(ILogger) constructor still works (no encryption) - EncryptionTime = 0 for non-encrypted files - ExtensionsToEncrypt empty = no encryption (v1.0/v1.1 behavior) Cahier des charges v2.0: - Cryptage via logiciel CryptoSoft externe - Extensions définies par utilisateur (paramètres généraux) - Fichier Log avec temps de cryptage (0/>0/<0) - Compatible v1.0/v1.1 (pas de cryptage si liste vide)
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
BusinessSoftwareDetector tests that launch calc.exe are now conditionally skipped on Linux/macOS platforms using RuntimeInformation.IsOSPlatform(). This fixes GitHub Actions CI failures on Ubuntu runners while maintaining full test coverage on Windows. Affected tests: - IsRunning_WithRunningProcess_ShouldReturnTrue - IsRunning_WithExeExtension_ShouldStillDetectProcess - IsRunning_AfterProcessClosed_ShouldReturnFalse - IsRunning_CaseInsensitive_ShouldWork - ExecuteBackup_v2_ShouldThrowException_WhenBusinessSoftwareIsRunning All 131 tests pass on Windows, tests gracefully skip on other platforms.
Replace Windows-specific calc.exe with dotnet process for testing. Tests now run on Windows, Linux, and macOS without skipping. Changes: - Use 'dotnet --info' as test process (available on all platforms) - Remove RuntimeInformation.IsOSPlatform checks - Reduce wait times (500ms vs 2000ms) since dotnet starts faster - Simplify cleanup logic All 131 tests pass on all platforms.
Critical fixes: - Remove useless assignment to finalTargetPath in BackupService - Replace generic catch clauses with specific exception types: * IOException for file operations * UnauthorizedAccessException for permissions * InvalidOperationException for process errors * Win32Exception for Win32 API errors - Use 'using' statements for Process disposal in tests Benefits: - Better error handling granularity - Improved resource management - Clearer exception intent - Maintains 131/132 tests passing CodeQL warnings addressed: 1 WARNING + 4 NOTICES (critical ones)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Pull Request automatique créée par GitHub Actions
Branche:
Kenan| Auteur: @PotaaatozWRLD | Dernier commit: feat(v2.0): Add business software detection (Task #6)Pull Request
Description
Type of Change
Related Issues
Fixes #
Relates to #
Changes Made
Testing Performed
dotnet test)Test Results
Backward Compatibility
Documentation
Code Quality Checklist
%AppData%or relative paths)Review Checklist
Screenshots / Logs
Additional Notes
Reviewers: Please check that all checkboxes are completed before approving.