Skip to content

feat(v2.0): Add business software detection (Task #6)#14

Merged
PotaaatozWRLD merged 6 commits into
mainfrom
Kenan
Feb 10, 2026
Merged

feat(v2.0): Add business software detection (Task #6)#14
PotaaatozWRLD merged 6 commits into
mainfrom
Kenan

Conversation

@github-actions

Copy link
Copy Markdown

🤖 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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring (code improvements without changing functionality)
  • Documentation update
  • Performance improvement
  • Test coverage improvement

Related Issues

Fixes #
Relates to #

Changes Made

Testing Performed

  • All existing tests pass (dotnet test)
  • New tests added for new functionality
  • Manual testing performed
  • Tested on Windows
  • Tested with different backup types (Full/Differential)
  • Tested with network paths (UNC)

Test Results

Example: 82/83 tests passing

Backward Compatibility

  • This change is backward compatible with previous versions
  • EasyLog.dll remains compatible (no breaking changes to signatures)
  • Existing configuration files still work
  • Log formats unchanged (JSON/XML)

Documentation

  • Code comments updated (XML documentation for public APIs)
  • README.md updated (if needed)
  • Release notes updated (if applicable)
  • User manual updated (if user-facing changes)

Code Quality Checklist

  • Code follows C# Microsoft conventions (PascalCase, camelCase, etc.)
  • No code duplication (DRY principle respected)
  • Functions are reasonably sized (<50 lines ideally)
  • All code and comments are in English
  • No hardcoded absolute paths (use %AppData% or relative paths)
  • Nullable reference types handled properly
  • Error handling implemented appropriately

Review Checklist

  • Self-review completed
  • No console warnings or errors
  • Code builds successfully
  • Coverage report checked (if applicable)
  • CodeQL security scan passed

Screenshots / Logs

Additional Notes


Reviewers: Please check that all checkboxes are completed before approving.

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)
@PotaaatozWRLD PotaaatozWRLD marked this pull request as ready for review February 10, 2026 07:39
@codecov

codecov Bot commented Feb 10, 2026

Copy link
Copy Markdown

@github-advanced-security github-advanced-security AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@PotaaatozWRLD PotaaatozWRLD left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parfait

@PotaaatozWRLD PotaaatozWRLD merged commit b045526 into main Feb 10, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants